Snap a photo of your meal, get instant AI-powered nutrition analysis, and track your diet with a personal AI assistant that knows your pantry.
Live Web App: https://mealsnap-327.web.app | API Docs: https://mealsnap-8bgs.onrender.com/docs
Note: Backend runs on Render free tier — first request after idle takes ~30s to wake up.
- Photo-based meal logging — take a photo or pick from gallery; Gemini Vision identifies every food item with confidence scores (High / Medium / Low)
- 60 FPS quantity slider — drag to adjust grams per food item; calories and macros recalculate in real time as you drag
- USDA nutrition data — calorie and macro values sourced from USDA FoodData Central, cached to avoid duplicate lookups
- Daily nutrition dashboard — calorie ring, macro breakdown (protein / carbs / fat), and a live list of today's meals
- Meal history — browse all past meals filtered by today / this week / this month; tap any meal for full item detail
- AI Nutrition Assistant — conversational chat powered by Gemini with full function-calling: ask questions, log meals, manage pantry, and get a daily summary — all through natural language
- Context-aware responses — the assistant knows your recent meals and pantry contents before it replies
- Time-context injection — current time is sent with every photo analysis so Gemini can distinguish breakfast from dinner
- Pantry management — add ingredients with quantity, unit, category, and expiration date; expiring-soon alerts surface automatically
- AI recipe suggestions — tap Recipes to get Gemini-generated meal ideas based on exactly what you have in your pantry
- Real-time group chat — Firestore-backed multi-room chat; create a room, invite friends by email, messages appear instantly via StreamBuilder
- Latency masking — rotating funny messages + progressive step indicators make the 2–4s AI analysis feel fast
- TDEE onboarding — Mifflin-St Jeor formula calculates personalised daily calorie and macro targets after registration
- Friendly error messages — no raw JSON dumps; every error (no food detected, AI timeout, network failure) gets a human-readable dialog
- Dark theme — "Neural Night" dark theme across all screens
| Layer | Technology |
|---|---|
| Frontend | Flutter 3.38 (Web + Android) |
| Backend | FastAPI + Python 3.12 |
| Database | PostgreSQL 15 (SQLAlchemy ORM) |
| AI — Vision | Google Gemini 2.5 Flash (photo analysis) |
| AI — Chat | Google Gemini 2.5 Flash (function-calling chat) |
| Nutrition Data | USDA FoodData Central API |
| Auth | JWT (HS256 + PBKDF2, no external deps) |
| Real-time Chat | Firebase Firestore + Anonymous Auth |
| Frontend Hosting | Firebase Hosting |
| Backend Hosting | Render (free tier) |
┌─────────────────────────────────────────────────────┐
│ Flutter Frontend │
│ Web (Firebase Hosting) + Android APK │
│ │
│ screens/ widgets/ services/ models/ │
│ │ │ │ │
│ └───────────┴───────────┘ │
│ api_service.dart ←── JWT auth │
│ firebase_chat_service.dart ←── Firestore│
└────────────────────┬────────────────────────────────┘
│ HTTPS
┌────────────────────▼────────────────────────────────┐
│ FastAPI Backend (Render) │
│ │
│ /api/auth JWT register / login / me │
│ /api/meals analyze (Gemini Vision + USDA) │
│ /api/chat Gemini function-calling chat │
│ /api/pantry CRUD + expiring-soon │
│ /api/group-chat legacy HTTP group messages │
│ │
│ services/gemini.py ← Gemini Vision API │
│ services/gemini_chat.py ← Gemini Chat + tools │
│ services/nutrition.py ← USDA lookup + cache │
│ middleware/rate_limit.py ← token bucket (burst 3) │
└────────────┬───────────────────┬────────────────────┘
│ │
┌────────▼──────┐ ┌────────▼──────────┐
│ PostgreSQL │ │ Firebase │
│ (Render) │ │ Firestore + Auth │
│ 8 tables │ │ (group chat) │
└───────────────┘ └────────────────────┘
- Miniconda (Python 3.12)
- Flutter 3.38+
- PostgreSQL 15
- A Gemini API key (free tier: 1,500 req/day)
- A USDA API key (free, no rate limit)
git clone https://github.com/asifulshiam/mealsnap.git
cd mealsnapCreate backend/.env:
GEMINI_API_KEY=your_gemini_key_here
USDA_API_KEY=your_usda_key_here
DATABASE_URL=postgresql://localhost/mealsnap_db
JWT_SECRET=your_random_secret_here# Create conda environment
conda create -n mealsnap python=3.12 -y
conda activate mealsnap
pip install -r backend/requirements.txt
# Create the database
createdb mealsnap_db
# Start the server
cd backend
uvicorn app.main:app --reload
# API docs → http://localhost:8000/docscd frontend
flutter pub get
flutter run -d chromeThe app defaults to http://localhost:8000 as the backend URL for local dev.
- Backend health: http://localhost:8000/api/test/db →
{"status": "connected"} - API keys loaded: http://localhost:8000/api/test/env → all
true
mealsnap/
├── backend/
│ └── app/
│ ├── main.py # FastAPI app, CORS, router registration
│ ├── database.py # SQLAlchemy engine + table creation
│ ├── models/ # ORM models (user, meal, food, pantry, chat)
│ ├── schemas/ # Pydantic request/response schemas
│ ├── routers/ # auth, meals, chat, pantry, group_chat
│ ├── services/
│ │ ├── gemini.py # Gemini Vision — photo → food list
│ │ ├── gemini_chat.py # Gemini Chat — function-calling loop
│ │ └── nutrition.py # USDA lookup with in-memory cache
│ ├── middleware/
│ │ └── rate_limit.py # Token bucket (burst 3, 1/4s refill)
│ └── tests/ # pytest suite (36 tests, real DB)
├── frontend/
│ └── lib/
│ ├── main.dart
│ ├── screens/ # 18 screen files
│ ├── widgets/
│ │ └── smooth_quantity_slider.dart # 60 FPS killer feature
│ ├── services/
│ │ ├── api_service.dart # HTTP client + JWT
│ │ └── firebase_chat_service.dart # Firestore group chat
│ └── theme/app_theme.dart # "Neural Night" dark theme
└── docs/
├── screenshots/ # All app screenshots
└── MEALSNAP_CONTEXT.md # Full technical reference
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Create account → JWT |
| POST | /api/auth/login |
Login → JWT |
| GET | /api/auth/me |
Current user from token |
| POST | /api/meals/analyze |
Photo → Gemini Vision → USDA → save |
| GET | /api/meals |
List user's meals |
| GET | /api/meals/summary/daily |
Daily totals + meal list |
| POST | /api/chat |
Message → Gemini function-calling → response |
| GET | /api/pantry |
List pantry items |
| POST | /api/pantry |
Add pantry item |
| GET | /api/pantry/expiring?days=3 |
Items expiring within N days |
Full interactive docs at /docs when running locally.
| Service | Platform | URL |
|---|---|---|
| Web frontend | Firebase Hosting (Spark — free) | https://mealsnap-327.web.app |
| Backend API | Render (free tier) | https://mealsnap-8bgs.onrender.com |
| Database | Render PostgreSQL (free tier) | internal to backend |
| Group chat | Firebase Firestore | mealsnap-327 project |
To redeploy the backend, push to feature/frontend-ui-complete — Render auto-deploys on every commit.
To redeploy the frontend:
cd frontend
nvm use --lts
flutter build web --release --dart-define=API_URL=https://mealsnap-8bgs.onrender.com
firebase deploy --only hosting --project mealsnap-327
















