# aditya290605/fitness-geni architecture

> Architecture diagram of the GitHub repository aditya290605/fitness-geni, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aditya290605/fitness-geni
- Repository: https://github.com/aditya290605/fitness-geni

## Overview

1. **Repository shape**
   - This is a **Flutter mobile app** called *Fitness Geni*, with iOS and Android host projects generated around a single Dart application in `lib/`.
   - The runtime app is almost entirely in Flutter; native code is thin and mostly the default platform bootstrap (`MainActivity.kt`, `AppDelegate.swift`).

2. **Top-level architecture**
   - The app follows a **feature-first clean architecture** style.
   - `lib/core` holds shared infrastructure and cross-cutting concerns.
   - `lib/features/*` contains user-facing product areas, each with its own screens, providers, models, and feature-specific services.
   - `lib/shared` contains cross-feature UI/navigation components.

3. **App entry and shell**
   - `lib/main.dart` is the application entry point.
   - The app shell likely wires together theme, Supabase initialization, Riverpod state, and routing.
   - `lib/shared/presentation/main_navigation.dart` suggests a shared bottom/tab navigation shell that hosts the main post-login areas.

4. **Identity and session boundary**
   - Authentication is centralized under `lib/core/auth`.
   - `auth_service.dart`, `session_manager.dart`, `auth_state.dart`, and `auth_provider.dart` indicate a single session source of truth exposed to the UI through Riverpod.
   - `auth_redirect.dart` implies route guarding/redirect logic based on auth and onboarding completion.
   - Supabase Auth is the backend identity provider, with profile/session state bridged into the app via `profile_service.dart` and `profile_adapter.dart`.

5. **Backend and persistence**
   - `lib/core/supabase` is the main backend integration layer.
   - `supabase_client.dart`, `supabase_config.dart`, and `supabase_service.dart` wrap environment-based connection setup and network/data access.
   - The `supabase/migrations` folder defines the backend schema and business rules for:
     - meals
     - daily plans
     - profile nutrition targets
     - nutrition tracking functions/policies
   - This makes Supabase the primary persistence and authorization boundary for app data.

6. **AI and meal generation flow**
   - `lib/core/services/gemini_service.dart` is the AI integration point for Google Gemini.
   - Meal-related services (`meal_service.dart`, `meal_catalog_service.dart`, `meal_notification_service.dart`) suggest the AI-generated meal flow is a core product loop.
   - The user-facing path is: input preferences/ingredients → generate meals via Gemini → review/preview meals → persist selected meals and nutrition data in Supabase.

7. **Nutrition and plan domain**
   - The home feature contains the meal domain models: `meal.dart` and `catalog_meal.dart`.
   - `nutrition_calculator.dart` and `meal_catalog_provider.dart` indicate the app computes nutrition goals and aggregates meal data locally before syncing or displaying.
   - `meal_creation_provider.dart` and `meal_provider.dart` appear to orchestrate meal creation, loading, preview, and final selection states.

8. **Onboarding and profile data flow**
   - Onboarding is split into stepwise screens for gender, age, height, weight, diet type, and fitness goal.
   - `features/onboarding/data/models/user_profile_model.dart` plus `onboarding_service.dart` show onboarding data is captured as a structured profile payload.
   - That profile feeds into `features/profile/domain/models/user_profile.dart` and the profile UI, making onboarding the source of user personalization for calorie targets and recommendations.

9. **Fitness tracking subsystem**
   - `features/fit` is the activity/health tracking area.
   - `fitness_provider.dart` and `perfect_days_provider.dart` wrap the state for activity metrics and streak-style progress.
   - Services in `lib/core/services/health_fitness_service.dart` and `fitness_service.dart` indicate integration with **Health Connect / Apple Health** for steps, calories, and distance.
   - The fit UI is built from charts, heatmaps, and progress cards, so this subsystem is mostly a read/aggregate/display pipeline over device health data plus stored history.

10. **Statistics and history**
   - `features/stats` is a separate analytics view built around historical tracking.
   - `daily_history_model.dart`, `stats_provider.dart`, and `overview_chart.dart` indicate the app stores and renders time-series nutrition/activity history.
   - `stats_history_service.dart` in core likely connects this view to persisted daily summaries in Supabase.

11. **Home dashboard**
   - `features/home/presentation/screens/home_screen.dart` is the main post-onboarding experience.
   - It combines daily progress, meal cards, nutrition statistics, and meal detail sheets.
   - This screen likely consumes several providers at once: meal state, catalog selection, nutrition aggregation, and possibly notifications or generated-plan state.

