Original Idea
mobile app for tracking calories
Product Requirements Document: NutriPath Pro
1. Executive Summary
NutriPath Pro is a high-performance, "local-first" mobile calorie and nutrient tracker designed to eliminate the high friction associated with dietary logging. By leveraging 2026-standard AI photo recognition, ultra-fast barcode scanning, and high-fidelity data visualization, the app provides athletes and health-conscious individuals with a seamless tool for managing their nutritional goals. Built on a modern React Native architecture with robust offline synchronization, NutriPath Pro ensures user data is always accessible, secure, and actionable, even without an active internet connection.
2. Problem Statement
Existing nutritional tracking applications suffer from three primary pain points:
- Logging Friction: Manual entry is tedious, leading to user abandonment within the first 14 days.
- Data Latency: Cloud-dependent apps feel sluggish, especially in low-connectivity environments like gyms or grocery stores.
- Lack of Actionable Insights: Static charts fail to provide the deep, temporal understanding required for serious athletes or individuals managing chronic health conditions.
3. Goals & Success Metrics
- User Retention: Achieve a 45% Day-30 retention rate by minimizing logging time to under 10 seconds per entry.
- Data Accuracy: Achieve 90%+ accuracy in AI-based food recognition and portion estimation.
- Performance: Maintain a consistent 60–120 FPS for all data visualizations and dashboard interactions.
- Sync Reliability: Ensure 100% data consistency between local SQLite and PostgreSQL backend via the Transactional Outbox pattern.
4. User Personas
| Persona | Goals | Pain Points | | :--- | :--- | :--- | | The Performance Athlete | Precise macro tracking (Protein/Carbs/Fat) to optimize training. | Hard to log complex home-cooked recipes. | | The Weight Management Seeker | Simple calorie counting and weight loss progress visualization. | Overwhelmed by too many technical data points. | | The Health Manager | Tracking specific micronutrients or allergens due to medical needs. | Fear of data privacy leaks regarding health history. |
5. User Stories
- As a user, I want to scan a barcode so that I can instantly see the nutritional value and add it to my daily log.
- As an athlete, I want to see my weekly protein trends via an interactive chart so that I can adjust my meal prep.
- As a busy professional, I want to take a photo of my meal so that AI can estimate the calories without me typing anything.
- As a privacy-conscious user, I want my health data to be encrypted and synced securely so that I am compliant with HIPAA/GDPR standards.
6. Functional Requirements
6.1 Food Logging & Database
- Multi-Modal Entry: Support for barcode scanning (Vision Camera V3), AI photo recognition (Spike Nutrition API), and text-based search (Nutritionix API).
- Recipe Builder: Allow users to group multiple ingredients into a single "Recipe" for one-tap logging.
- Local-First Search: Index "frequent foods" in a local SQLite database for instant offline lookup.
6.2 Nutritional Engine
- Dynamic TDEE Calculation: Automatically calculate Total Daily Energy Expenditure based on age, weight, and activity level synced from wearables.
- Macro-Targeting: Set specific ratios for Protein, Fats, and Carbohydrates.
6.3 Progress & Visualization
- Daily Dashboard: High-fidelity Skia-based rings for "Calories Remaining."
- Historical Logs: Interactive Victory Native XL charts for weight and nutrient trends over 7/30/90 days.
6.4 Wearable Integration
- Bi-Directional Sync: Read active energy and steps from Apple HealthKit and Android Health Connect; write nutritional summaries back to the health ecosystems.
7. Technical Requirements
7.1 Frontend (Mobile)
- Framework: Expo SDK 54 (React Native 0.81) utilizing the New Architecture (Fabric/TurboModules).
- State Management: Redux Toolkit 2.11.2 with RTK Query for server state.
- Local Database:
expo-sqlitewith Drizzle ORM for type-safe local storage. - Visuals:
react-native-skiafor custom UI andvictory-native(XL version) for charts. - Camera:
react-native-vision-camerafor high-speed barcode scanning.
7.2 Backend
- Runtime: Node.js 22+ with NestJS (TypeScript 5.4+).
- Primary Database: PostgreSQL 18 with TimescaleDB (for time-series logs) and pgvector (for AI food embeddings).
- Caching: Redis for session management and frequent food data.
- Hosting: AWS ECS (Fargate) with RDS, utilizing AWS European Sovereign Cloud for GDPR regions.
7.3 Infrastructure & Integrations
- Auth: Auth0 with OAuth 2.1, PKCE, and DPoP (Demonstrating Proof-of-Possession).
- Sync: PowerSync for PostgreSQL-to-SQLite logical replication.
- Payments: Stripe for premium tier subscriptions.
8. Data Model
8.1 User Entity
userId(UUID),email(String),encryptedPhysicalProfile(JSONB),activityLevel(Enum),lastSyncTimestamp(BigInt).
8.2 FoodItem Entity
foodId(UUID),name(String),barcode(String, indexed),macros(JSONB: {p, c, f, cal}),isCustom(Boolean).
8.3 LogEntry Entity (Time-Series)
entryId(UUID),userId(FK),foodId(FK),quantity(Float),mealType(Enum: B/L/D/S),timestamp(TIMESTAMPTZ).
8.4 SyncOutbox Entity
mutationId(UUID),payload(JSONB),status(Enum: Pending/Synced),retryCount(Int).
9. API Specification (Sample)
9.1 POST /api/v1/logs
- Request:
Header: { Authorization: Bearer <DPoP-Token> }, Body: { foodId: UUID, quantity: 1.5, timestamp: ISO8601 } - Response:
201 Created { entryId: UUID, currentDailyTotal: { calories: 1850, goal: 2000 } }
9.2 GET /api/v1/food/search?q=banana
- Response:
200 OK [ { foodId: UUID, name: "Banana", caloriesPerUnit: 89, source: "USDA" } ]
10. UI/UX Requirements
- Dashboard: A central "Calorie Ring" using
react-native-skiawith a liquid-fill animation. - Logging Flow: A "Swipe-to-Log" gesture on search results to minimize taps.
- Dark Mode: 2026-compliant "OLED Black" mode for battery efficiency.
- Micro-interactions: Haptic feedback (Taptic Engine/Haptics API) upon successful barcode scan or goal completion.
11. Non-Functional Requirements
- Offline Capability: Users must be able to log food and view the last 7 days of history without a network connection.
- Security: AES-256-GCM encryption for all PII/PHI at rest.
- Latency: Search results must return in <200ms (via local indexing).
- Accessibility: Full support for Screen Readers (TalkBack/VoiceOver) and dynamic text scaling.
12. Out of Scope
- In-app social network/feed (deferred to V2).
- Direct integration with medical insurance provider portals.
- Support for desktop web logging (Mobile-first focus).
13. Risks & Mitigations
| Risk | Impact | Mitigation | | :--- | :--- | :--- | | API Costs (AI Recognition) | High | Implement local caching of image hashes to avoid re-analyzing identical photos. | | Data Sync Conflicts | Medium | Use Last-Write-Wins (LWW) with vector clocks for conflict resolution. | | Platform EOL (Google Fit) | High | Strict adherence to the 2026 Health Connect SDK for all Android integrations. |
14. Implementation Tasks
Phase 1: Project Setup
- [ ] Initialize project with Expo SDK 54 and React Native 0.81
- [ ] Enable React Native New Architecture in
app.json - [ ] Configure Redux Toolkit 2.11.2 and RTK Query
- [ ] Set up Drizzle ORM with
expo-sqlite - [ ] Configure Auth0 tenant with OAuth 2.1 and PKCE
Phase 2: Core Logging Infrastructure
- [ ] Implement local-first
FoodItemschema and search index - [ ] Integrate
react-native-vision-camerafor barcode scanning - [ ] Build the Transactional Outbox for offline-to-online sync
- [ ] Set up Node.js 22 backend with TimescaleDB for log storage
Phase 3: AI & Wearables
- [ ] Implement Spike Nutrition API for photo food recognition
- [ ] Integrate
@kingstinct/react-native-healthkit(iOS) - [ ] Integrate
react-native-health-connect(Android) - [ ] Develop background sync workers using
WorkManager(Android) andObserver Queries(iOS)
Phase 4: Data Visualization (The "Pro" Experience)
- [ ] Build daily goal rings with
react-native-skia - [ ] Implement weekly nutrient trend charts using
victory-nativeXL - [ ] Add GPU-accelerated transitions for dashboard view switches
- [ ] Finalize HIPAA/GDPR audit logging via Auth0 Actions and CloudTrail
Phase 5: Launch & Quality Assurance
- [ ] Perform penetration testing on JWT/DPoP implementation
- [ ] Conduct 120Hz frame-rate stress test on older devices
- [ ] Sign AWS BAA and DPA for legal compliance
- [ ] Deploy to AWS Sovereign Cloud (EU) and Standard Regions (US)