How kakumanu-harshitha/fitvision-ai works
Purpose and Runtime Entry Points
AI Fitness Tracker is a full-stack fitness coaching system: browser-based pose/workout interaction, FastAPI APIs, persisted fitness/social data, and AI-assisted personalization/coaching. Backend starts at Ai_Fitness_Tracker/backend/app/main.py (uvicorn app.main:app); React starts from Ai_Fitness_Tracker/frontend/src/index.js and composes routes/UI in Ai_Fitness_Tracker/frontend/src/App.js.
Client Application and Live Workout Boundary
The React client owns interactive screens, camera presentation, local workout state, and API/WebSocket consumption. Live sessions center on Ai_Fitness_Tracker/frontend/src/screens/LiveWorkout.js and Ai_Fitness_Tracker/frontend/src/components/CameraView.js; shared state is provided through Ai_Fitness_Tracker/frontend/src/contexts/WorkoutContext.js. The browser-side MediaPipe workflow is the real-time pose boundary; it emits workout outcomes rather than requiring raw camera streams to be persisted by the backend.
HTTP API, Authentication, and Domain Routing
FastAPI versioned routers expose auth, workouts, plans, dashboards, social, AI, chatbot, hydration, and voice-facing capabilities under Ai_Fitness_Tracker/backend/app/api/v1/. Authentication/security dependencies and request policy are centralized in Ai_Fitness_Tracker/backend/app/api/dependencies.py, Ai_Fitness_Tracker/backend/app/core/security.py, and Ai_Fitness_Tracker/backend/app/core/middleware.py. JWT is the primary auth mechanism, with migration evidence for optional TOTP MFA.
Business Services and Persistence
Router handlers delegate core workout, activity, plan, and identity behaviors to service/repository layers: Ai_Fitness_Tracker/backend/app/services/workout_service.py, Ai_Fitness_Tracker/backend/app/services/activity_service.py, and Ai_Fitness_Tracker/backend/app/db/repositories/workout_repo.py. SQLAlchemy models and async database setup form the persistence boundary in Ai_Fitness_Tracker/backend/app/db/models.py and Ai_Fitness_Tracker/backend/app/db/database.py. Alembic migrations in Ai_Fitness_Tracker/backend/alembic/versions/ evolve the relational schema, including workout replay, plans, chatbot context, and social activity.
Computer-Vision Exercise Pipeline
The backend AI core supports capture-to-feedback processing: camera input, MediaPipe landmark detection, angle/feature derivation, temporal smoothing, exercise state logic, rep counting, and scoring. Key orchestration and boundaries are Ai_Fitness_Tracker/backend/app/core_ai/pipeline.py, Ai_Fitness_Tracker/backend/app/core_ai/pose/pose_detector.py, and Ai_Fitness_Tracker/backend/app/core_ai/processing/rep_counter.py. Exercise-specific rules reside in Ai_Fitness_Tracker/backend/app/core_ai/exercises/, keeping interpretable movement semantics separate from API and persistence code.
Personalization and AI Coaching
Personal targets and coaching combine stored user/workout context with lightweight ML and LLM-oriented coach logic. The Random Forest-related model path is represented by Ai_Fitness_Tracker/backend/app/core_ai/personalization_model.py and Ai_Fitness_Tracker/backend/app/core_ai/processing/ml_models.py; chatbot/AI endpoints are Ai_Fitness_Tracker/backend/app/api/v1/chatbot.py and Ai_Fitness_Tracker/backend/app/api/v1/ai.py. Coach implementations in Ai_Fitness_Tracker/backend/app/core_ai/coach/ produce guidance for plans, lifestyle, or workout feedback.
Real-Time, External Infrastructure, and Operations
WebSockets support real-time chat and social-duel/session updates via Ai_Fitness_Tracker/backend/app/api/v1/websockets.py and Ai_Fitness_Tracker/backend/app/websockets.py, consumed by Ai_Fitness_Tracker/frontend/src/hooks/useWebSocket.js. PostgreSQL is the intended production datastore; Redis is an additional runtime dependency managed through Ai_Fitness_Tracker/backend/app/core/redis.py. Material external/model services include MediaPipe, scikit-learn/joblib model artifacts, and an LLM provider configured through backend settings rather than embedded in the frontend.
Main entry points: pipeline.py Exercise CV pipeline · LiveWorkout.js Live workout UI · websockets.py Realtime endpoints · database.py SQLAlchemy data layer
Components 21
React Client
- React entry & routes
Ai_Fitness_Tracker/frontend/src/index.js - Live workout UI
Ai_Fitness_Tracker/frontend/src/screens/LiveWorkout.js - Camera pose capture · Processes browser camera input locally.
Ai_Fitness_Tracker/frontend/src/components/CameraView.js - Workout state
Ai_Fitness_Tracker/frontend/src/contexts/WorkoutContext.js - WebSocket client
Ai_Fitness_Tracker/frontend/src/hooks/useWebSocket.js
FastAPI Backend
- FastAPI application
Ai_Fitness_Tracker/backend/app/main.py - Versioned API routers · Auth, workouts, plans, dashboards, social, AI, chatbot, hydration, and voice APIs.
- Auth & request policy · Centralizes authentication dependencies, security, and middleware.
Ai_Fitness_Tracker/backend/app/api/dependencies.py - Workout & activity services
Ai_Fitness_Tracker/backend/app/services/workout_service.py
AI Processing
- Exercise CV pipeline · Runs pose analysis through feedback scoring.
Ai_Fitness_Tracker/backend/app/core_ai/pipeline.py - Pose detection
Ai_Fitness_Tracker/backend/app/core_ai/pose/pose_detector.py - Rep counting & scoring
Ai_Fitness_Tracker/backend/app/core_ai/processing/rep_counter.py - Exercise rules
- Personalization model · Random Forest-related personalization and model loading.
Ai_Fitness_Tracker/backend/app/core_ai/personalization_model.py - AI coach · Produces plan, lifestyle, and workout guidance.
Data & Realtime
- Realtime endpoints · Chat and social-duel/session updates.
Ai_Fitness_Tracker/backend/app/api/v1/websockets.py - Workout repository
Ai_Fitness_Tracker/backend/app/db/repositories/workout_repo.py - SQLAlchemy data layer · Models and async database setup.
Ai_Fitness_Tracker/backend/app/db/database.py - PostgreSQL
- Redis
Ai_Fitness_Tracker/backend/app/core/redis.py
Other components
- LLM provider
Connections 22
- React entry & routes → Live workout UI: renders
- Live workout UI → Camera pose capture: uses
- Live workout UI → Workout state: updates
- Camera pose capture → Exercise CV pipeline: submits pose/workout input
- React entry & routes → Versioned API routers: HTTP API
- WebSocket client → Realtime endpoints: WebSocket
- FastAPI application → Versioned API routers: mounts
- FastAPI application → Realtime endpoints: hosts
- Versioned API routers → Auth & request policy: enforces
- Versioned API routers → Workout & activity services: delegates
- Versioned API routers → Exercise CV pipeline: invokes AI feedback
- Versioned API routers → AI coach: requests coaching
- Workout & activity services → Workout repository: persists via
- Workout repository → SQLAlchemy data layer: uses
- SQLAlchemy data layer → PostgreSQL: stores relational data
- Realtime endpoints → Redis: uses runtime state
- Exercise CV pipeline → Pose detection: detects landmarks
- Exercise CV pipeline → Rep counting & scoring: derives reps and score
- Rep counting & scoring → Exercise rules: applies rules
- AI coach → Personalization model: uses user targets
- AI coach → LLM provider: generates guidance
- Personalization model → SQLAlchemy data layer: uses workout context