12. **Profile and user-facing health summary**
   - `features/profile` presents identity, BMI, daily needs, and goal cards.
   - The `bmi_gauge_painter.dart` and related widgets show that profile is not just editable metadata; it is a computed health summary derived from onboarding inputs and nutrition calculations.

13. **Core UI and design system**
   - `lib/core/theme` defines the app’s visual system: colors, typography, and theme composition.
   - `lib/core/widgets` holds reusable UI primitives such as buttons, text fields, selection cards, gradients, and the animated logo.
   - This keeps feature screens visually consistent and prevents duplicated component logic.

14. **Assets and supporting toolchain**
   - `assets/animations` and `assets/logo` support branded, animated onboarding/splash experiences.
   - The `image_generator/` directory is a separate Node-based support tool for generating meal images and maintaining image metadata; it is not part of the mobile runtime but supports content preparation.
   - `frontend_design/skills.md` and the resolved planning docs suggest some product/spec artifacts are kept in-repo alongside code.

15. **End-to-end data flow**
   - The main runtime flow is: app launch → auth/session check → onboarding if profile is incomplete → main navigation shell → home/fit/stats/profile views.
   - Data enters from three main places: user input, Supabase, and device health APIs.
   - Data leaves through Supabase writes, AI requests to Gemini, and local/native health permission access.
   - Riverpod providers sit in the middle as the state boundary between services and UI.

16. **What to draw in an architecture diagram**
   - Show the Flutter app as the central client.
   - Split it into feature modules: auth, onboarding, home, fit, stats, profile, splash.
   - Add core infrastructure around them: Supabase, Gemini, health-device integration, theming/utilities, and shared navigation.
   - Include Supabase migrations as the backend schema/authorization layer and `image_generator` as an offline content pipeline, not a runtime component.

Main entry points: [`fitness_geni/lib/core/supabase/supabase_service.dart`](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/supabase/supabase_service.dart) (Supabase core), [`fitness_geni/lib/core/auth/auth_service.dart`](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/auth/auth_service.dart) (Auth core), [`fitness_geni/lib/shared/presentation/main_navigation.dart`](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/shared/presentation/main_navigation.dart) (Main nav), [`fitness_geni/lib/main.dart`](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/main.dart) (Main)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_main["Main<br/>flutter entry<br/>[main.dart]"]
  node_nav["Main nav<br/>shell navigation"]
end

subgraph group_core["Core infrastructure"]
  node_auth_core["Auth core<br/>session boundary<br/>[auth_service.dart]"]
  node_supabase_core[("Supabase core<br/>backend client layer")]
  node_gemini{{"Gemini<br/>ai service"}}
  node_health["Health data<br/>device health bridge"]
  node_meal_services["Meal services<br/>meal pipeline<br/>[meal_service.dart]"]
  node_stats_service["History service<br/>history sync"]
  node_theme_ui["Theme UI<br/>design system<br/>[app_theme.dart]"]
end

subgraph group_features["Features"]
  node_splash["Splash<br/>startup screen<br/>[splash_screen.dart]"]
  node_auth_feature["Auth UI<br/>login/signup screens<br/>[login_screen.dart]"]
  node_onboarding["Onboarding<br/>profile setup flow"]
  node_home["Home<br/>dashboard screen<br/>[home_screen.dart]"]
  node_fit["Fit<br/>activity view<br/>[fit_screen.dart]"]
  node_stats["Stats<br/>history analytics<br/>[stats_screen.dart]"]
  node_profile["Profile<br/>health summary"]
  node_home_state["Meal state<br/>home providers<br/>[meal_provider.dart]"]
  node_onboarding_data["Profile model<br/>onboarding data"]
  node_profile_state["Profile state<br/>profile providers"]
  node_stats_state["Stats state<br/>stats providers"]
end

subgraph group_backend["Backend & tooling"]
  node_migrations[("Migrations<br/>supabase schema")]
  node_image_gen{{"Image gen<br/>offline tooling<br/>[generate-images.js]"}}
end

