Nutri-E Architecture¶
Nutri-E is a supplement tracking app built with SwiftUI (iOS) and Jetpack Compose (Android). It provides intelligent supplement management, dose tracking, nutrient analysis, and AI-powered food analysis.
Tech Stack¶
| Platform | Technology |
|---|---|
| iOS | SwiftUI, Core Data, StoreKit 2, iOS 16+ |
| Android | Jetpack Compose, Room, Kotlin |
| Backend | Cloudflare Workers (3 workers) |
| AI | GPT-4 Vision via Cloudflare Worker proxy |
Architecture Pattern¶
MVVM with a Service Layer:
flowchart TB
subgraph ios["iOS App"]
views["SwiftUI Views<br/>(TodayView, SupplementsView, etc.)"]
services["Services<br/>(SupplementService, OpenAIService, etc.)"]
coredata["Core Data<br/>(Local persistence)"]
models["Models<br/>(UnitType, Frequency)"]
end
subgraph backend["Cloudflare Workers"]
openai["OpenAI Worker<br/>(GPT-4 Vision proxy)"]
dsld["DSLD Worker<br/>(NIH supplement DB)"]
apple["Apple Webhook Worker<br/>(Subscription lifecycle)"]
end
views --> services
services --> coredata
services --> models
services --> openai
services --> dsld
coredata --> models
| Layer | Implementation | Responsibility |
|---|---|---|
| Views | SwiftUI Views | UI rendering, user input |
| Services | Singletons (.shared) |
Business logic, API calls |
| Persistence | Core Data | Local storage |
| Models | Core Data entities, enums | Data structures |
Project Structure¶
ios/Nutri-E/Nutri-E/
├── Nutri_EApp.swift # App entry point
├── ContentView.swift # 5-tab navigation hub
├── Persistence.swift # Core Data stack
├── Nutri_E.xcdatamodeld/ # Core Data models
├── Models/
│ ├── UnitType.swift # Unit system
│ └── Frequency.swift # Dose frequencies
├── Services/
│ ├── SupplementService.swift # Core supplement operations
│ ├── DSLDSearchService.swift # NIH database integration
│ ├── OpenAIService.swift # GPT-4 Vision analysis
│ ├── DeviceAuthService.swift # API security
│ └── StoreKitManager.swift # In-app purchases
└── Views/
├── TodayView.swift # Daily dashboard
├── SupplementsView.swift # Supplement list
├── ScheduleManagementView.swift
├── NutrientsView.swift # Nutrient tracking
├── MoreView.swift # Settings
└── FoodView.swift # AI food analysis
Platform Strategy¶
iOS is the master platform:
- All new features are implemented on iOS first
- iOS serves as the reference for functionality, UX, and business logic
- After iOS testing, features are ported to Android
- Feature parity is maintained between platforms
Backend Workers¶
| Worker | Purpose | Production URL |
|---|---|---|
| OpenAI | GPT-4 Vision for food/supplement analysis | nutrie-openai-worker-v2.invotekas.workers.dev |
| DSLD | NIH supplement database proxy | nutrie-dsld-worker-v2.invotekas.workers.dev |
| Apple Webhook | App Store subscription lifecycle | nutrie-apple-webhook-worker-v2.invotekas.workers.dev |
All workers support multi-environment deployment (production + sandbox) and use device authentication (HMAC-SHA256).
Brand Mascots¶
| Character | Color | Role |
|---|---|---|
| Nutri-E | Purple | Health Expert -- nutrition guide |
| Cuti-E | Pink | Support Specialist -- user engagement |
| Codi-E | Teal | Tech Wizard -- AI features |
Design Principles¶
- Card-based UI with consistent spacing and corner radius
- Explicit UI -- all functionality through visible controls, no hidden gestures
- Offline-First -- Core Data for local persistence, works without network
- KISS -- minimal abstraction, direct Core Data access via
@FetchRequest