How sathish-create/fitcoachai_app works
1. System Purpose and Entry Points
FitCoach AI is a cross-platform Flutter fitness-coaching client backed by a Python/FastAPI service. Its central workflow combines on-device pose capture, server-side form analysis, AI coach/diet requests, and Supabase-backed identity/data.
• Mobile bootstrap, dependency initialization, and routing: mobile/lib/main.dart
• Backend HTTP application and endpoint host: backend/main.py
• Combined local launcher: run_all.bat
2. Mobile Application Shell
The Flutter client is the primary user-facing runtime, targeting Android, iOS, desktop, and partial web support. It uses feature-oriented presentation folders, with shared navigation/layout and core services separating UI from external integrations.
• Persistent app layout/navigation boundary: mobile/lib/shared/widgets/main_layout.dart
• App-wide HTTP endpoint configuration: mobile/lib/core/network/api_constants.dart
• Native Android host entry: mobile/android/app/src/main/kotlin/com/gymai/fitcoach/MainActivity.kt
Control flow begins in the app bootstrap, routes users through landing/auth/setup, then presents dashboard and feature screens. Authentication state is managed separately from screens and controls protected versus guest access.
• Authentication state provider: mobile/lib/features/auth/presentation/providers/auth_provider.dart
• Login boundary: mobile/lib/features/auth/presentation/screens/login_screen.dart
• Setup/onboarding flow: mobile/lib/features/setup/presentation/screens/setup_screen.dart
3. Workout and Hybrid Pose-Analysis Pipeline
The workout feature is the core real-time interaction boundary. The mobile client captures camera-based MediaPipe pose landmarks for low-latency feedback, while the backend receives landmarks for exercise validation and rep/form analysis using the same general pose domain.
• Live workout UI and camera/pose integration: mobile/lib/features/workout/presentation/screens/workout_screen.dart
• Warmup and workout completion stages: mobile/lib/features/workout/presentation/screens/warmup_screen.dart, mobile/lib/features/workout/presentation/screens/workout_summary_screen.dart
• Backend request handling: backend/main.py
Backend pose processing is organized as an analyzer plus exercise-family rules. This makes the analyzer responsible for dispatching/common landmark interpretation and rule modules responsible for movement-specific conditions.
• Analysis coordinator: backend/engine/analyzer.py
• Rule abstraction/base: backend/engine/rules/abs.py, backend/engine/rules/base.py
• Representative body-part rule modules: backend/engine/rules/chest.py, backend/engine/rules/legs.py, backend/engine/rules/full_body.py
The packaged MediaPipe task is a deployment dependency of the backend, not a remote ML service.
• Pose model asset: backend/pose_landmarker.task
4. AI Coach and Remote API Boundary
The mobile API service is the client-side boundary for FastAPI calls, including coach chat, diet generation, pose-landmark processing, session reset, and health checks. The backend in turn uses Google Gemini for natural-language coaching and diet-generation behavior, with credentials supplied outside source control.
• HTTP service: mobile/lib/core/services/api_service.dart
• AI/chat interface surfaces: mobile/lib/features/coach/presentation/screens/coach_screen.dart, mobile/lib/features/coach/presentation/widgets/coach_chat_widget.dart
• Backend API/Gemini integration point: backend/main.py
Relevant runtime configuration/dependencies are captured in:
• Backend environment template: backend/.env.template
• Python service/ML dependencies: backend/requirements.txt
5. Identity, Persistence, and Device Services
Supabase is the external authentication and PostgreSQL/data boundary, supporting email/password and Google sign-in flows. Local preferences, notifications, speech, and exercise catalog loading remain client-side service concerns.
• Supabase integration: mobile/lib/core/services/supabase_service.dart
• Local persistence: mobile/lib/core/services/storage_service.dart
• Voice input/output: mobile/lib/core/services/voice_service.dart
Exercise browsing and workout selection consume a bundled asset catalog rather than requiring the backend.
• Catalog loader: mobile/lib/core/services/exercise_data_service.dart
• Exercise data: mobile/assets/exercises.json
• Library/exercise entry screens: mobile/lib/features/library/presentation/screens/library_screen.dart, mobile/lib/features/exercises/presentation/screens/exercises_screen.dart
6. Supporting Fitness Experiences and External Integrations
Feature screens compose the wider coaching journey: dashboard/steps tracking, workout schedules, calculators/diet planning, profile settings, and nearby gym discovery. Gym discovery depends on device location plus TomTom APIs; step tracking depends on device sensors; notifications are local-device scheduling.
• Dashboard and steps: mobile/lib/features/dashboard/presentation/screens/dashboard_screen.dart, mobile/lib/features/dashboard/presentation/screens/steps_screen.dart
• Planning and calculators: mobile/lib/features/schedules/presentation/screens/schedules_screen.dart, mobile/lib/features/calculators/presentation/screens/calculators_screen.dart
• Gym discovery: mobile/lib/features/gyms/presentation/screens/gyms_screen.dart
• Notification service/state: mobile/lib/core/services/notification_service.dart, mobile/lib/shared/providers/notifications_provider.dart
Main entry points: main_layout.dart Main layout & navigation · auth_provider.dart Auth state & login · api_service.dart API service · workout_screen.dart Live workout capture
Components 20
Flutter Client
Cross-platform user runtime.
- App bootstrap & routing
mobile/lib/main.dart - Main layout & navigation
mobile/lib/shared/widgets/main_layout.dart - Auth state & login · Controls guest and protected access.
mobile/lib/features/auth/presentation/providers/auth_provider.dart - Setup onboarding
mobile/lib/features/setup/presentation/screens/setup_screen.dart - Dashboard & steps
mobile/lib/features/dashboard/presentation/screens/dashboard_screen.dart - Live workout capture · Captures on-device landmarks and delivers workout feedback.
mobile/lib/features/workout/presentation/screens/workout_screen.dart - Warmup & workout summary
mobile/lib/features/workout/presentation/screens/warmup_screen.dart - Coach chat
mobile/lib/features/coach/presentation/screens/coach_screen.dart - Schedules & calculators
mobile/lib/features/schedules/presentation/screens/schedules_screen.dart - Exercise library
mobile/lib/features/library/presentation/screens/library_screen.dart - API service · Calls coaching, diet, pose, reset, and health endpoints.
mobile/lib/core/services/api_service.dart - Local device services · Storage, voice, and local notifications.
mobile/lib/core/services/storage_service.dart - Bundled exercise catalog
mobile/assets/exercises.json
FastAPI Analysis Service
HTTP, pose analysis, and AI integration.
- FastAPI endpoint host · Receives pose analysis and AI coaching requests.
backend/main.py - Pose analysis coordinator · Dispatches landmark interpretation to exercise rules.
backend/engine/analyzer.py - Exercise-family rules · Movement-specific chest, leg, and full-body validation.
backend/engine/rules/base.py - Pose landmarker model · Packaged backend MediaPipe task.
backend/pose_landmarker.task
External & Device Boundaries
- Supabase auth & data · Email, Google sign-in, and persisted application data.
- Google Gemini · Generates coach and diet responses.
- Device sensors & TomTom · Supports steps, location-based gyms, and local notifications.
Connections 22
- App bootstrap & routing → Main layout & navigation: starts shell
- App bootstrap & routing → Auth state & login: initializes access state
- Auth state & login → Setup onboarding: new-user flow
- Auth state & login → Main layout & navigation: authenticated access
- Main layout & navigation → Dashboard & steps: navigates
- Main layout & navigation → Live workout capture: opens
- Main layout & navigation → Coach chat: opens
- Main layout & navigation → Schedules & calculators: opens
- Main layout & navigation → Exercise library: opens
- Exercise library → Bundled exercise catalog: loads
- Live workout capture → Warmup & workout summary: completes
- Live workout capture → API service: sends landmarks
- Coach chat → API service: sends chat requests
- Schedules & calculators → API service: requests diet/coaching
- API service → FastAPI endpoint host: HTTP
- FastAPI endpoint host → Pose analysis coordinator: pose requests
- Pose analysis coordinator → Exercise-family rules: applies exercise rules
- Pose analysis coordinator → Pose landmarker model: uses
- FastAPI endpoint host → Google Gemini: coach & diet generation
- Auth state & login → Supabase auth & data: sign-in and identity
- Local device services → Device sensors & TomTom: uses device capabilities
- Dashboard & steps → Device sensors & TomTom: reads step sensors