node_main -->|"launch"| node_splash
node_main -->|"init session"| node_auth_core
node_main -->|"configure backend"| node_supabase_core
node_main -->|"apply theme"| node_theme_ui
node_splash -->|"check session"| node_auth_core
node_auth_core -->|"gate auth"| node_auth_feature
node_auth_core -->|"gate profile"| node_onboarding
node_auth_core -->|"enter shell"| node_nav
node_nav -->|"tab"| node_home
node_nav -->|"tab"| node_fit
node_nav -->|"tab"| node_stats
node_nav -->|"tab"| node_profile
node_onboarding -->|"capture"| node_onboarding_data
node_onboarding_data -->|"seed profile"| node_profile_state
node_home -->|"consume"| node_home_state
node_home_state -->|"orchestrate"| node_meal_services
node_meal_services -->|"generate"| node_gemini
node_meal_services -->|"persist meals"| node_supabase_core
node_profile_state -->|"sync profile"| node_supabase_core
node_fit -->|"read metrics"| node_health
node_fit -->|"load history"| node_supabase_core
node_stats -->|"consume"| node_stats_state
node_stats_state -->|"load history"| node_stats_service
node_stats_service -->|"query data"| node_supabase_core
node_auth_core -->|"identity sync"| node_supabase_core
node_supabase_core -.->|"schema"| node_migrations
node_meal_services -.->|"nutrition data"| node_migrations
node_image_gen -.->|"content prep"| node_home

