How aditya290605/fitness-geni works
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: supabase_service.dart Supabase core · auth_service.dart Auth core · main_navigation.dart Main nav · main.dart Main
Components 22
App shell
Core infrastructure
- Auth core · Central session state, auth services, and route redirect logic.
fitness_geni/lib/core/auth/auth_service.dart - Supabase core · Supabase connection, configuration, and persistence access.
fitness_geni/lib/core/supabase/supabase_service.dart - Gemini · AI meal generation integration.
fitness_geni/lib/core/services/gemini_service.dart - Health data · Health Connect / Apple Health integration for activity metrics.
fitness_geni/lib/core/services/health_fitness_service.dart - Meal services · Meal generation, catalog, and notifications orchestration.
fitness_geni/lib/core/services/meal_service.dart - History service · Loads historical daily summaries for stats views.
fitness_geni/lib/core/services/stats_history_service.dart - Theme UI · Shared colors, typography, and reusable widgets.
fitness_geni/lib/core/theme/app_theme.dart
Features
- Splash · Initial launch screen while session and route state resolve.
fitness_geni/lib/features/splash/presentation/screens/splash_screen.dart - Auth UI · User-facing authentication flows.
fitness_geni/lib/features/auth/presentation/screens/login_screen.dart - Onboarding · Stepwise capture of user inputs for personalization.
fitness_geni/lib/features/onboarding/presentation/screens/onboarding_screen.dart - Home · Main post-login meal and progress dashboard.
fitness_geni/lib/features/home/presentation/screens/home_screen.dart - Fit · Health and activity tracking dashboard.
fitness_geni/lib/features/fit/presentation/screens/fit_screen.dart - Stats · Historical nutrition and activity summaries.
fitness_geni/lib/features/stats/presentation/screens/stats_screen.dart - Profile · Identity, BMI, and daily needs overview.
fitness_geni/lib/features/profile/presentation/screens/profile_screen.dart - Meal state · Provider layer for meal creation, selection, and catalog state.
fitness_geni/lib/features/home/presentation/providers/meal_provider.dart - Profile model · Structured user profile captured during setup.
fitness_geni/lib/features/onboarding/data/models/user_profile_model.dart - Profile state · Profile UI state and computed health summary data.
fitness_geni/lib/features/profile/presentation/providers/profile_provider.dart - Stats state · Analytics state for charts and historical summaries.
fitness_geni/lib/features/stats/presentation/providers/stats_provider.dart
Backend & tooling
- Migrations · Backend schema, policies, and nutrition tracking functions.
supabase/migrations/create_meals_table.sql - Image gen · Node-based content pipeline for meal image preparation.
image_generator/generate-images.js
Connections 28
- 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.