AI-powered waste sorting and disposal guidance from a single photo.
Gemini multimodal analysis β’ Python + FastAPI backend β’ Expo + React Native mobile app β’ Firebase-secured personal history
SnapSort AI is a mobile application and backend service for identifying how to responsibly dispose of everyday items using multimodal AI image analysis.
The core idea is simple:
Capture a photo of an item, and let a Python-powered AI backend determine how it should be sorted, scored, and safely disposed of.
A user opens the SnapSort AI mobile app, captures or selects a photo, and the image is sent to a Python FastAPI backend. The backend constructs a structured prompt and sends the image to a Gemini multimodal model, which returns a disposal category, an eco score, practical guidance, an optional reuse idea, and an optional safety warning. The result is displayed instantly and can be saved to the user's private, Firebase-secured Waste Journal.
The project is designed as a complete engineering pipeline connecting mobile UI, a Python API service, generative AI reasoning, and per-user cloud storage β not just an isolated model demo.
Development note: the project currently ships with a working end-to-end pipeline (mobile capture β Python API β Gemini analysis β Firestore storage). Production deployment requires hosting the Python backend on a public HTTPS server instead of a local development machine.
Correct disposal decisions are not always obvious, and most people do not have time to research every item they throw away.
Common everyday questions include:
- Is this item recyclable, reusable, compostable, or hazardous?
- Does it need to be cleaned or disassembled first?
- Could it be reused instead of discarded?
- Are there safety precautions to be aware of?
SnapSort AI focuses on the last-mile workflow between a photo and a confident disposal decision.
| Capability | What it does |
|---|---|
| Photo-based AI analysis | Sends a captured or selected photo to a Python backend for Gemini-powered reasoning |
| Disposal classification | Assigns each item to recycle, reuse, compost, trash, or hazardous |
| Eco score | Produces a 0β10 score reflecting the relative environmental impact of the item |
| Actionable guidance | Returns clear, natural-language disposal instructions |
| Reuse suggestions | Suggests a creative reuse idea when applicable |
| Safety warnings | Flags hazardous or sensitive items explicitly |
| Firebase authentication | Secure per-user sign-in and session handling |
| Private Waste Journal | Stores each user's results under their own Firestore subcollection |
| Weekly progress tracking | Summarizes scan activity, sorting distribution, and weekly goals |
| Local daily reminders | On-device notifications to build a consistent sorting habit |
| Cross-network API access | Works with local development servers and production HTTPS deployments |
βββββββββββββββββββββββββββββββ
β Mobile Application (Expo) β
β Camera / Gallery Capture β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Firebase Authentication β
β Sign in / session state β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Python FastAPI Backend β
β /api/scans/analyze endpoint β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Prompt Construction β
β (backend/app/prompts.py) β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Gemini Multimodal Model β
β Image + Prompt β JSON Resultβ
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Structured Analysis Result β
β category, ecoScore, advice,β
β reuseIdea, warning β
ββββββββββββββββ¬βββββββββββββββ
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
ββββββββββββββββββ ββββββββββββββββββββββ
β Result Screen β β Cloud Firestore β
β (Mobile UI) β β users/{uid}/scans/*β
ββββββββββββββββββ ββββββββββββββββββββββ
SnapSort AI's Python backend is the core reasoning layer of the application.
Item Photo (Base64)
β
βΌ
FastAPI /api/scans/analyze
β
βΌ
Prompt Construction (prompts.py)
β
βΌ
Gemini Multimodal Model
β
βΌ
Structured JSON Response
β
βΌ
Validation + Normalization
β
βΌ
Mobile Result Rendering
β
βΌ
Optional Save to Firestore
Expected structured output fields:
itemName
category (recycle | reuse | compost | trash | hazardous)
ecoScore (0β10)
confidence (low | medium | high)
disposalAdvice
reuseIdea (optional)
warning (optional)
users/
βββ {userId}/
βββ scans/
βββ {scanId}
βββ itemName : string
βββ category : "recycle" | "reuse" | "compost" | "trash" | "hazardous"
βββ ecoScore : number (0β10)
βββ confidence : "low" | "medium" | "high"
βββ disposalAdvice : string
βββ reuseIdea : string (optional)
βββ warning : string (optional)
βββ createdAt : timestamp
auth.store.ts β current authenticated user
onboarding.store.ts β first-run onboarding completion state
scan.store.ts β active image, analysis result, loading state
The backend is a lightweight Python FastAPI service responsible for receiving images, verifying Firebase identity, calling the Gemini model, and returning a structured disposal-analysis result.
Receive Base64 image
β
βΌ
Verify Firebase ID token (firebase_auth.py)
β
βΌ
Build Gemini prompt (prompts.py)
β
βΌ
Call Gemini service (gemini_service.py)
β
βΌ
Validate/normalize AI response (schemas)
β
βΌ
Return JSON result to mobile app
backend/
βββ requirements.txt
βββ app/
βββ main.py # FastAPI application entry point
βββ api/
β βββ scans.py # Image-analysis and scan API routes
βββ config.py # Environment and application configuration
βββ firebase_auth.py # Firebase ID token verification
βββ gemini_service.py # Gemini multimodal analysis integration
βββ prompts.py # Structured AI prompt templates
βββ schemas/ # Request and response models
βββ services/ # Backend business logic
βββ utils/ # Shared backend utilities
SnapSort/
β
βββ App.tsx # App bootstrap, animated splash, Firebase auth listener
βββ app.json # Expo configuration, icons, splash settings
β
βββ assets/
β βββ icon.png
β βββ adaptive-icon.png
β βββ splash-icon.png
β βββ images/
β βββ hero-leaf.png
β βββ pathway-recycle.png
β βββ pathway-reuse.png
β βββ pathway-compost.png
β βββ pathway-dispose.png
β βββ waste-journal-hero.png
β
βββ backend/ # Python FastAPI service (see above)
β
βββ src/
β βββ components/
β β βββ common/
β β βββ scan/
β β
β βββ constants/
β β βββ categories.ts # Disposal pathway metadata
β β βββ theme.ts # Shared color tokens and typography
β β
β βββ navigation/
β β βββ RootNavigator.tsx
β β βββ types.ts
β β
β βββ screens/
β β βββ auth/ # Login, register, forgot password
β β βββ onboarding/ # First-run onboarding
β β βββ home/ # Dashboard
β β βββ scan/ # Camera, preview, result
β β βββ history/ # Saved scan history
β β βββ impact/ # Waste Journal
β β βββ profile/ # Profile, notifications, privacy, about
β β
β βββ services/
β β βββ api/
β β β βββ scan-api.service.ts # Python backend API client
β β βββ firebase/
β β βββ firebase.ts # Firebase app/auth/Firestore init
β β βββ scans.service.ts # Firestore read/write for scans
β β
β βββ stores/
β β βββ auth.store.ts
β β βββ onboarding.store.ts
β β βββ scan.store.ts
β β
β βββ types/
β βββ scan.ts
β
βββ docs/
β βββ assets/
β βββ snapsort-logo.svg
β βββ dashboard.png
β
βββ index.ts
βββ package.json
βββ tsconfig.json
βββ README.md
git clone https://github.com/<YOUR_USERNAME>/SnapSort.git
cd SnapSortnpm installWindows PowerShell:
cd backend
py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1Linux/macOS:
cd backend
python3.11 -m venv .venv
source .venv/bin/activatepython -m pip install --upgrade pip
pip install -r requirements.txtCreate .env in the project root (mobile):
EXPO_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
EXPO_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.firebasestorage.app
EXPO_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
EXPO_PUBLIC_FIREBASE_APP_ID=your_firebase_app_id
EXPO_PUBLIC_API_URL=http://192.168.x.x:8000Create backend/.env (Python):
GEMINI_API_KEY=your_gemini_api_key
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_CLIENT_EMAIL=your_service_account_email
FIREBASE_PRIVATE_KEY="your_private_key"Never commit
.env,backend/.env, or any Firebase service-account file to Git.
cd backend
.\.venv\Scripts\Activate.ps1
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Default development address:
http://localhost:8000
Interactive API documentation:
http://localhost:8000/docs
Alternative documentation:
http://localhost:8000/redoc
npx expo start --clearThen choose one:
Press "a" β open Android emulator
Scan QR code β open in Expo Go on a physical device
Native features such as push notifications require an Expo development build rather than Expo Go.
| Environment | EXPO_PUBLIC_API_URL |
|---|---|
| Physical Android phone (same Wi-Fi) | http://YOUR_PC_IPV4:8000 |
| Android Studio emulator | http://10.0.2.2:8000 |
| Production APK | https://your-deployed-api-domain.com |
Health check for the backend service.
Interactive Swagger documentation generated by FastAPI.
Runs multimodal AI analysis on a submitted image.
Example request body:
{
"imageBase64": "BASE64_ENCODED_IMAGE_DATA"
}Example response:
{
"itemName": "Plastic water bottle",
"category": "recycle",
"ecoScore": 7.5,
"confidence": "high",
"disposalAdvice": "Rinse the bottle and place it in your recycling bin. Remove the cap if your local program requires separate disposal.",
"reuseIdea": "Reuse as a small planter or refillable water container.",
"warning": ""
}Confirm the exact route defined in
backend/app/api/scans.py, since route naming may evolve during development.
import base64
import requests
url = "http://127.0.0.1:8000/api/scans/analyze"
with open("item.jpg", "rb") as image_file:
encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
response = requests.post(
url,
json={"imageBase64": encoded_image},
timeout=60,
)
response.raise_for_status()
result = response.json()
print(result["itemName"])
print(result["category"])
print(result["ecoScore"])
print(result["disposalAdvice"])Enable required sign-in methods in Firebase Console:
Firebase Console β Build β Authentication β Sign-in method
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, create, update: if
request.auth != null &&
request.auth.uid == userId;
allow delete: if false;
match /scans/{scanId} {
allow read, create, update, delete: if
request.auth != null &&
request.auth.uid == userId;
}
}
}
}These rules ensure a signed-in user can only access their own profile document and their own saved scans.
The Waste Journal screen aggregates a user's saved scans into a personal sustainability dashboard.
Saved Scans
β
βΌ
Weekly Aggregation
β
βΌ
Category Distribution
β
βΌ
Personalized Insight Message
β
βΌ
Journal Dashboard
Displayed metrics include:
Total scans
Average eco score
Pathway diversity
Weekly scan progress
Disposal category distribution
Recent scan entries
SnapSort AI supports local daily reminders to build a consistent sorting habit.
Remote push-notification functionality is unavailable in standard Expo Go for current Expo SDK versions. Use a development build for full native notification testing:
npx expo install expo-dev-client
npx expo prebuild --clean
npx expo run:androidAfter the development build installs successfully:
npx expo startOpen the installed SnapSort development build instead of Expo Go.
npx expo prebuild --clean
npx expo run:androidnpm install -g eas-cli
eas login
eas build:configureInstallable APK:
eas build --platform android --profile previewPlay Store bundle:
eas build --platform android --profile productionDeploy the Python backend to a public HTTPS host before producing a release APK. A local address such as
http://192.168.x.x:8000only works while the developer's computer is running on the same network.
Target production architecture:
SnapSort Android Application
β
βΌ HTTPS
Deployed Python FastAPI Backend
β
βΌ
Gemini Analysis + Firebase
Deployment checklist:
Deploy backend/ to Render, Railway, Fly.io, or a private server
Run with: uvicorn app.main:app --host 0.0.0.0 --port $PORT
Serve the API over HTTPS
Store backend secrets as host environment variables
Update EXPO_PUBLIC_API_URL to the deployed HTTPS URL
Rebuild the Android application
Restrict Firebase API keys appropriately
Keep Gemini and Firebase Admin credentials out of the mobile bundle
All Gemini calls happen inside the Python backend rather than directly from the mobile app. This keeps the Gemini API key off the device, allows centralized prompt engineering, and makes it possible to change AI providers without shipping a new mobile release.
Every saved scan is stored under users/{userId}/scans/{scanId} rather than a single shared collection. Firestore Security Rules enforce that a user can only read or write their own documents.
The mobile app resolves the backend address from EXPO_PUBLIC_API_URL rather than hardcoding it, allowing the same codebase to target a local development server, an Android emulator, or a deployed production API.
The app waits for font loading, onboarding status, and Firebase auth state before rendering the main navigator, avoiding a flash of the wrong screen during startup.
- Camera and gallery image capture
- Python FastAPI backend
- Gemini multimodal analysis integration
- Structured disposal-analysis response
- Firebase Authentication
- Per-user Firestore scan storage
- Firestore Security Rules
- Waste Journal dashboard
- Local daily reminders
- Animated startup splash screen
- Circular, consistent mobile UI system
- Deploy Python backend to a production HTTPS host
- Add image compression before upload
- Add offline scan queue with automatic sync
- Expand Waste Journal analytics and date filters
- Add region-specific disposal-rule customization
- Add automated backend and mobile tests
- Add CI/CD for Android preview and production builds
SnapSort AI is currently a research/production-style prototype rather than a certified waste-management authority.
- AI-generated disposal guidance is general and may not reflect local municipal rules.
- Image quality, lighting, and framing affect analysis accuracy.
- The eco score is a relative indicator, not a certified environmental measurement.
- Local backend testing requires the developer machine and phone to share the same network.
- Production use requires a deployed, secured, and monitored backend rather than a local development server.
For consistent testing, keep this information documented per environment:
Python version
Node.js version
Firebase project ID
Backend .env keys (names only, never values)
EXPO_PUBLIC_API_URL used for testing
Device type (emulator / physical phone)
git status
git diff
git add .
git commit -m "feat: describe your change"
git push origin mainThis project is released under the MIT License.
See LICENSE for details.
Firebase and the Gemini API are subject to their own separate terms of use. Review each provider's license and usage requirements before production deployment.
SnapSort AI builds on the following technologies and services:
Python
FastAPI
Expo
React Native
Firebase
Gemini API
React Native Paper
Zustand
All third-party tools remain subject to their respective licenses.
SnapSort AI Development Team
Full-Stack Mobile Engineering | Python Backend Engineering | Applied AI Integration
SnapSort AI combines:
Computer Vision
+ Generative AI Integration
+ Python API Engineering
+ Mobile Application Development
+ Secure Cloud Data Design
Most people discard items without knowing the best disposal path. SnapSort AI turns that single everyday decision into a fast, guided, and encouraging interaction.
Item Photo
β
Python Backend + Gemini AI
β
Disposal Category + Eco Score
β
Clear Guidance
β
Saved Personal History
β
Long-Term Sustainable Habits
Smarter choices. Smaller footprint.