click node_main "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/main.dart"
click node_splash "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/splash/presentation/screens/splash_screen.dart"
click node_auth_feature "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/auth/presentation/screens/login_screen.dart"
click node_onboarding "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/onboarding/presentation/screens/onboarding_screen.dart"
click node_home "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/home/presentation/screens/home_screen.dart"
click node_fit "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/fit/presentation/screens/fit_screen.dart"
click node_stats "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/stats/presentation/screens/stats_screen.dart"
click node_profile "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/profile/presentation/screens/profile_screen.dart"
click node_nav "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/shared/presentation/main_navigation.dart"
click node_auth_core "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/auth/auth_service.dart"
click node_supabase_core "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/supabase/supabase_service.dart"
click node_gemini "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/gemini_service.dart"
click node_health "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/health_fitness_service.dart"
click node_meal_services "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/meal_service.dart"
click node_stats_service "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/stats_history_service.dart"
click node_theme_ui "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/theme/app_theme.dart"
click node_home_state "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/home/presentation/providers/meal_provider.dart"
click node_onboarding_data "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/onboarding/data/models/user_profile_model.dart"
click node_profile_state "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/profile/presentation/providers/profile_provider.dart"
click node_stats_state "https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/stats/presentation/providers/stats_provider.dart"
click node_migrations "https://github.com/aditya290605/fitness-geni/blob/main/supabase/migrations/create_meals_table.sql"
click node_image_gen "https://github.com/aditya290605/fitness-geni/blob/main/image_generator/generate-images.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_nav toneBlue
class node_auth_core,node_supabase_core,node_gemini,node_health,node_meal_services,node_stats_service,node_theme_ui toneAmber
class node_splash,node_auth_feature,node_onboarding,node_home,node_fit,node_stats,node_profile,node_home_state,node_onboarding_data,node_profile_state,node_stats_state toneMint
class node_migrations,node_image_gen toneRose
```

## Components

### App shell

- [Main](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/main.dart): flutter entry · App bootstrap and startup wiring. · `fitness_geni/lib/main.dart`
- [Main nav](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/shared/presentation/main_navigation.dart): shell navigation · Shared bottom/tab navigation across primary app areas. · `fitness_geni/lib/shared/presentation/main_navigation.dart`

### Core infrastructure

- [Auth core](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/auth/auth_service.dart): session boundary · Central session state, auth services, and route redirect logic. · `fitness_geni/lib/core/auth/auth_service.dart`
- [Supabase core](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/supabase/supabase_service.dart): backend client layer · Supabase connection, configuration, and persistence access. · `fitness_geni/lib/core/supabase/supabase_service.dart`
- [Gemini](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/gemini_service.dart): ai service · AI meal generation integration. · `fitness_geni/lib/core/services/gemini_service.dart`
- [Health data](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/health_fitness_service.dart): device health bridge · Health Connect / Apple Health integration for activity metrics. · `fitness_geni/lib/core/services/health_fitness_service.dart`
- [Meal services](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/meal_service.dart): meal pipeline · Meal generation, catalog, and notifications orchestration. · `fitness_geni/lib/core/services/meal_service.dart`
- [History service](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/services/stats_history_service.dart): history sync · Loads historical daily summaries for stats views. · `fitness_geni/lib/core/services/stats_history_service.dart`
- [Theme UI](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/core/theme/app_theme.dart): design system · Shared colors, typography, and reusable widgets. · `fitness_geni/lib/core/theme/app_theme.dart`

### Features

- [Splash](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/splash/presentation/screens/splash_screen.dart): startup screen · Initial launch screen while session and route state resolve. · `fitness_geni/lib/features/splash/presentation/screens/splash_screen.dart`
- [Auth UI](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/auth/presentation/screens/login_screen.dart): login/signup screens · User-facing authentication flows. · `fitness_geni/lib/features/auth/presentation/screens/login_screen.dart`
- [Onboarding](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/onboarding/presentation/screens/onboarding_screen.dart): profile setup flow · Stepwise capture of user inputs for personalization. · `fitness_geni/lib/features/onboarding/presentation/screens/onboarding_screen.dart`
- [Home](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/home/presentation/screens/home_screen.dart): dashboard screen · Main post-login meal and progress dashboard. · `fitness_geni/lib/features/home/presentation/screens/home_screen.dart`
- [Fit](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/fit/presentation/screens/fit_screen.dart): activity view · Health and activity tracking dashboard. · `fitness_geni/lib/features/fit/presentation/screens/fit_screen.dart`
- [Stats](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/stats/presentation/screens/stats_screen.dart): history analytics · Historical nutrition and activity summaries. · `fitness_geni/lib/features/stats/presentation/screens/stats_screen.dart`
- [Profile](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/profile/presentation/screens/profile_screen.dart): health summary · Identity, BMI, and daily needs overview. · `fitness_geni/lib/features/profile/presentation/screens/profile_screen.dart`
- [Meal state](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/home/presentation/providers/meal_provider.dart): home providers · Provider layer for meal creation, selection, and catalog state. · `fitness_geni/lib/features/home/presentation/providers/meal_provider.dart`
- [Profile model](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/onboarding/data/models/user_profile_model.dart): onboarding data · Structured user profile captured during setup. · `fitness_geni/lib/features/onboarding/data/models/user_profile_model.dart`
- [Profile state](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/profile/presentation/providers/profile_provider.dart): profile providers · Profile UI state and computed health summary data. · `fitness_geni/lib/features/profile/presentation/providers/profile_provider.dart`
- [Stats state](https://github.com/aditya290605/fitness-geni/blob/main/fitness_geni/lib/features/stats/presentation/providers/stats_provider.dart): stats providers · Analytics state for charts and historical summaries. · `fitness_geni/lib/features/stats/presentation/providers/stats_provider.dart`

### Backend & tooling

- [Migrations](https://github.com/aditya290605/fitness-geni/blob/main/supabase/migrations/create_meals_table.sql): supabase schema · Backend schema, policies, and nutrition tracking functions. · `supabase/migrations/create_meals_table.sql`
- [Image gen](https://github.com/aditya290605/fitness-geni/blob/main/image_generator/generate-images.js): offline tooling · Node-based content pipeline for meal image preparation. · `image_generator/generate-images.js`

## Connections

- Main → Splash: launch · App starts on the splash screen.
- Main → Auth core: init session · Bootstraps auth/session state and redirect rules.
- Main → Supabase core: configure backend · Initializes Supabase client and environment config.
- Main → Theme UI: apply theme · Sets global visual system and reusable UI primitives.
- Splash → Auth core: check session · Resolves whether the user is signed in and onboarded.
- Auth core → Auth UI: gate auth · Routes users into login and signup flows when needed.
- Auth core → Onboarding: gate profile · Sends incomplete profiles into the setup flow.
- Auth core → Main nav: enter shell · Allows access to the main app shell after session checks.
- Main nav → Home: tab · Primary dashboard destination.
- Main nav → Fit: tab · Activity and health tracking destination.
- Main nav → Stats: tab · History and analytics destination.
- Main nav → Profile: tab · Profile and health summary destination.
- Onboarding → Profile model: capture · Collects structured personalization inputs.
- Profile model → Profile state: seed profile · Feeds the profile domain and computed health summary.
- Home → Meal state: consume · Home dashboard reads meal and catalog state.
- Meal state → Meal services: orchestrate · Drives meal generation, preview, and selection.
- Meal services → Gemini: generate · Uses AI to create meal plans and suggestions.
- Meal services → Supabase core: persist meals · Stores selected meals and nutrition data.
- Profile state → Supabase core: sync profile · Reads and writes profile and target data.
- Fit → Health data: read metrics · Aggregates device health and activity data.
- Fit → Supabase core: load history · Fetches stored activity summaries and progress.
- Stats → Stats state: consume · Stats screen reads analytics state.
- Stats state → History service: load history · Pulls historical daily summaries for charts.
- History service → Supabase core: query data · Reads persisted tracking and summary records.
- Auth core → Supabase core: identity sync · Bridges Supabase Auth with local session state.
- Supabase core → Migrations: schema · Backend schema defines persistence and policy boundaries.
- Meal services → Migrations: nutrition data · Meal writes align with tracked nutrition tables and functions.
- Image gen → Home: content prep · Supports offline meal image/content assets used by the app.
