How rbarbieri13/fuelwell works
Purpose and entry points
FuelWell is a health, nutrition, fitness, and AI-coaching product with two clients sharing Supabase-backed product concepts: a Next.js web application and a native SwiftUI iOS app. The generic root README is not representative of the repository’s product scope.
Web routing starts at src/app/layout.tsx, with authenticated product surfaces under src/app/app/layout.tsx and public/auth route groups under src/app/(marketing)/page.tsx and src/app/(auth)/login/page.tsx. iOS starts at ios/FuelWellApp/Sources/FuelWellApp.swift, composed through ios/Features/App/Sources/App/AppCoordinator.swift.
Web application shell and product surfaces
The web client uses the Next.js App Router with server routes and interactive client components. It organizes user workflows around dashboard, food logging, daily review, meal plans/recipes/groceries, workouts, profile/settings, and a conversational coach. Shared responsive navigation is centralized in src/components/layout/sidebar.tsx, src/components/layout/mobile-nav.tsx, and the authenticated layout.
The primary interactive pages are route-level boundaries; their client components and feature-specific UI call hooks/repositories rather than directly owning persistence. Examples: src/app/app/dashboard/dashboard-client.tsx, src/app/app/log/page.tsx, and src/app/app/workouts/[id]/live/page.tsx.
Coach engine: request, policy, tools, and artifacts
The coach is an API-mediated agent system. A user turn reaches src/app/api/coach/turn/route.ts, which coordinates provider access, system prompt/context, intent/tool execution, mutation application, auditing, and response persistence. The core integration boundary is src/lib/coach/provider-client.ts; prompt/policy composition lives in src/lib/coach/system-prompt.ts and src/lib/coach/voice-filter.ts.
Tools are grouped by product domain in src/lib/coach/tools/index.ts, src/lib/coach/tools/meal-tools.ts, and src/lib/coach/tools/workout-tools.ts. Mutations are applied through src/lib/coach/apply-mutation.ts, separating agent-proposed actions from persisted effects. Structured results are rendered in the chat UI through src/components/coach/artifacts/index.tsx and its artifact contract, rather than requiring prose-only responses.
Health-data domain and persistence flow
Nutrition, body, workout, and grocery actions flow from pages/hooks to API routes and repository modules, then to Supabase when configured. Core web repositories include src/lib/day-log-repository.ts, src/lib/body-log-repository.ts, and src/lib/workout-log-repository.ts; endpoint boundaries include src/app/api/day-log/route.ts, src/app/api/body-log/route.ts, and src/app/api/workout-log/route.ts.
Food acquisition has distinct barcode, image-estimation, and restaurant paths at src/app/api/food/barcode/route.ts, src/app/api/food/photo-estimate/route.ts, and src/app/api/restaurants/nearby/route.ts. Meal and workout logging therefore feed both deterministic tracking views and coach context.
Supabase, identity, and data boundaries
Supabase provides authentication/session handling and product persistence. Web client/server adapters are separated in src/lib/supabase/client.ts, src/lib/supabase/server.ts, and src/lib/supabase/middleware.ts; the auth callback is src/app/(auth)/callback/route.ts. Schema evolution is maintained as SQL migrations, including coach, profile-preference, uploaded-artifact, fitness/grocery, and body-log data in supabase/migrations/20260611180100_coach_tables.sql, supabase/migrations/20260612120000_profiles_preferences_jsonb.sql, and supabase/migrations/20260712200713_fitness_grocery_foundation.sql.
Native iOS architecture
The iOS application is SwiftUI with feature packages and reusable domain/service packages. App-level routing and tabs live in ios/Features/App/Sources/App/AppFeature.swift and ios/Features/App/Sources/App/RootTabView.swift; nutrition workflows are encapsulated in ios/Features/Nutrition/Sources/Nutrition/DailyLogFeature.swift and ios/Features/Nutrition/Sources/Nutrition/AddMealSheet.swift.
Domain calculations are isolated in ios/Packages/NutritionDomain/Sources/NutritionDomain/MacroDecisionEngine.swift. Networking, persistence, HealthKit, Supabase feature flags, subscriptions, analytics, crash reporting, and an Anthropic client are explicit package boundaries under ios/Packages/Networking/Sources/Networking/APIClient.swift, ios/Packages/HealthKitClient/Sources/HealthKitClient/HealthKitClient.swift, and ios/Packages/SupabaseClient/Sources/SupabaseClient/SupabaseClient.swift.
Runtime and delivery
The web runtime is TypeScript/React on Next.js, deployable to Vercel and also containerized via Dockerfile with Fly configuration in fly.toml. CI includes web deployment and iOS/TestFlight workflows in .github/workflows/deploy.yml and .github/workflows/ios-testflight.yml. iOS release automation is Fastlane-based at ios/fastlane/Fastfile, with Supabase migration/operational scripts under tools/supabase/.
Main entry points: dashboard-client.tsx Product workflows · route.ts Coach turn API · day-log-repository.ts Health repositories · DailyLogFeature.swift Nutrition workflows
Components 21
Next.js web
- Web route entry · Root, marketing, and login route groups.
src/app/layout.tsx - Authenticated shell · Shared app layout, sidebar, and mobile navigation.
src/app/app/layout.tsx - Product workflows · Dashboard, logging, review, meals, workouts, profile, and chat.
src/app/app/dashboard/dashboard-client.tsx - Coach artifacts · Renders structured coach results.
src/components/coach/artifacts/index.tsx
Coach engine
- Coach turn API · Coordinates context, execution, auditing, and response persistence.
src/app/api/coach/turn/route.ts - Prompt & policy · System context and voice filtering.
src/lib/coach/system-prompt.ts - AI provider client
src/lib/coach/provider-client.ts - Domain tools · Meal and workout tool registry.
src/lib/coach/tools/index.ts - Mutation applier · Applies approved agent-proposed changes.
src/lib/coach/apply-mutation.ts
Supabase & APIs
- Health logging APIs · Day, body, and workout endpoint boundaries.
src/app/api/day-log/route.ts - Food acquisition APIs · Barcode, photo estimation, and nearby restaurants.
src/app/api/food/barcode/route.ts - Health repositories · Day, body, and workout log repositories.
src/lib/day-log-repository.ts - Supabase adapters · Separated browser, server, and middleware adapters.
src/lib/supabase/server.ts - Supabase backend · Shared identity and product persistence.
- Database migrations · Coach, preferences, fitness, grocery, and body-log schema.
supabase/migrations/20260712200713_fitness_grocery_foundation.sql
iOS SwiftUI
- iOS app composition · Application entry and coordinator.
ios/FuelWellApp/Sources/FuelWellApp.swift - App routing & tabs · Root feature and tab navigation.
ios/Features/App/Sources/App/AppFeature.swift - Nutrition workflows · Daily log and add-meal flows.
ios/Features/Nutrition/Sources/Nutrition/DailyLogFeature.swift - Nutrition domain · Macro decision engine.
ios/Packages/NutritionDomain/Sources/NutritionDomain/MacroDecisionEngine.swift - Native service clients · Networking, HealthKit, and Supabase access.
ios/Packages/Networking/Sources/Networking/APIClient.swift
Delivery
- Build & release automation · Vercel/Fly web deployment and TestFlight release workflows.
.github/workflows/deploy.yml
Connections 23
- Web route entry → Authenticated shell: authenticated routes
- Authenticated shell → Product workflows: hosts
- Product workflows → Coach artifacts: chat results
- Coach artifacts → Coach turn API: user turn
- Product workflows → Health logging APIs: logs health data
- Product workflows → Food acquisition APIs: acquires food data
- Coach turn API → Prompt & policy: builds context
- Coach turn API → AI provider client: requests generation
- Coach turn API → Domain tools: selects tools
- Domain tools → Mutation applier: proposed actions
- Mutation applier → Health repositories: persists effects
- Health logging APIs → Health repositories: uses
- Food acquisition APIs → Health repositories: feeds tracking
- Health repositories → Supabase adapters: accesses through
- Supabase adapters → Supabase backend: auth & data
- Database migrations → Supabase backend: evolves schema
- iOS app composition → App routing & tabs: composes
- App routing & tabs → Nutrition workflows: routes to
- Nutrition workflows → Nutrition domain: calculates macros
- Nutrition workflows → Native service clients: uses
- Native service clients → Supabase backend: shared backend
- Build & release automation → Web route entry: deploys web
- Build & release automation → iOS app composition: releases iOS