CalFit - Personal Fitness & Nutrition AI Coach
A full-featured fitness and nutrition app powered by AI — personalized workouts, meal plans, calorie tracking, AI coach, food scanner, sleep/fasting/measurement tracking, accountability partners, and detailed analytics. One codebase ships to iOS, Android, and Web.
Your personal AI-powered fitness and nutrition companion
iOS, Android, Web (responsive, max-width 480px)
React Native 0.81.5 + Expo SDK 54 + TypeScript 5.9
Supabase (PostgreSQL, Auth, Realtime, Edge Functions)
NVIDIA Llama 3.1 70B (chat/workout/meal gen) + Llama 3.2 90B Vision (food scanner)
Deepgram STT + expo-speech (TTS workout cues)
AOT (aotnetworklabs@gmail.com)
Postponed (Web demo available now)
1. Overview & Architecture
CalFit is a full-featured fitness and nutrition app powered by AI. Users can generate personalized workouts and meal plans, track calories and macros, log sleep and body measurements, manage intermittent fasting, chat with an AI coach (with voice input), partner with friends for accountability, scan food with the camera, and monitor progress with detailed analytics and exportable reports.
State Management (Zustand)
| Store | Purpose |
|---|---|
| authStore | User, session, profile, onboarding status, live steps count |
| themeStore | Light/dark color scheme |
| aiCoachStore | Current AI workout, saved workouts, chat messages, loading state |
| mealPlanStore | Current AI meal plan, saved plans, loading state |
Key Services
| Service | Purpose |
|---|---|
| supabase.ts | Supabase client with cross-platform storage |
| nvidia-client.ts | All NVIDIA AI API calls |
| foodSearchService.ts | Open Food Facts API + Nigerian local food DB |
| profileService.ts | Profile CRUD, daily queries |
| notificationService.tsx | In-app notification CRUD |
| reminderService.ts | Scheduled local notifications |
| aiAnalysisService.ts | Workout trend analysis & predictions |
| imageService.ts | Camera/gallery picking, avatar upload |
| VoiceRecorderService.ts | Audio recording + Deepgram transcription |
| stepService.ts | Pedometer subscription, step data persistence |
2. Navigation Structure
The app uses React Navigation v7 with conditional stacks based on auth state.
Root Level
4 Tab Navigator + Floating Radial Menu
Home — Dashboard with stats, streaks, quick-log buttons
Calorie — Daily calorie tracking, macros, water intake
AI Coach — Generate workouts, saved plans, chat with AI
Notes — Full CRUD journal with AI integration
The center "+" button opens a radial menu with: Activity, Health, Meal Plans, Progress, Scan Food.
3. Auth Flow
CalFit uses anonymous authentication — no email, no password, no social login required. Users tap "Get Started", complete a 5-step onboarding wizard, and an anonymous Supabase session is created automatically. Sessions persist via SecureStore (native) or localStorage (web) for return visits.
4. Dashboard (HomeScreen)
Central command center showing the user's fitness status at a glance:
- Greeting header with user name, notification bell, avatar
- ComebackBanner — detects 2+ days inactivity, encourages return
- BurnoutBanner — alerts when sleep is low and activity is high
- StreakRow — weekly calendar with ring-shaped day dots
- HeroCarousel — 3 auto-scrolling slides (Calories, Macros, Stats)
- StatCards — water, steps, sleep progress
- QuickLog buttons — +Food, +Water, +Sleep, Workout
- Accountability Partners card + Streaks card
5. Workouts & Activity
48 bodyweight exercises across 8 categories (Chest, Back, Legs, Shoulders, Arms, Core, Cardio, Full Body), each with duration, calorie burn rate, difficulty, muscle groups, equipment needs, and step-by-step instructions.
QuickStart Workout Session
- Timer counts workout duration
- TTS voice cues announce exercise name, duration, countdown
- Auto-advance between exercises with 3s rest
- Animated exercise demos with countdown
- AI workout support with sets/reps/rest/form tips
- Auto-save to workout_sessions on completion
AnalysisScreen
Period selector (7d, 30d, 90d) with total sessions, calories, duration, streak tracking, weekly breakdown charts, category distribution, trend analysis, goal prediction, milestone progress, AI-generated suggestions, and PDF export.
6. AI Coach
Three-tab interface providing AI-powered fitness guidance:
Generate
Workout form: fitness level, goals, duration, equipment. AI generates a complete workout with warmup, exercises (sets/reps/rest/form tips), and cooldown. Save or regenerate. Results cached for 5 minutes.
Saved
List of previously saved AI-generated workouts with delete option.
Chat
Full conversational AI coach with message bubbles, voice mic input (Deepgram STT), suggested prompt chips, chat history persisted to Supabase. AI can inline-generate workouts from chat commands. System prompt: certified fitness coach with 15 years experience.
7. Calorie & Nutrition Tracking
Daily calorie tracking hub with hero card showing consumed vs goal, recipe suggestions based on remaining macros, macro progress bars (protein/carbs/fat), water intake with +250ml quick-add, and meal sections for Breakfast, Lunch, Dinner, Snacks.
Food Database
Search via Open Food Facts API with fallback to a built-in Nigerian local food database (25 entries: Jollof Rice, Egusi Soup, Suya, Moi Moi, etc.) and AI lookup via NVIDIA for any typed food. 7-day calorie trend chart included.
8. Meal Plans (AI-Generated)
7-step guided questionnaire covering health goal, budget, cuisine preference (Nigerian, Italian, Asian, etc.), dietary preferences, meals per day, excluded foods, and calorie target. Generates via NVIDIA AI with local Nigerian ingredient knowledge. Plans include title, description, daily calories, budget level, meals with macros, and AI notes.
9. Health Tracking
Steps — Pedometer via expo-sensors, live count in Zustand store, saved every 60s to step_logs, goal notifications.
Water Intake — Quick-add +250ml from dashboard or calorie screen, configurable daily goal, visual progress bar.
10. Intermittent Fasting
Protocol selection: 16:8, 18:6, 20:4, 24hr, 5:2. Active timer with progress ring. Logged to fasting_logs table. Accessible from the Health tab.
11. Journal (Notes)
Full CRUD journal with welcome view, rich editor (title, date, content), toolbar with "Send to AI Coach" for discussing entries, save/share/delete. Slide-out sidebar drawer for navigation. Synced to Supabase notes table.
12. Accountability Partners
Add up to 3 partners by CalFit ID. Bidirectional partner connections. Shared dashboard with side-by-side streak comparison (VS bar). Shared goals via modal. Milestone notifications at 7, 14, 21, 30, 60, 90, 100 days.
PartnerChat
Real-time messaging via Supabase Realtime subscriptions with read receipts and push notifications on new messages.
13. Progress & Analytics
Comprehensive dashboard with period selector (Week, Month, 3 Months, Year). Calorie consumed vs burned chart, workout stats, water/sleep averages, step counts, weight tracking, BMI display, body measurements comparison, recent workouts, streak count, and PDF export.
RecapScreen
Shareable recap cards with 5 design templates (Bold, Gradient, Dark, Sunrise, Minimal) and Daily/Weekly/Monthly recaps. Image export via react-native-view-shot.
14. Streaks & Milestones
Current streak with day dots, milestone badges at 3, 7, 14, 30, 60, 90, 180, 365 days with emoji celebrations, partner comparison, weekly calendar view, and daily push reminder. Streak logic: daily check-in increments, missed day resets.
15. Sleep Tracking
Log sleep hours (1–12, 0.5 increments), quality rating (1–5 with emoji), notes field, 7-day bar chart history, goal progress, average hours calculation. Stored in sleep_logs table.
16. Body Measurements
Track chest, waist, hips, arms, thighs, neck, and body fat %. Form fields with historical measurements list and trend indicators (up/down arrows). Stored in body_measurements table.
17. Food Scanner (AI Vision)
Camera capture via expo-camera or gallery pick via expo-image-picker. Sends base64 JPEG to NVIDIA Llama 3.2 90B Vision model via Supabase Edge Function proxy. Returns detected food items with calories, protein, carbs, fat, and serving size. Results shown in card UI with "Log Food" button.
18. Notifications
9 notification types: achievement, social, streak, upgrade, coach, community, goal, system, welcome. Filter by type, mark as read, mark all read, delete. Trigger functions throughout the app for workouts, streaks, food logging, water/calorie goals, coach responses, partner messages, and more.
Scheduled Reminders
Meal, water, workout, sleep, and streak reminders scheduled as daily local notifications via expo-notifications. Toggleable from Settings.
19. Settings & Profile
Profile card with name and avatar, notification preferences (toggled via SecureStore), theme toggle (light/dark), navigation items for Privacy Policy, Goals, Equipment Preferences, Download My Data, and Subscription. Account actions include Sign Out and Delete Account. Editable fields: name, username, height, weight, goal, activity level, dietary preferences, and all daily goals.
Equipment Preferences
Select available equipment for AI workout generation.
Download My Data
Export all user data as CSV or text report.
20. Subscription & Monetization
Three tiers (Starter, Pro, Premium) displayed in a subscription screen. Currently all features are free — the infrastructure, tier display, and upgrade prompts are in place and ready for App Store/Play Store IAP deployment.
21. Data Flow & Services
AI API Flow
3 retries with exponential backoff (1s, 2s, 4s). Usage logged to ai_api_usage table. Hardcoded fallbacks if NVIDIA is unavailable.
Voice Transcription Flow
Step Tracking Flow
Pedometer sensor → expo-sensors → Zustand authStore.liveSteps → All screens → Saved to step_logs every 60s.
22. Supabase Database Schema
| Table | Key Columns | Purpose |
|---|---|---|
| profiles | id, calfit_id, full_name, goal, height_cm, weight_kg, daily_calorie_goal, step_goal, water_goal, sleep_goal, streak_count, last_active_date, avatar_url | User profile and settings |
| food_logs | id, user_id, food_name, calories, protein, carbs, fat, meal_type, logged_at | Daily meal entries |
| water_logs | id, user_id, amount_ml, logged_at | Water intake records |
| workout_sessions | id, user_id, name, status, calories_burned, duration_seconds, exercises, completed_at | Completed workout sessions |
| workout_routines | id, user_id, name, exercises, created_at | Saved custom routines |
| step_logs | id, user_id, steps, date | Daily step counts |
| sleep_logs | id, user_id, hours, quality, notes, date | Sleep duration and quality |
| fasting_logs | id, user_id, protocol, fast_hours, eating_hours, started_at, ended_at | Fasting sessions |
| notifications | id, user_id, type, title, body, read, created_at | In-app notification inbox |
| ai_generated_workouts | id, user_id, title, duration, difficulty, exercises, warmup, cooldown | Saved AI workouts |
| ai_generated_meal_plans | id, user_id, title, daily_calories, meals, budget_level | Saved AI meal plans |
| chat_messages | id, user_id, role, content, created_at | AI Coach chat history |
| partner_messages | id, sender_id, receiver_id, content, created_at, read | Accountability chat |
| partners | id, user_id, partner_id, status | Partner relationships |
| notes | id, user_id, title, content, created_at | Journal entries |
| body_measurements | id, user_id, chest, waist, hips, arms, thighs, neck, body_fat, measured_at | Body measurement history |
| ai_api_usage | id, user_id, endpoint, model, tokens, latency, status | AI API usage logging |
Edge Functions
ai-proxy — Proxies NVIDIA AI calls (Llama 3.1 70B for chat/workout/meal gen, Llama 3.2 90B Vision for food scanning).
deepgram-proxy — Proxies audio transcription to Deepgram API.
23. Theming & Design System
Color Palette
Primary: CalFit Green (#0DAE6C / #34D98A) — CTAs, active nav, coach buttons.
Backgrounds: Light lavender (#F4F0FF), Dark indigo (#08061A)
Gradients: Pink → Orange → Yellow for scan food banner, streak badges, primary CTAs.
Macro colors: Protein (orange #FF6B35), Carbs (yellow #FFB830), Fat (blue #4A90E2)
Typography
Plus Jakarta Sans (Google Fonts) — 7 weights available. App uses 900 (black), 800 (extrabold), 700 (bold), 600 (semibold).
Responsive Design
Web version centered in max-width 480px container (phone-like layout). Adaptive font sizing via moderateScale() based on 390px base width.
Light/Dark Mode
Toggle persisted in Zustand (default: light). Full separate color definitions with glass effect overlays and adaptive StatusBar.