# tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system architecture

> Architecture diagram of the GitHub repository tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system
- Repository: https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system

## Overview

AI Gym & Fitness Assistant combines a React dashboard with a FastAPI service. Users choose a fitness feature, submit inputs through the shared API client, and receive module-specific results; the backend persists results for history and analytics. The README documents all eight feature areas and optional AI, IoT, and place-search upgrades. Edges are grounded in excerpts, the source index, or README statements; unsampled module internals and some integration wiring are not inferred.

Main entry points: [`frontend/src/App.jsx`](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/App.jsx) (Dashboard tabs), [`backend/main.py`](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/main.py) (FastAPI route registry), [`backend/database.py`](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/database.py) (Database sessions), [`frontend/src/api.js`](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Fitness Dashboard"]
  node_app["Dashboard tabs<br/>[App.jsx]"]
  node_api["API client<br/>[api.js]"]
  node_workout_ui["Workout trainer UI<br/>[WorkoutTrainer.jsx]"]
  node_diet_ui["Diet coach UI<br/>[DietCoach.jsx]"]
  node_smartgym_ui["Smart gym UI<br/>[SmartGym.jsx]"]
  node_habits_ui["Habit tracker UI<br/>[HabitTracker.jsx]"]
  node_chat_ui["Chat companion UI<br/>[ChatCompanion.jsx]"]
  node_performance_ui["Performance UI"]
  node_recommender_ui["Gym finder UI<br/>[GymRecommender.jsx]"]
  node_analytics_ui["Analytics dashboard"]
end

subgraph group_backend["Fitness Services"]
  node_routes["FastAPI route registry<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_workout["Workout analysis<br/>[workout_trainer.py]"]
  node_diet["Diet planning<br/>[diet_coach.py]"]
  node_smartgym["Smart gym assistance<br/>[smart_gym.py]"]
  node_habits["Habit risk tracking<br/>[habit_tracker.py]"]
  node_chat["Chat companion<br/>[chat_companion.py]"]
  node_chat_logic["Sentiment and replies<br/>[chat_logic.py]"]
  node_habit_logic["Skip risk logic<br/>[habit_logic.py]"]
  node_performance["Performance scoring"]
  node_recommender["Gym recommendations<br/>[gym_recommender.py]"]
end

subgraph group_data["Persistence and Analytics"]
  node_analytics["History aggregation<br/>[analytics.py]"]
  node_db_access["Database sessions<br/>[database.py]"]
  node_models["Result records<br/>[db_models.py]"]
  node_store[("Fitness database<br/>[fitness.db]")]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
end

subgraph group_integrations["Optional Integrations"]
  node_vision["Pose detection"]
  node_llm["OpenAI service"]
  node_mqtt["MQTT broker"]
  node_places["Google Places"]
end

node_user(("Fitness user"))

node_user -->|"chooses feature"| node_app
node_app -->|"renders"| node_workout_ui
node_app -->|"renders"| node_diet_ui
node_app -->|"renders"| node_smartgym_ui
node_app -->|"renders"| node_habits_ui
node_app -->|"renders"| node_chat_ui
node_app -->|"renders"| node_performance_ui
node_app -->|"renders"| node_recommender_ui
node_app -->|"renders"| node_analytics_ui
node_workout_ui -->|"requests"| node_api
node_diet_ui -->|"requests"| node_api
node_smartgym_ui -->|"requests"| node_api
node_habits_ui -->|"requests"| node_api
node_chat_ui -->|"requests"| node_api
node_performance_ui -->|"requests"| node_api
node_recommender_ui -->|"requests"| node_api
node_analytics_ui -->|"requests"| node_api
node_api -->|"HTTP requests"| node_routes
node_routes -->|"registers routes"| node_workout
node_routes -->|"registers routes"| node_diet
node_routes -->|"registers routes"| node_smartgym
node_routes -->|"registers routes"| node_habits
node_routes -->|"registers routes"| node_chat
node_routes -->|"registers routes"| node_performance
node_routes -->|"registers routes"| node_recommender
node_routes -->|"registers routes"| node_analytics
node_workout -->|"validates input"| node_schemas
node_workout -->|"opens sessions"| node_db_access
node_workout -->|"writes workout logs"| node_models
node_chat -->|"classifies and replies"| node_chat_logic
node_chat -->|"opens sessions"| node_db_access
node_chat -->|"writes chat logs"| node_models
node_habits -->|"calculates skip risk"| node_habit_logic
node_diet -->|"opens sessions"| node_db_access
node_smartgym -->|"validates input"| node_schemas
node_performance -->|"opens sessions"| node_db_access
node_recommender -->|"opens sessions"| node_db_access
node_analytics -->|"reads history"| node_db_access
node_db_access -->|"registers tables"| node_models
node_models -->|"uses base"| node_db_access
node_db_access -->|"persists records"| node_store
node_workout -.->|"uses pose detection"| node_vision
node_chat -.->|"generates replies"| node_llm
node_smartgym -.->|"listens for readings"| node_mqtt
node_recommender -.->|"searches gyms"| node_places

click node_app "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/api.js"
click node_workout_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/WorkoutTrainer.jsx"
click node_diet_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/DietCoach.jsx"
click node_smartgym_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/SmartGym.jsx"
click node_habits_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/HabitTracker.jsx"
click node_chat_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/ChatCompanion.jsx"
click node_performance_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/PerformanceAnalyzer.jsx"
click node_recommender_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/GymRecommender.jsx"
click node_analytics_ui "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/AnalyticsDashboard.jsx"
click node_routes "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/main.py"
click node_schemas "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/models/schemas.py"
click node_workout "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/workout_trainer.py"
click node_diet "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/diet_coach.py"
click node_smartgym "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/smart_gym.py"
click node_habits "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/habit_tracker.py"
click node_chat "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/chat_companion.py"
click node_chat_logic "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/logic/chat_logic.py"
click node_habit_logic "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/logic/habit_logic.py"
click node_performance "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/performance_analyzer.py"
click node_recommender "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/gym_recommender.py"
click node_analytics "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/analytics.py"
click node_db_access "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/database.py"
click node_models "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/db_models.py"
click node_store "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/fitness.db"
click node_metrics "https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/evaluation/metrics.py"

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_app,node_api,node_workout_ui,node_diet_ui,node_smartgym_ui,node_habits_ui,node_chat_ui,node_performance_ui,node_recommender_ui,node_analytics_ui,node_user toneBlue
class node_routes,node_schemas,node_workout,node_diet,node_smartgym,node_habits,node_chat,node_chat_logic,node_habit_logic,node_performance,node_recommender toneAmber
class node_analytics,node_db_access,node_models,node_store,node_metrics toneMint
class node_vision,node_llm,node_mqtt,node_places toneRose
```

## Components

### Fitness Dashboard

- [Dashboard tabs](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Workout trainer UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/WorkoutTrainer.jsx): `frontend/src/components/WorkoutTrainer.jsx`
- [Diet coach UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/DietCoach.jsx): `frontend/src/components/DietCoach.jsx`
- [Smart gym UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/SmartGym.jsx): `frontend/src/components/SmartGym.jsx`
- [Habit tracker UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/HabitTracker.jsx): `frontend/src/components/HabitTracker.jsx`
- [Chat companion UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/ChatCompanion.jsx): `frontend/src/components/ChatCompanion.jsx`
- [Performance UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/PerformanceAnalyzer.jsx): `frontend/src/components/PerformanceAnalyzer.jsx`
- [Gym finder UI](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/GymRecommender.jsx): `frontend/src/components/GymRecommender.jsx`
- [Analytics dashboard](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/frontend/src/components/AnalyticsDashboard.jsx): `frontend/src/components/AnalyticsDashboard.jsx`

### Fitness Services

- [FastAPI route registry](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/main.py): `backend/main.py`
- [Request schemas](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/models/schemas.py): `backend/models/schemas.py`
- [Workout analysis](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/workout_trainer.py): `backend/modules/workout_trainer.py`
- [Diet planning](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/diet_coach.py): `backend/modules/diet_coach.py`
- [Smart gym assistance](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/smart_gym.py): `backend/modules/smart_gym.py`
- [Habit risk tracking](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/habit_tracker.py): `backend/modules/habit_tracker.py`
- [Chat companion](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/chat_companion.py): `backend/modules/chat_companion.py`
- [Sentiment and replies](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/logic/chat_logic.py): `backend/logic/chat_logic.py`
- [Skip risk logic](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/logic/habit_logic.py): `backend/logic/habit_logic.py`
- [Performance scoring](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/performance_analyzer.py): `backend/modules/performance_analyzer.py`
- [Gym recommendations](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/gym_recommender.py): `backend/modules/gym_recommender.py`

### Persistence and Analytics

- [History aggregation](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/modules/analytics.py): `backend/modules/analytics.py`
- [Database sessions](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/database.py): `backend/database.py`
- [Result records](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/db_models.py): `backend/db_models.py`
- [Fitness database](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/fitness.db): `backend/fitness.db`
- [Evaluation metrics](https://github.com/tanaypusalkar-jpg/an-ai-powered-gym-fitness-tracking-system/blob/main/backend/evaluation/metrics.py): `backend/evaluation/metrics.py`

### Optional Integrations

- **Pose detection**
- **OpenAI service**
- **MQTT broker**
- **Google Places**

### Other components

- **Fitness user**

## Connections

- Fitness user → Dashboard tabs: chooses feature (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Workout trainer UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Diet coach UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Smart gym UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Habit tracker UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Chat companion UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Performance UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Gym finder UI: renders (evidence: `frontend/src/App.jsx`)
- Dashboard tabs → Analytics dashboard: renders (evidence: `frontend/src/App.jsx`)
- Workout trainer UI → API client: requests (evidence: `frontend/src/components/WorkoutTrainer.jsx`)
- Diet coach UI → API client: requests (evidence: `frontend/src/components/DietCoach.jsx`)
- Smart gym UI → API client: requests (evidence: `frontend/src/components/SmartGym.jsx`)
- Habit tracker UI → API client: requests (evidence: `frontend/src/components/HabitTracker.jsx`)
- Chat companion UI → API client: requests (evidence: `frontend/src/components/ChatCompanion.jsx`)
- Performance UI → API client: requests (evidence: `frontend/src/components/PerformanceAnalyzer.jsx`)
- Gym finder UI → API client: requests (evidence: `frontend/src/components/GymRecommender.jsx`)
- Analytics dashboard → API client: requests (evidence: `frontend/src/components/AnalyticsDashboard.jsx`)
- API client → FastAPI route registry: HTTP requests (evidence: `README.md`)
- FastAPI route registry → Workout analysis: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Diet planning: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Smart gym assistance: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Habit risk tracking: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Chat companion: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Performance scoring: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → Gym recommendations: registers routes (evidence: `backend/main.py`)
- FastAPI route registry → History aggregation: registers routes (evidence: `backend/main.py`)
- Workout analysis → Request schemas: validates input (evidence: `backend/modules/workout_trainer.py`)
- Workout analysis → Database sessions: opens sessions (evidence: `backend/modules/workout_trainer.py`)
- Workout analysis → Result records: writes workout logs (evidence: `backend/modules/workout_trainer.py`)
- Chat companion → Sentiment and replies: classifies and replies (evidence: `backend/modules/chat_companion.py`)
- Chat companion → Database sessions: opens sessions (evidence: `backend/modules/chat_companion.py`)
- Chat companion → Result records: writes chat logs (evidence: `backend/modules/chat_companion.py`)
- Habit risk tracking → Skip risk logic: calculates skip risk (evidence: `backend/modules/habit_tracker.py`)
- Diet planning → Database sessions: opens sessions (evidence: `backend/modules/diet_coach.py`)
- Smart gym assistance → Request schemas: validates input (evidence: `backend/modules/smart_gym.py`)
- Performance scoring → Database sessions: opens sessions (evidence: `backend/modules/performance_analyzer.py`)
- Gym recommendations → Database sessions: opens sessions (evidence: `backend/modules/gym_recommender.py`)
- History aggregation → Database sessions: reads history (evidence: `backend/modules/analytics.py`)
- Database sessions → Result records: registers tables (evidence: `backend/database.py`)
- Result records → Database sessions: uses base (evidence: `backend/db_models.py`)
- Database sessions → Fitness database: persists records (evidence: `backend/database.py`)
- Workout analysis → Pose detection: uses pose detection (evidence: `README.md`)
- Chat companion → OpenAI service: generates replies (evidence: `backend/modules/chat_companion.py`)
- Smart gym assistance → MQTT broker: listens for readings (evidence: `README.md`)
- Gym recommendations → Google Places: searches gyms (evidence: `README.md`)
