Files
calorie-counter/idea/start.md
Andris Enins 91cd18aec6 feat: initial implementation — all 35 requirements across phases 1-3
Backend (Spring Boot 3.2 / Java 21 / PostgreSQL):
- JWT auth with BCrypt password hashing
- User profile + Mifflin-St Jeor BMR calculator
- Food search + barcode via OpenFoodFacts API with local cache
- Meal CRUD with user data isolation and ownership checks
- AI photo analysis (OpenAI Vision) with confidence intervals
- AI correction feedback loop for personalisation
- Flyway DB migrations + RFC-7807 error responses

Mobile (React Native / TypeScript):
- Full navigation stack (Auth → Tabs → Home stack)
- Design tokens (WCAG 2.2 AA colours, 8px grid, 48px touch targets)
- 10 screens: Login, Register, Home, Search, Camera, AI Result, Edit Meal,
  Daily Details, History, Profile
- Confidence-aware calorie display (kcal ± range)
- Repeat last meal shortcut + macro tracking

Docs:
- docs/PLAN-AND-REQUIREMENTS.md
- docs/traceability.csv (35 requirements, all Implemented)
2026-05-18 21:56:13 +03:00

239 lines
4.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Great idea — this is actually a **non-trivial product problem**, not just a simple app. The hardest part is not UI or tracking, but **accuracy vs usability trade-off**.
Let me break it down in a way that fits your background (architecture + GenAI + product thinking).
***
# 🧠 1. First principle: “Precise calorie counting” is inherently imperfect
Even the best apps are not 100% accurate because:
* Food labels themselves can legally deviate (\~20%) [\[scienceinsights.org\]](https://scienceinsights.org/most-accurate-calorie-tracker-apps-ai-and-wearables/)
* Portion estimation is the biggest error source (humans underestimate 2040%) [\[healthlyai.com\]](https://www.healthlyai.com/blog/ai-calorie-tracking-vs-manual-logging)
* AI image recognition still has \~1025% error depending on food complexity [\[scienceinsights.org\]](https://scienceinsights.org/most-accurate-calorie-tracker-apps-ai-and-wearables/)
👉 So your goal should be:
> **“consistent estimation” > “absolute precision”**
***
# 🏗️ 2. 3 viable approaches (you should choose one or combine)
## Option A — Database-driven (classic, most reliable baseline)
**How it works:**
* User selects food from DB or scans barcode
* Calories come from nutrition datasets
**Tech:**
* APIs like Open Food Facts (free, open DB) [\[openfoodfa....github.io\]](https://openfoodfacts.github.io/openfoodfacts-server/api/)
* USDA / Nutritionix / Edamam [\[rapidapi.com\]](https://rapidapi.com/collection/nutrition)
✅ Pros:
* Most consistent & explainable
* Easy to build MVP
* Works well for packaged food
❌ Cons:
* Bad UX for homemade meals
* Requires manual input
***
## Option B — AI / Image-based (cool, but tricky)
**How it works:**
1. Detect food (CV model)
2. Estimate portion (hard!)
3. Map to nutrition DB
Typical pipeline:
* Image → food classification → portion estimation → calorie calculation [\[arxiv.org\]](https://arxiv.org/html/2412.09936v1)
✅ Pros:
* Amazing UX (“just take a photo”)
* Differentiating feature
❌ Cons:
* Accuracy varies a lot
* Hard problem (volume estimation especially)
***
## Option C — Hybrid (BEST PRACTICE ✅)
This is what modern apps do:
* Barcode scan → DB
* Photo → AI suggestion
* Manual correction → user confirms
👉 This gives:
* Speed of AI
* Accuracy of database
📌 Industry trend:
> Best apps combine AI + verified food databases [\[welling.ai\]](https://www.welling.ai/articles/most-accurate-calorie-tracker-app)
***
# 🧩 3. Recommended architecture (simple but scalable)
Given your background, Id suggest:
## 🟢 MVP architecture
```text
Mobile App (React Native)
|
Backend (Node / Java / FastAPI)
|
----------------------------------
| Food DB API (OpenFoodFacts) |
| AI Service (image analysis) |
| User data (Firebase / Postgres)|
----------------------------------
```
## Key components
### 1. Food data layer
* Cache food DB locally (performance)
* Normalize entries (important!)
### 2. AI service (optional MVP v2)
* Start simple:
* OpenAI / vision model
* or pre-trained food classifier
* Later:
* custom fine-tuned model
### 3. Calorie engine
* Core logic:
* calories = portion × kcal\_per\_100g
* Add:
* macro tracking (protein/fat/carbs)
***
# 🎯 4. Where you can actually differentiate (this is key)
Most apps already exist. Your edge must be here:
## 💡 Ideas (aligned with your GenAI interest)
### 1. “Confidence-aware calories”
Instead of:
> 500 kcal
Show:
> 500 kcal ± 80 kcal (confidence 85%)
👉 No one does this well, but its honest and valuable.
***
### 2. Learning system
* User corrects AI → model improves
* Build personal “food profile”
***
### 3. Context-aware tracking
* “Restaurant mode”
* “Home cooking mode”
* “Meal template reuse”
***
### 4. Behavioural layer (underrated)
Apps fail because people stop logging.
Add:
* Auto-suggestions
* Meal prediction
* “You usually eat this at lunch”
***
# ⚙️ 5. Practical MVP plan (step-by-step)
## Phase 1 (23 weeks)
✅ Manual + DB only
* Food search
* Barcode scan
* Daily calorie counter
## Phase 2
✅ Add AI assist
* Upload photo → suggest food
* User confirms
## Phase 3
✅ Smart features
* Meal history
* Predictions
* Personalisation
***
# 🧪 6. Accuracy strategy (critical)
To be “more or less precise”, do this:
1. Use **verified databases first**
2. Always allow **manual override**
3. Store **user corrections**
4. Avoid pretending AI is exact
***
# 🚀 My recommendation for YOU
Given your skills + interests:
👉 Build a **GenAI-first hybrid app**
* Start simple (DB + manual)
* Add AI layer as enhancement
* Focus on **UX + intelligence**, not just counting
***
# 💬 If you want next step
I can help you:
* define **feature set for MVP (like PRD)**
* design **data model + APIs**
* or sketch **UI flows (very important here)**
Just tell me 👍