# deepak007bgd/fitbuddy architecture

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

- Interactive diagram: https://gitdiagram.com/deepak007bgd/fitbuddy
- Repository: https://github.com/deepak007bgd/fitbuddy

## Overview

FitBuddy is a workout-tracking and personalized fitness web app. Users register and maintain a fitness profile, then log workouts, view daily plans, track progress and streaks, and optionally request AI coaching or analysis. The main path runs from authenticated Home or Progress screens through workout/progress services and Firestore; AI features use a separate service and server handler. The graph follows shown imports, calls, and routes; AI-service-to-server wiring is not visible in the excerpts, so that link is marked unverified.

Main entry points: [`src/pages/Home.jsx`](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Home.jsx) (Home dashboard), [`src/App.jsx`](https://github.com/deepak007bgd/fitbuddy/blob/main/src/App.jsx) (Application routes), [`src/pages/Progress.jsx`](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Progress.jsx) (Progress dashboard), [`src/lib/aiService.js`](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/aiService.js) (AI feature service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts and Profiles"]
  node_app["Application routes<br/>[App.jsx]"]
  node_auth["Authentication<br/>[AuthContext.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_profile["Fitness profile<br/>[Profile.jsx]"]
end

subgraph group_fitness["Workout and Progress"]
  node_home["Home dashboard<br/>[Home.jsx]"]
  node_workoutui["Workout logging<br/>[WorkoutModal.jsx]"]
  node_history["Workout history"]
  node_workouts["Workout records<br/>[workoutService.js]"]
  node_dailyplan["Daily plan<br/>[DailyPlanView.jsx]"]
  node_progress["Progress dashboard<br/>[Progress.jsx]"]
  node_metrics["Progress metrics<br/>[progressService.js]"]
  node_streak["Streak milestones"]
  node_streakui["Streak display<br/>[StreakWidget.jsx]"]
  node_celebration["Milestone celebration"]
end

subgraph group_coaching["AI Coaching"]
  node_assistant["AI assistant<br/>[AiAssistant.jsx]"]
  node_analysisui["AI progress analysis"]
  node_aiservice["AI feature service<br/>[aiService.js]"]
  node_aihandler["AI request handler<br/>[aiHandler.js]"]
end

subgraph group_platform["Shared Platform"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_ui["Shared UI<br/>[ui.jsx]"]
end

node_user(("Fitness user"))
node_gemini["Gemini API"]
node_firestore[("Firestore")]

node_user -->|"uses"| node_app
node_app -->|"guards routes"| node_auth
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_progress
node_auth -->|"uses auth and data"| node_firebase
node_profile -->|"reads profile"| node_auth
node_home -->|"reads session"| node_auth
node_home -->|"loads and updates"| node_workouts
node_home -->|"opens logging"| node_workoutui
node_home -->|"shows history"| node_history
node_workoutui -->|"logs workouts"| node_workouts
node_history -->|"reads records"| node_workouts
node_home -->|"displays plan"| node_dailyplan
node_home -->|"requests daily plan"| node_aiservice
node_home -->|"claims milestones"| node_streak
node_home -->|"renders streak"| node_streakui
node_home -->|"shows milestone"| node_celebration
node_streakui -->|"uses milestone data"| node_streak
node_progress -->|"reads profile"| node_auth
node_progress -->|"loads workout logs"| node_workouts
node_progress -->|"computes metrics"| node_metrics
node_metrics -->|"reads weight logs"| node_firebase
node_progress -->|"requests analysis"| node_aiservice
node_progress -->|"renders analysis"| node_analysisui
node_assistant -->|"sends chat"| node_aiservice
node_aiservice -->|"caches AI results"| node_firebase
node_aiservice -->|"uses workout context"| node_workouts
node_aiservice -.->|"requests AI generation"| node_aihandler
node_aihandler -->|"calls generation API"| node_gemini
node_workouts -->|"reads and writes records"| node_firebase
node_streak -->|"updates claims"| node_firebase
node_firebase -->|"connects"| node_firestore
node_login -->|"renders controls"| node_ui
node_register -->|"renders controls"| node_ui
node_dailyplan -->|"renders controls"| node_ui
node_assistant -->|"renders controls"| node_ui
node_analysisui -->|"renders controls"| node_ui

click node_app "https://github.com/deepak007bgd/fitbuddy/blob/main/src/App.jsx"
click node_auth "https://github.com/deepak007bgd/fitbuddy/blob/main/src/context/AuthContext.jsx"
click node_login "https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Login.jsx"
click node_register "https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Register.jsx"
click node_profile "https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Profile.jsx"
click node_home "https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Home.jsx"
click node_workoutui "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/WorkoutModal.jsx"
click node_history "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/WorkoutHistoryModal.jsx"
click node_workouts "https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/workoutService.js"
click node_dailyplan "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/DailyPlanView.jsx"
click node_progress "https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Progress.jsx"
click node_metrics "https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/progressService.js"
click node_streak "https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/milestoneService.js"
click node_streakui "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/StreakWidget.jsx"
click node_celebration "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/MilestoneCelebrationModal.jsx"
click node_assistant "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/AiAssistant.jsx"
click node_analysisui "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/AiProgressAnalysisCard.jsx"
click node_aiservice "https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/aiService.js"
click node_aihandler "https://github.com/deepak007bgd/fitbuddy/blob/main/server/aiHandler.js"
click node_firebase "https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/firebase.js"
click node_ui "https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/ui.jsx"

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_auth,node_login,node_register,node_profile,node_user toneBlue
class node_home,node_workoutui,node_history,node_workouts,node_dailyplan,node_progress,node_metrics,node_streak,node_streakui,node_celebration,node_firestore toneAmber
class node_assistant,node_analysisui,node_aiservice,node_aihandler,node_gemini toneMint
class node_firebase,node_ui toneRose
```

## Components

### Accounts and Profiles

- [Application routes](https://github.com/deepak007bgd/fitbuddy/blob/main/src/App.jsx): `src/App.jsx`
- [Authentication](https://github.com/deepak007bgd/fitbuddy/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Login](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Login.jsx): `src/pages/Login.jsx`
- [Registration](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Register.jsx): `src/pages/Register.jsx`
- [Fitness profile](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Profile.jsx): `src/pages/Profile.jsx`

### Workout and Progress

- [Home dashboard](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Home.jsx): `src/pages/Home.jsx`
- [Workout logging](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/WorkoutModal.jsx): `src/components/WorkoutModal.jsx`
- [Workout history](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/WorkoutHistoryModal.jsx): `src/components/WorkoutHistoryModal.jsx`
- [Workout records](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/workoutService.js): `src/lib/workoutService.js`
- [Daily plan](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/DailyPlanView.jsx): `src/components/DailyPlanView.jsx`
- [Progress dashboard](https://github.com/deepak007bgd/fitbuddy/blob/main/src/pages/Progress.jsx): `src/pages/Progress.jsx`
- [Progress metrics](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/progressService.js): `src/lib/progressService.js`
- [Streak milestones](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/milestoneService.js): `src/lib/milestoneService.js`
- [Streak display](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/StreakWidget.jsx): `src/components/StreakWidget.jsx`
- [Milestone celebration](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/MilestoneCelebrationModal.jsx): `src/components/MilestoneCelebrationModal.jsx`

### AI Coaching

- [AI assistant](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/AiAssistant.jsx): `src/components/AiAssistant.jsx`
- [AI progress analysis](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/AiProgressAnalysisCard.jsx): `src/components/AiProgressAnalysisCard.jsx`
- [AI feature service](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/aiService.js): `src/lib/aiService.js`
- [AI request handler](https://github.com/deepak007bgd/fitbuddy/blob/main/server/aiHandler.js): `server/aiHandler.js`

### Shared Platform

- [Firebase client](https://github.com/deepak007bgd/fitbuddy/blob/main/src/lib/firebase.js): `src/lib/firebase.js`
- [Shared UI](https://github.com/deepak007bgd/fitbuddy/blob/main/src/components/ui.jsx): `src/components/ui.jsx`

### Other components

- **Fitness user**
- **Gemini API**
- **Firestore**

## Connections

- Fitness user → Application routes: uses
- Application routes → Authentication: guards routes (evidence: `src/App.jsx`)
- Application routes → Login: routes to (evidence: `src/App.jsx`)
- Application routes → Registration: routes to (evidence: `src/App.jsx`)
- Application routes → Fitness profile: routes to (evidence: `src/App.jsx`)
- Application routes → Home dashboard: routes to (evidence: `src/App.jsx`)
- Application routes → Progress dashboard: routes to (evidence: `src/App.jsx`)
- Authentication → Firebase client: uses auth and data (evidence: `src/context/AuthContext.jsx`)
- Fitness profile → Authentication: reads profile (evidence: `src/pages/Profile.jsx`)
- Home dashboard → Authentication: reads session (evidence: `src/pages/Home.jsx`)
- Home dashboard → Workout records: loads and updates (evidence: `src/pages/Home.jsx`)
- Home dashboard → Workout logging: opens logging (evidence: `src/pages/Home.jsx`)
- Home dashboard → Workout history: shows history (evidence: `src/pages/Home.jsx`)
- Workout logging → Workout records: logs workouts (evidence: `src/components/WorkoutModal.jsx`)
- Workout history → Workout records: reads records (evidence: `src/components/WorkoutHistoryModal.jsx`)
- Home dashboard → Daily plan: displays plan (evidence: `src/pages/Home.jsx`)
- Home dashboard → AI feature service: requests daily plan (evidence: `src/pages/Home.jsx`)
- Home dashboard → Streak milestones: claims milestones (evidence: `src/pages/Home.jsx`)
- Home dashboard → Streak display: renders streak (evidence: `src/pages/Home.jsx`)
- Home dashboard → Milestone celebration: shows milestone (evidence: `src/pages/Home.jsx`)
- Streak display → Streak milestones: uses milestone data (evidence: `src/components/StreakWidget.jsx`)
- Progress dashboard → Authentication: reads profile (evidence: `src/pages/Progress.jsx`)
- Progress dashboard → Workout records: loads workout logs (evidence: `src/pages/Progress.jsx`)
- Progress dashboard → Progress metrics: computes metrics (evidence: `src/pages/Progress.jsx`)
- Progress metrics → Firebase client: reads weight logs (evidence: `src/lib/progressService.js`)
- Progress dashboard → AI feature service: requests analysis (evidence: `src/pages/Progress.jsx`)
- Progress dashboard → AI progress analysis: renders analysis (evidence: `src/pages/Progress.jsx`)
- AI assistant → AI feature service: sends chat (evidence: `src/components/AiAssistant.jsx`)
- AI feature service → Firebase client: caches AI results (evidence: `src/lib/aiService.js`)
- AI feature service → Workout records: uses workout context (evidence: `src/lib/aiService.js`)
- AI feature service → AI request handler: requests AI generation
- AI request handler → Gemini API: calls generation API (evidence: `server/aiHandler.js`)
- Workout records → Firebase client: reads and writes records (evidence: `src/lib/workoutService.js`)
- Streak milestones → Firebase client: updates claims (evidence: `src/lib/milestoneService.js`)
- Firebase client → Firestore: connects (evidence: `src/lib/firebase.js`)
- Login → Shared UI: renders controls (evidence: `src/pages/Login.jsx`)
- Registration → Shared UI: renders controls (evidence: `src/pages/Register.jsx`)
- Daily plan → Shared UI: renders controls (evidence: `src/components/DailyPlanView.jsx`)
- AI assistant → Shared UI: renders controls (evidence: `src/components/AiAssistant.jsx`)
- AI progress analysis → Shared UI: renders controls (evidence: `src/components/AiProgressAnalysisCard.jsx`)
