# praneethk-002/fitness_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/praneethk-002/fitness_tracker
- Repository: https://github.com/praneethk-002/fitness_tracker

## Overview

Fitness Tracker supports account registration and login, then lets authenticated users record, edit, delete, and view workout history. The frontend routes users through protected Home and History pages; page components call a shared API service that sends requests to the Express backend. The backend handles authentication and workout operations, including calorie calculation, and persists users and workouts through MongoDB models. The graph follows explicit imports and calls; database wiring and some unsampled page behavior are represented only where the available references support them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/services/api.js`](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/services/api.js) (API client), [`frontend/src/pages/Home.jsx`](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Home.jsx) (Workout home), [`backend/server.js`](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/server.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_home["Workout home<br/>[Home.jsx]"]
  node_history["Workout history<br/>[History.jsx]"]
  node_workout_form["Workout form<br/>[WorkoutForm.jsx]"]
  node_workout_item["Workout item<br/>[WorkoutItem.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_backend["Backend API"]
  node_server["Express server<br/>[server.js]"]
  node_auth_routes["Auth endpoints<br/>[authRoutes.js]"]
  node_workout_routes["Workout endpoints<br/>[workoutRoutes.js]"]
  node_auth_middleware["JWT middleware<br/>[authMiddleware.js]"]
  node_workout_controller["Workout operations"]
end

subgraph group_data["Persistence"]
  node_user_model["User model<br/>[User.js]"]
  node_workout_model["Workout model<br/>[Workout.js]"]
  node_db_config["Database config<br/>[db.js]"]
end

node_user(("User"))
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_auth_context
node_app -->|"renders"| node_navbar
node_app -->|"routes"| node_home
node_app -->|"routes"| node_history
node_app -->|"routes"| node_login
node_app -->|"routes"| node_register
node_login -->|"calls"| node_api
node_register -->|"calls"| node_api
node_login -->|"sets auth"| node_auth_context
node_register -->|"sets auth"| node_auth_context
node_navbar -->|"reads auth"| node_auth_context
node_home -->|"loads workouts"| node_api
node_home -->|"renders"| node_workout_form
node_home -->|"renders"| node_workout_item
node_workout_form -->|"submits workout"| node_api
node_workout_item -->|"edits or deletes"| node_api
node_history -->|"loads workouts"| node_api
node_api -->|"HTTP requests"| node_server
node_server -->|"connects"| node_db_config
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_workout_routes
node_auth_routes -->|"reads and saves"| node_user_model
node_workout_routes -->|"protects routes"| node_auth_middleware
node_workout_routes -->|"dispatches"| node_workout_controller
node_workout_controller -->|"queries and writes"| node_workout_model
node_db_config -.->|"connects"| node_mongodb

click node_app "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/context/AuthContext.jsx"
click node_navbar "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/Navbar.jsx"
click node_login "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Register.jsx"
click node_home "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Home.jsx"
click node_history "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/History.jsx"
click node_workout_form "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/WorkoutForm.jsx"
click node_workout_item "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/WorkoutItem.jsx"
click node_api "https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/server.js"
click node_auth_routes "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/routes/authRoutes.js"
click node_workout_routes "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/routes/workoutRoutes.js"
click node_auth_middleware "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/middleware/authMiddleware.js"
click node_workout_controller "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/controllers/workoutController.js"
click node_user_model "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/models/User.js"
click node_workout_model "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/models/Workout.js"
click node_db_config "https://github.com/praneethk-002/fitness_tracker/blob/main/backend/config/db.js"

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_context,node_navbar,node_login,node_register,node_home,node_history,node_workout_form,node_workout_item,node_api,node_user toneBlue
class node_server,node_auth_routes,node_workout_routes,node_auth_middleware,node_workout_controller,node_mongodb toneAmber
class node_user_model,node_workout_model,node_db_config toneMint
```

## Components

### Frontend

- [App routing](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth state](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Navigation](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Login](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Workout home](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Workout history](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`
- [Workout form](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/WorkoutForm.jsx): `frontend/src/components/WorkoutForm.jsx`
- [Workout item](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/components/WorkoutItem.jsx): `frontend/src/components/WorkoutItem.jsx`
- [API client](https://github.com/praneethk-002/fitness_tracker/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Backend API

- [Express server](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/server.js): `backend/server.js`
- [Auth endpoints](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Workout endpoints](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/routes/workoutRoutes.js): `backend/routes/workoutRoutes.js`
- [JWT middleware](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Workout operations](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/controllers/workoutController.js): `backend/controllers/workoutController.js`

### Persistence

- [User model](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/models/User.js): `backend/models/User.js`
- [Workout model](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/models/Workout.js): `backend/models/Workout.js`
- [Database config](https://github.com/praneethk-002/fitness_tracker/blob/main/backend/config/db.js): `backend/config/db.js`

### Other components

- **User**
- **MongoDB**

## Connections

- User → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Auth state: provides auth (evidence: `frontend/src/App.jsx`)
- App routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App routing → Workout home: routes (evidence: `frontend/src/App.jsx`)
- App routing → Workout history: routes (evidence: `frontend/src/App.jsx`)
- App routing → Login: routes (evidence: `frontend/src/App.jsx`)
- App routing → Registration: routes (evidence: `frontend/src/App.jsx`)
- Login → API client: calls (evidence: `frontend/src/services/api.js`)
- Registration → API client: calls (evidence: `frontend/src/services/api.js`)
- Login → Auth state: sets auth (evidence: `frontend/src/pages/Login.jsx`)
- Registration → Auth state: sets auth (evidence: `frontend/src/pages/Register.jsx`)
- Navigation → Auth state: reads auth (evidence: `frontend/src/components/Navbar.jsx`)
- Workout home → API client: loads workouts (evidence: `frontend/src/pages/Home.jsx`)
- Workout home → Workout form: renders (evidence: `frontend/src/pages/Home.jsx`)
- Workout home → Workout item: renders (evidence: `frontend/src/pages/Home.jsx`)
- Workout form → API client: submits workout (evidence: `frontend/src/components/WorkoutForm.jsx`)
- Workout item → API client: edits or deletes (evidence: `frontend/src/components/WorkoutItem.jsx`)
- Workout history → API client: loads workouts (evidence: `frontend/src/pages/History.jsx`)
- API client → Express server: HTTP requests (evidence: `frontend/src/services/api.js`)
- Express server → Database config: connects (evidence: `backend/server.js`)
- Express server → Auth endpoints: mounts (evidence: `backend/server.js`)
- Express server → Workout endpoints: mounts (evidence: `backend/server.js`)
- Auth endpoints → User model: reads and saves (evidence: `backend/routes/authRoutes.js`)
- Workout endpoints → JWT middleware: protects routes (evidence: `backend/routes/workoutRoutes.js`)
- Workout endpoints → Workout operations: dispatches (evidence: `backend/routes/workoutRoutes.js`)
- Workout operations → Workout model: queries and writes (evidence: `backend/controllers/workoutController.js`)
- Database config → MongoDB: connects
