feat: Phase 4 — 9 new features (v1.1)
Some checks failed
CI / Build & test backend (push) Failing after 14m56s

REQ-MOB-010: BarcodeScreen.tsx — barcode scanner via react-native-camera
REQ-VIZ-001: WeeklyCalorieChart.tsx — 7-day bar chart on History screen
REQ-VIZ-002: Streak tracker — GET /meals/streak + HomeScreen badge
REQ-UX-001: Quick-add calories — POST /meals/quick-add + QuickAddScreen
REQ-UX-002: Food favourites — UserFoodMemory.favourite + toggle endpoint + FoodRow star
REQ-UX-003: GoalBanner.tsx — in-app slide-in when daily target hit
REQ-EXP-001: ExportController — GET /export/meals CSV download
REQ-WTR-001: Water tracking — WaterEntry entity + POST/GET /water + DailyDetails widget
REQ-UX-004: Daily logging reminder — HomeScreen after-18:00 banner

Also: Flyway V2 (favourite), V3 (water_entries), V4 (source constraints)
Traceability, CHANGELOG, PLAN updated after each feature
This commit is contained in:
2026-05-19 02:11:23 +03:00
parent 904f1c43b3
commit 12820632e7
46 changed files with 8151 additions and 63 deletions

View File

@@ -1,8 +1,8 @@
# Calorie Counter App — Plan & Requirements
**Version**: 1.0
**Date**: 2026-05-18
**Status**: Draft — awaiting review
**Version**: 1.1
**Date**: 2026-05-19
**Status**: Phase 4 in progress
---
@@ -301,32 +301,93 @@ FAB: [ + Add Meal ] (accessible from Home)
## 10. Phased Delivery Plan
### Phase 1 — Core MVP (23 weeks)
- [ ] User auth (register / login)
- [ ] User profile + BMR-based calorie target
- [ ] Food search (OpenFoodFacts API)
- [ ] Manual meal logging
- [ ] Barcode scan → auto-fill
- [ ] Daily calorie dashboard
- [ ] Meal history
### Phase 1 — Core MVP ✅ Implemented
- [x] User auth (register / login)
- [x] User profile + BMR-based calorie target
- [x] Food search (OpenFoodFacts API)
- [x] Manual meal logging
- [x] Barcode scan backend endpoint
- [x] Daily calorie dashboard
- [x] Meal history
### Phase 2 — AI Layer
- [ ] Photo capture screen
- [ ] OpenAI Vision API integration (`/ai/analyze-meal`)
- [ ] AI result confirmation screen
- [ ] Per-item portion sliders (Edit Meal screen)
- [ ] AI correction storage
### Phase 2 — AI Layer ✅ Implemented
- [x] Photo capture screen
- [x] OpenAI Vision API integration (`/ai/analyze-meal`)
- [x] AI result confirmation screen
- [x] Per-item portion sliders (Edit Meal screen)
- [x] AI correction storage
### Phase 3 — Intelligence + Polish
- [ ] Confidence-aware display (kcal ± range)
- [ ] UserFoodMemory — personalised portion defaults
- [ ] "Repeat last meal" shortcut
- [ ] Macro tracking display (protein/carbs/fat)
- [ ] Fine-tune AI suggestions based on user corrections
### Phase 3 — Intelligence + Polish ✅ Implemented
- [x] Confidence-aware display (kcal ± range)
- [x] UserFoodMemory — personalised portion defaults
- [x] "Repeat last meal" shortcut
- [x] Macro tracking display (protein/carbs/fat)
- [x] Fine-tune AI suggestions based on user corrections
### Phase 4 — Enhanced Features (v1.1)
- [x] REQ-MOB-010: Barcode scanner mobile screen (HIGH — fix UI gap)
- [x] REQ-VIZ-001: Weekly calorie bar chart on History screen (HIGH)
- [x] REQ-VIZ-002: Streak tracker — consecutive days logged (HIGH)
- [x] REQ-UX-001: Quick-add calories without food search (MEDIUM)
- [x] REQ-UX-002: Food favourites — star items in search (MEDIUM)
- [x] REQ-UX-003: Goal achievement in-app notification (MEDIUM)
- [x] REQ-EXP-001: Data export as CSV (LOW)
- [x] REQ-WTR-001: Water intake tracking (LOW)
- [x] REQ-UX-004: Daily logging reminder banner (LOW)
---
## 11. Open Questions (to resolve before development)
## 11. Phase 4 Requirement Details
### REQ-MOB-010 — Barcode Scanner Screen (HIGH)
**Gap**: Backend and API client for barcode lookup exist; mobile UI omits the scan option.
- New `BarcodeScreen.tsx` using `react-native-camera` (already installed) — full-screen camera with barcode overlay
- Add "Scan Barcode" as third option in HomeScreen bottom sheet
- On successful scan → call `GET /foods/barcode/{code}` → navigate to portion selector → log meal
### REQ-VIZ-001 — Weekly Calorie Chart (HIGH)
- New `WeeklyCalorieChart` component: proportional-height bar chart for last 7 days (pure RN `View`, no extra deps)
- Rendered at top of History screen above the daily list
- Each bar shows day-of-week label + kcal value; target line drawn at user's daily goal
- Color-coded: green = at/under goal, amber = over goal
### REQ-VIZ-002 — Streak Tracker (HIGH)
- Backend: `GET /meals/streak` → returns `{ currentStreak: N, longestStreak: N }`
- Counts consecutive calendar days (ending today) where at least one meal was logged
- Mobile: streak badge on Home screen below CalorieCard
### REQ-UX-001 — Quick-Add Calories (MEDIUM)
- New `QuickAddScreen.tsx` — number-pad input for kcal + meal type picker
- Backend: `POST /meals/quick-add``{ date, mealType, calories, label? }` → creates system food "Quick Add" entry
- Accessible from Home bottom sheet as "⚡ Quick Add"
### REQ-UX-002 — Food Favourites (MEDIUM)
- Add `favourite` boolean column to `user_food_memories` (Flyway V3)
- Backend: `POST /foods/{id}/favourite` (toggle) → upserts UserFoodMemory with `favourite=true/false`
- Mobile: star icon on each `FoodRow`; Favourites section at top of Search screen
### REQ-UX-003 — Goal Achievement Notification (MEDIUM)
- In-app only (no native push required)
- When `remaining ≤ 0` after a meal is logged, show an in-app success banner on HomeScreen
- Banner auto-dismisses after 4 seconds
### REQ-EXP-001 — Data Export CSV (LOW)
- Backend: `GET /export/meals?from=YYYY-MM-DD&to=YYYY-MM-DD``Content-Type: text/csv`
- Columns: `date, mealType, foodName, grams, calories, source`
- Mobile: "Export Data" button in Profile screen → uses React Native `Share` API
### REQ-WTR-001 — Water Intake Tracking (LOW)
- Backend: `WaterEntry` entity + Flyway V4 migration; `POST /water`, `GET /water/daily?date=`
- Mobile: water counter widget on DailyDetails screen (+250ml / +500ml quick buttons, reset)
### REQ-UX-004 — Daily Logging Reminder (LOW)
- In-app banner (no native push)
- If it is after 18:00 local time and `totalCalories === 0` for today, show a reminder banner on HomeScreen
- Dismissible; does not re-appear once dismissed in the same session
---
## 12. Open Questions (to resolve before development)
1. **Backend language**: Spring Boot (Java — familiar) or FastAPI (Python — easier AI integration)?
2. **Auth provider**: Self-managed JWT, Firebase Auth, or Auth0?