feat: Phase 4 — 9 new features (v1.1)
Some checks failed
CI / Build & test backend (push) Failing after 14m56s
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:
@@ -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 (2–3 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?
|
||||
|
||||
@@ -33,3 +33,12 @@ REQ-SEC-003,Input validation on all request bodies and path variables,1,P0,Secur
|
||||
REQ-SEC-004,No secrets hardcoded — all via environment variables,1,P0,Security,backend/src/main/resources/application.yml (${DB_PASSWORD} ${JWT_SECRET} ${OPENAI_API_KEY}),,Implemented
|
||||
REQ-A11Y-001,WCAG 2.2 AA compliance — contrast ratio >= 4.5:1 on all UI,1,P1,Accessibility,mobile/src/theme/colors.ts (contrast-verified tokens) + accessibilityLabel on all interactive elements,,Implemented
|
||||
REQ-A11Y-002,Minimum 48x48px touch targets on all interactive elements,1,P1,Accessibility,mobile/src/theme/spacing.ts#touchTarget=48 + all buttons/rows enforce minHeight,,Implemented
|
||||
REQ-MOB-010,Barcode scanner mobile screen (REQ-MOB-002 gap fix),4,P0,Mobile,mobile/src/screens/BarcodeScreen.tsx + navigation/AppNavigator.tsx (Barcode route) + screens/HomeScreen.tsx (Scan Barcode option),,Implemented
|
||||
REQ-VIZ-001,Weekly calorie bar chart on History screen,4,P1,Visualisation,mobile/src/components/WeeklyCalorieChart.tsx + screens/HistoryScreen.tsx (last-7-days aggregation + target line),,Implemented
|
||||
REQ-VIZ-002,Streak tracker — consecutive days logged,4,P1,Visualisation,backend/src/main/java/com/caloriecounter/service/MealService.java#getStreak + repository/MealEntryRepository.java#findDistinctDatesByUserId + controller/MealController.java#getStreak + mobile/src/screens/HomeScreen.tsx (streak badge) + services/api.ts#getStreak,,Implemented
|
||||
REQ-UX-001,Quick-add calories without food search,4,P2,UX,backend/src/main/java/com/caloriecounter/service/MealService.java#quickAddMeal + controller/MealController.java#quickAdd + entity/MealEntry.java (quickadd source) + entity/FoodItem.java (quickadd source) + mobile/src/screens/QuickAddScreen.tsx + services/api.ts#quickAddCalories,,Implemented
|
||||
REQ-UX-002,Food favourites — star items in search,4,P2,UX,backend: entity/UserFoodMemory.java (favourite field) + db/migration/V2__add_favourite_to_user_food_memory.sql + repository/UserFoodMemoryRepository.java + service/FoodService.java#toggleFavourite + service/FoodService.java#getFavourites + controller/FoodController.java (GET /foods/favourites + POST /foods/{id}/favourite); mobile: components/FoodRow.tsx (star icon) + screens/SearchScreen.tsx (favourites section) + services/api.ts#getFavourites#toggleFavourite,,Implemented
|
||||
REQ-UX-003,Goal achievement in-app notification,4,P2,UX,mobile/src/components/GoalBanner.tsx + screens/HomeScreen.tsx (goalReached state + banner render),,Implemented
|
||||
REQ-EXP-001,Data export as CSV,4,P3,Export,backend/src/main/java/com/caloriecounter/controller/ExportController.java (GET /export/meals) + mobile/src/screens/ProfileScreen.tsx (Export button + Share) + services/api.ts#exportMeals,,Implemented
|
||||
REQ-WTR-001,Water intake tracking,4,P3,Water,backend: entity/WaterEntry.java + repository/WaterEntryRepository.java + controller/WaterController.java + db/migration/V3__water_entries.sql; mobile: screens/DailyDetailsScreen.tsx (water widget) + services/api.ts#getWaterDaily#logWater,,Implemented
|
||||
REQ-UX-004,Daily logging reminder banner,4,P3,UX,mobile/src/screens/HomeScreen.tsx (showLogReminder state — shown after 18:00 if totalCalories === 0; dismissible),,Implemented
|
||||
|
||||
|
Reference in New Issue
Block a user