# rockeybhai19511-ctrl/fitness-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/rockeybhai19511-ctrl/fitness-tracker
- Repository: https://github.com/rockeybhai19511-ctrl/fitness-tracker

## Overview

PulseTrack is an admin-only fitness journal. The user signs in, records steps and water manually or saves a live walk, then reviews derived activity metrics, history, goals, workouts and settings. The backend validates requests, applies domain calculations, and persists entries and preferences in MongoDB. The graph follows the shown route/API and controller calls; several UI capabilities and route details are documented but their implementations were not sampled, so those links are omitted where source evidence is unavailable.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/App.tsx) (Page routing), [`frontend/src/utils/api.ts`](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/api.ts) (API client), [`backend/src/server.js`](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/server.js) (HTTP server), [`backend/src/controllers/dashboardController.js`](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/dashboardController.js) (Metric aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Fitness journal"]
  node_app["Page routing<br/>[App.tsx]"]
  node_login["Admin login<br/>[Login.tsx]"]
  node_dashboard["Metrics dashboard<br/>[Dashboard.tsx]"]
  node_activity["Activity logging<br/>[LogActivity.tsx]"]
  node_journey["Journey badges<br/>[JourneyTrail.tsx]"]
  node_goals["Goals<br/>[Goals.tsx]"]
  node_workouts["Workout guide<br/>[Workouts.tsx]"]
  node_settingsui["Fitness settings<br/>[Settings.tsx]"]
end

subgraph group_client["Client state and API"]
  node_walktracker["Walk sensing"]
  node_clientmetrics["Metric calculations<br/>[calculations.ts]"]
  node_authstate["Auth state<br/>[authStore.ts]"]
  node_api["API client<br/>[api.ts]"]
end

subgraph group_service["Backend services"]
  node_server["HTTP server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_authcontroller["Admin authentication<br/>[authController.js]"]
  node_authmiddleware["JWT protection<br/>[auth.js]"]
  node_entryroutes["Entry routes<br/>[entries.js]"]
  node_entrycontroller["Entry handling"]
  node_dashboardroutes["Dashboard routes<br/>[dashboard.js]"]
  node_dashboardcontroller["Metric aggregation"]
  node_settingsroutes["Settings routes<br/>[settings.js]"]
  node_settingscontroller["Settings handling"]
  node_extrasroutes["Goals and workout routes<br/>[extras.js]"]
  node_extrascontroller["Goals and workouts"]
  node_validation["Request validation<br/>[validate.js]"]
  node_domaincalc["Fitness calculations<br/>[calculations.js]"]
end

subgraph group_persistence["MongoDB records"]
  node_dbconfig["Mongo connection<br/>[db.js]"]
  node_adminrecord[("Admin record<br/>[Admin.js]")]
  node_stepsrecord[("Step entries<br/>[StepEntry.js]")]
  node_waterrecord[("Water entries<br/>[WaterEntry.js]")]
  node_settingsrecord[("Settings record<br/>[Settings.js]")]
  node_goalrecord[("Goal records<br/>[Goal.js]")]
  node_workoutrecord[("Workout templates<br/>[WorkoutTemplate.js]")]
end

node_admin(("Admin"))

node_admin -->|"opens app"| node_app
node_app -->|"routes guest"| node_login
node_app -->|"routes page"| node_dashboard
node_app -->|"routes page"| node_activity
node_app -->|"routes page"| node_goals
node_app -->|"routes page"| node_workouts
node_app -->|"routes page"| node_settingsui
node_login -->|"submits credentials"| node_api
node_login -->|"stores session"| node_authstate
node_app -->|"checks token"| node_authstate
node_activity -->|"tracks walk"| node_walktracker
node_activity -->|"sends entries"| node_api
node_activity -->|"renders milestones"| node_journey
node_activity -->|"uses date helper"| node_clientmetrics
node_dashboard -->|"loads metrics"| node_api
node_dashboard -->|"uses calculations"| node_clientmetrics
node_goals -->|"manages goals"| node_api
node_workouts -->|"loads templates"| node_api
node_workouts -->|"estimates energy"| node_clientmetrics
node_settingsui -.->|"loads settings"| node_api
node_api -->|"reads token"| node_authstate
node_api -.->|"sends API requests"| node_server
node_server -->|"connects database"| node_dbconfig
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_dashboardroutes
node_server -->|"mounts routes"| node_entryroutes
node_server -->|"mounts routes"| node_settingsroutes
node_server -->|"mounts routes"| node_extrasroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects endpoint"| node_authmiddleware
node_authcontroller -->|"looks up admin"| node_adminrecord
node_authcontroller -->|"validates login"| node_validation
node_entryroutes -->|"dispatches"| node_entrycontroller
node_entryroutes -->|"protects endpoints"| node_authmiddleware
node_entrycontroller -->|"validates payloads"| node_validation
node_entrycontroller -->|"calculates ranges"| node_domaincalc
node_entrycontroller -->|"creates and queries"| node_stepsrecord
node_entrycontroller -->|"creates and queries"| node_waterrecord
node_dashboardroutes -.->|"dispatches"| node_dashboardcontroller
node_dashboardcontroller -->|"reads entries"| node_stepsrecord
node_dashboardcontroller -->|"reads entries"| node_waterrecord
node_dashboardcontroller -->|"reads settings"| node_settingsrecord
node_dashboardcontroller -->|"reads goals"| node_goalrecord
node_dashboardcontroller -->|"derives metrics"| node_domaincalc
node_settingsroutes -->|"dispatches"| node_settingscontroller
node_settingsroutes -->|"protects endpoints"| node_authmiddleware
node_settingscontroller -.->|"validates updates"| node_validation
node_settingscontroller -.->|"reads and updates"| node_settingsrecord

click node_app "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/App.tsx"
click node_login "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Login.tsx"
click node_dashboard "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Dashboard.tsx"
click node_activity "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/LogActivity.tsx"
click node_walktracker "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/useGpsStepTracker.ts"
click node_journey "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/components/JourneyTrail.tsx"
click node_goals "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Goals.tsx"
click node_workouts "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Workouts.tsx"
click node_settingsui "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Settings.tsx"
click node_clientmetrics "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/calculations.ts"
click node_authstate "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/stores/authStore.ts"
click node_api "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/api.ts"
click node_server "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/auth.js"
click node_authcontroller "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/authController.js"
click node_authmiddleware "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/middleware/auth.js"
click node_entryroutes "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/entries.js"
click node_entrycontroller "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/entriesController.js"
click node_dashboardroutes "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/dashboard.js"
click node_dashboardcontroller "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/dashboardController.js"
click node_settingsroutes "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/settings.js"
click node_settingscontroller "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/settingsController.js"
click node_extrasroutes "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/extras.js"
click node_extrascontroller "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/extrasController.js"
click node_validation "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/utils/validate.js"
click node_domaincalc "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/utils/calculations.js"
click node_dbconfig "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/config/db.js"
click node_adminrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Admin.js"
click node_stepsrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/StepEntry.js"
click node_waterrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/WaterEntry.js"
click node_settingsrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Settings.js"
click node_goalrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Goal.js"
click node_workoutrecord "https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/WorkoutTemplate.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_login,node_dashboard,node_activity,node_journey,node_goals,node_workouts,node_settingsui toneBlue
class node_walktracker,node_clientmetrics,node_authstate,node_api toneAmber
class node_server,node_authroutes,node_authcontroller,node_authmiddleware,node_entryroutes,node_entrycontroller,node_dashboardroutes,node_dashboardcontroller,node_settingsroutes,node_settingscontroller,node_extrasroutes,node_extrascontroller,node_validation,node_domaincalc toneMint
class node_dbconfig,node_adminrecord,node_stepsrecord,node_waterrecord,node_settingsrecord,node_goalrecord,node_workoutrecord toneRose
class node_admin toneIndigo
```

## Components

### Fitness journal

- [Page routing](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Admin login](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Login.tsx): `frontend/src/pages/Login.tsx`
- [Metrics dashboard](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Activity logging](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/LogActivity.tsx): `frontend/src/pages/LogActivity.tsx`
- [Journey badges](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/components/JourneyTrail.tsx): `frontend/src/components/JourneyTrail.tsx`
- [Goals](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Goals.tsx): `frontend/src/pages/Goals.tsx`
- [Workout guide](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Workouts.tsx): `frontend/src/pages/Workouts.tsx`
- [Fitness settings](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/pages/Settings.tsx): `frontend/src/pages/Settings.tsx`

### Client state and API

- [Walk sensing](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/useGpsStepTracker.ts): `frontend/src/utils/useGpsStepTracker.ts`
- [Metric calculations](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/calculations.ts): `frontend/src/utils/calculations.ts`
- [Auth state](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/stores/authStore.ts): `frontend/src/stores/authStore.ts`
- [API client](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/frontend/src/utils/api.ts): `frontend/src/utils/api.ts`

### Backend services

- [HTTP server](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth routes](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Admin authentication](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [JWT protection](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Entry routes](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/entries.js): `backend/src/routes/entries.js`
- [Entry handling](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/entriesController.js): `backend/src/controllers/entriesController.js`
- [Dashboard routes](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/dashboard.js): `backend/src/routes/dashboard.js`
- [Metric aggregation](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/dashboardController.js): `backend/src/controllers/dashboardController.js`
- [Settings routes](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/settings.js): `backend/src/routes/settings.js`
- [Settings handling](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/settingsController.js): `backend/src/controllers/settingsController.js`
- [Goals and workout routes](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/routes/extras.js): `backend/src/routes/extras.js`
- [Goals and workouts](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/controllers/extrasController.js): `backend/src/controllers/extrasController.js`
- [Request validation](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/utils/validate.js): `backend/src/utils/validate.js`
- [Fitness calculations](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/utils/calculations.js): `backend/src/utils/calculations.js`

### MongoDB records

- [Mongo connection](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Admin record](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Admin.js): `backend/src/models/Admin.js`
- [Step entries](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/StepEntry.js): `backend/src/models/StepEntry.js`
- [Water entries](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/WaterEntry.js): `backend/src/models/WaterEntry.js`
- [Settings record](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Settings.js): `backend/src/models/Settings.js`
- [Goal records](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/Goal.js): `backend/src/models/Goal.js`
- [Workout templates](https://github.com/rockeybhai19511-ctrl/fitness-tracker/blob/main/backend/src/models/WorkoutTemplate.js): `backend/src/models/WorkoutTemplate.js`

### Other components

- **Admin**

## Connections

- Admin → Page routing: opens app
- Page routing → Admin login: routes guest (evidence: `frontend/src/App.tsx`)
- Page routing → Metrics dashboard: routes page (evidence: `frontend/src/App.tsx`)
- Page routing → Activity logging: routes page (evidence: `frontend/src/App.tsx`)
- Page routing → Goals: routes page (evidence: `frontend/src/App.tsx`)
- Page routing → Workout guide: routes page (evidence: `frontend/src/App.tsx`)
- Page routing → Fitness settings: routes page (evidence: `frontend/src/App.tsx`)
- Admin login → API client: submits credentials (evidence: `frontend/src/pages/Login.tsx`)
- Admin login → Auth state: stores session (evidence: `frontend/src/pages/Login.tsx`)
- Page routing → Auth state: checks token (evidence: `frontend/src/App.tsx`)
- Activity logging → Walk sensing: tracks walk (evidence: `frontend/src/pages/LogActivity.tsx`)
- Activity logging → API client: sends entries (evidence: `frontend/src/pages/LogActivity.tsx`)
- Activity logging → Journey badges: renders milestones (evidence: `frontend/src/pages/LogActivity.tsx`)
- Activity logging → Metric calculations: uses date helper (evidence: `frontend/src/pages/LogActivity.tsx`)
- Metrics dashboard → API client: loads metrics (evidence: `frontend/src/pages/Dashboard.tsx`)
- Metrics dashboard → Metric calculations: uses calculations (evidence: `frontend/src/pages/Dashboard.tsx`)
- Goals → API client: manages goals (evidence: `frontend/src/pages/Goals.tsx`)
- Workout guide → API client: loads templates (evidence: `frontend/src/pages/Workouts.tsx`)
- Workout guide → Metric calculations: estimates energy (evidence: `frontend/src/pages/Workouts.tsx`)
- Fitness settings → API client: loads settings
- API client → Auth state: reads token (evidence: `frontend/src/utils/api.ts`)
- API client → HTTP server: sends API requests
- HTTP server → Mongo connection: connects database (evidence: `backend/src/server.js`)
- HTTP server → Auth routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Dashboard routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Entry routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Settings routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Goals and workout routes: mounts routes (evidence: `backend/src/server.js`)
- Auth routes → Admin authentication: dispatches (evidence: `backend/src/routes/auth.js`)
- Auth routes → JWT protection: protects endpoint (evidence: `backend/src/routes/auth.js`)
- Admin authentication → Admin record: looks up admin (evidence: `backend/src/controllers/authController.js`)
- Admin authentication → Request validation: validates login (evidence: `backend/src/controllers/authController.js`)
- Entry routes → Entry handling: dispatches (evidence: `backend/src/routes/entries.js`)
- Entry routes → JWT protection: protects endpoints (evidence: `backend/src/routes/entries.js`)
- Entry handling → Request validation: validates payloads (evidence: `backend/src/controllers/entriesController.js`)
- Entry handling → Fitness calculations: calculates ranges (evidence: `backend/src/controllers/entriesController.js`)
- Entry handling → Step entries: creates and queries (evidence: `backend/src/controllers/entriesController.js`)
- Entry handling → Water entries: creates and queries (evidence: `backend/src/controllers/entriesController.js`)
- Dashboard routes → Metric aggregation: dispatches
- Metric aggregation → Step entries: reads entries (evidence: `backend/src/controllers/dashboardController.js`)
- Metric aggregation → Water entries: reads entries (evidence: `backend/src/controllers/dashboardController.js`)
- Metric aggregation → Settings record: reads settings (evidence: `backend/src/controllers/dashboardController.js`)
- Metric aggregation → Goal records: reads goals (evidence: `backend/src/controllers/dashboardController.js`)
- Metric aggregation → Fitness calculations: derives metrics (evidence: `backend/src/controllers/dashboardController.js`)
- Settings routes → Settings handling: dispatches (evidence: `backend/src/routes/settings.js`)
- Settings routes → JWT protection: protects endpoints (evidence: `backend/src/routes/settings.js`)
- Settings handling → Request validation: validates updates (evidence: `backend/src/controllers/settingsController.js`)
- Settings handling → Settings record: reads and updates (evidence: `backend/src/controllers/settingsController.js`)
