# saurav-pandit2005/healthsense-ai architecture

> Architecture diagram of the GitHub repository saurav-pandit2005/healthsense-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saurav-pandit2005/healthsense-ai
- Repository: https://github.com/saurav-pandit2005/healthsense-ai

## Overview

HealthSense AI is a wellness tracking and planning application: users create an account and health profile, record daily measurements, then review dashboard summaries and use risk, fitness, meal, and report features. The React frontend calls the Express API; the API owns authentication and business logic, persists user health data, and proxies diabetes predictions to FastAPI. README documentation supports the proxy and report capabilities; some unsampled frontend and backend modules are represented by their tree paths, with uncertain internal links omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/App.jsx) (Routes and access), [`backend/server.js`](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/server.js) (HTTP API), [`frontend/src/api/client.js`](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/api/client.js) (API client), [`backend/controllers/dashboardController.js`](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/dashboardController.js) (Dashboard summary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Routes and access<br/>[App.jsx]"]
  node_authctx["Session context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_profile_ui["Health profile<br/>[ProfileSetup.jsx]"]
  node_dashboard_ui["Dashboard<br/>[Dashboard.jsx]"]
  node_tracker_ui["Daily tracker<br/>[Tracker.jsx]"]
  node_risk_ui["Risk assessment<br/>[DiseaseRisk.jsx]"]
  node_fitness_ui["Fitness planner<br/>[FitnessPlanner.jsx]"]
  node_meal_ui["Meal planner<br/>[MealPlanner.jsx]"]
  node_report_ui["Health report<br/>[HealthReport.jsx]"]
  node_theme["Theme settings<br/>[ThemeContext.jsx]"]
  node_ui_shared["Shared UI<br/>[Field.jsx]"]
end

subgraph group_api["Express API"]
  node_server["HTTP API<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Account and recovery<br/>[authController.js]"]
  node_auth_guard["JWT authorization<br/>[authMiddleware.js]"]
  node_user_store[("User records<br/>[User.js]")]
end

subgraph group_health["Health features"]
  node_profile_controller["Profile service"]
  node_tracker_controller["Tracker service"]
  node_dashboard_controller["Dashboard summary"]
  node_fitness_controller["Fitness planning"]
  node_meal_controller["Meal planning<br/>[mealController.js]"]
  node_log_store[("Health logs<br/>[HealthLog.js]")]
  node_bmi["BMI calculation<br/>[calculateBMI.js]"]
  node_health_score["Health score"]
  node_fitness_generator["Plan generation"]
  node_meal_generator["Meal generation"]
end

subgraph group_ml["Risk prediction"]
  node_risk_controller["Risk service<br/>[riskController.js]"]
  node_risk_store[("Risk history")]
  node_ml_service["Prediction API<br/>[main.py]"]
  node_ml_schemas["Prediction schemas<br/>[schemas.py]"]
end

node_person(("HealthSense user"))
node_mongo[("MongoDB")]

node_person -->|"uses"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_profile_ui
node_app -->|"routes to"| node_dashboard_ui
node_app -->|"routes to"| node_tracker_ui
node_app -->|"routes to"| node_risk_ui
node_app -->|"routes to"| node_fitness_ui
node_app -->|"routes to"| node_meal_ui
node_app -->|"routes to"| node_report_ui
node_app -->|"provides session"| node_authctx
node_authctx -->|"calls auth"| node_api_client
node_dashboard_ui -->|"fetches summary"| node_api_client
node_tracker_ui -->|"reads and saves"| node_api_client
node_risk_ui -->|"requests prediction"| node_api_client
node_fitness_ui -->|"requests plan"| node_api_client
node_meal_ui -.->|"requests plan"| node_api_client
node_report_ui -->|"loads report data"| node_api_client
node_dashboard_ui -->|"renders"| node_ui_shared
node_dashboard_ui -->|"reads theme"| node_theme
node_api_client -->|"sends API requests"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -.->|"mounts profile routes"| node_profile_controller
node_server -->|"mounts tracker routes"| node_tracker_controller
node_server -->|"mounts dashboard routes"| node_dashboard_controller
node_server -->|"mounts risk routes"| node_risk_controller
node_server -->|"mounts fitness routes"| node_fitness_controller
node_server -->|"mounts meal routes"| node_meal_controller
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects session route"| node_auth_guard
node_auth_controller -->|"reads and updates"| node_user_store
node_auth_guard -->|"loads user"| node_user_store
node_profile_controller -->|"reads and updates"| node_user_store
node_profile_controller -->|"calculates"| node_bmi
node_tracker_controller -->|"reads and writes"| node_log_store
node_dashboard_controller -->|"reads profile"| node_user_store
node_dashboard_controller -->|"reads logs"| node_log_store
node_dashboard_controller -->|"calculates"| node_bmi
node_dashboard_controller -->|"calculates"| node_health_score
node_fitness_controller -->|"generates plan"| node_fitness_generator
node_meal_controller -.->|"generates plan"| node_meal_generator
node_risk_controller -->|"stores history"| node_risk_store
node_risk_controller -->|"proxies prediction"| node_ml_service
node_ml_service -->|"uses schemas"| node_ml_schemas
node_server -.->|"persists application data"| node_mongo

click node_app "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/App.jsx"
click node_authctx "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/api/client.js"
click node_landing "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Landing.jsx"
click node_profile_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/ProfileSetup.jsx"
click node_dashboard_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_tracker_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Tracker.jsx"
click node_risk_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/DiseaseRisk.jsx"
click node_fitness_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/FitnessPlanner.jsx"
click node_meal_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/MealPlanner.jsx"
click node_report_ui "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/HealthReport.jsx"
click node_theme "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/context/ThemeContext.jsx"
click node_ui_shared "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/components/ui/Field.jsx"
click node_server "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/server.js"
click node_auth_routes "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/routes/authRoutes.js"
click node_auth_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/authController.js"
click node_auth_guard "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/middleware/authMiddleware.js"
click node_profile_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/profileController.js"
click node_tracker_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/trackerController.js"
click node_dashboard_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/dashboardController.js"
click node_fitness_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/fitnessController.js"
click node_meal_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/mealController.js"
click node_risk_controller "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/riskController.js"
click node_user_store "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/User.js"
click node_log_store "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/HealthLog.js"
click node_risk_store "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/DiseaseRiskResult.js"
click node_bmi "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/calculateBMI.js"
click node_health_score "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/calculateHealthScore.js"
click node_fitness_generator "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/fitnessPlanGenerator.js"
click node_meal_generator "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/mealPlanGenerator.js"
click node_ml_service "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/ml-service/app/main.py"
click node_ml_schemas "https://github.com/saurav-pandit2005/healthsense-ai/blob/main/ml-service/app/schemas.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_authctx,node_api_client,node_landing,node_profile_ui,node_dashboard_ui,node_tracker_ui,node_risk_ui,node_fitness_ui,node_meal_ui,node_report_ui,node_theme,node_ui_shared,node_person toneBlue
class node_server,node_auth_routes,node_auth_controller,node_auth_guard,node_user_store,node_mongo toneAmber
class node_profile_controller,node_tracker_controller,node_dashboard_controller,node_fitness_controller,node_meal_controller,node_log_store,node_bmi,node_health_score,node_fitness_generator,node_meal_generator toneMint
class node_risk_controller,node_risk_store,node_ml_service,node_ml_schemas toneRose
```

## Components

### Web application

- [Routes and access](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session context](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Landing page](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Health profile](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/ProfileSetup.jsx): `frontend/src/pages/ProfileSetup.jsx`
- [Dashboard](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Daily tracker](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/Tracker.jsx): `frontend/src/pages/Tracker.jsx`
- [Risk assessment](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/DiseaseRisk.jsx): `frontend/src/pages/DiseaseRisk.jsx`
- [Fitness planner](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/FitnessPlanner.jsx): `frontend/src/pages/FitnessPlanner.jsx`
- [Meal planner](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/MealPlanner.jsx): `frontend/src/pages/MealPlanner.jsx`
- [Health report](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/pages/HealthReport.jsx): `frontend/src/pages/HealthReport.jsx`
- [Theme settings](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/context/ThemeContext.jsx): `frontend/src/context/ThemeContext.jsx`
- [Shared UI](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/frontend/src/components/ui/Field.jsx): `frontend/src/components/ui/Field.jsx`

### Express API

- [HTTP API](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Account and recovery](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [JWT authorization](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [User records](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/User.js): `backend/models/User.js`

### Health features

- [Profile service](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/profileController.js): `backend/controllers/profileController.js`
- [Tracker service](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/trackerController.js): `backend/controllers/trackerController.js`
- [Dashboard summary](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/dashboardController.js): `backend/controllers/dashboardController.js`
- [Fitness planning](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/fitnessController.js): `backend/controllers/fitnessController.js`
- [Meal planning](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/mealController.js): `backend/controllers/mealController.js`
- [Health logs](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/HealthLog.js): `backend/models/HealthLog.js`
- [BMI calculation](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/calculateBMI.js): `backend/utils/calculateBMI.js`
- [Health score](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/calculateHealthScore.js): `backend/utils/calculateHealthScore.js`
- [Plan generation](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/fitnessPlanGenerator.js): `backend/utils/fitnessPlanGenerator.js`
- [Meal generation](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/utils/mealPlanGenerator.js): `backend/utils/mealPlanGenerator.js`

### Risk prediction

- [Risk service](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/controllers/riskController.js): `backend/controllers/riskController.js`
- [Risk history](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/backend/models/DiseaseRiskResult.js): `backend/models/DiseaseRiskResult.js`
- [Prediction API](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [Prediction schemas](https://github.com/saurav-pandit2005/healthsense-ai/blob/main/ml-service/app/schemas.py): `ml-service/app/schemas.py`

### Other components

- **HealthSense user**
- **MongoDB**

## Connections

- HealthSense user → Routes and access: uses
- Routes and access → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Health profile: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Daily tracker: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Risk assessment: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Fitness planner: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Meal planner: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Health report: routes to (evidence: `frontend/src/App.jsx`)
- Routes and access → Session context: provides session (evidence: `frontend/src/App.jsx`)
- Session context → API client: calls auth (evidence: `frontend/src/context/AuthContext.jsx`)
- Dashboard → API client: fetches summary (evidence: `frontend/src/pages/Dashboard.jsx`)
- Daily tracker → API client: reads and saves (evidence: `frontend/src/api/client.js`)
- Risk assessment → API client: requests prediction (evidence: `frontend/src/pages/DiseaseRisk.jsx`)
- Fitness planner → API client: requests plan (evidence: `frontend/src/pages/FitnessPlanner.jsx`)
- Meal planner → API client: requests plan
- Health report → API client: loads report data (evidence: `frontend/src/pages/HealthReport.jsx`)
- Dashboard → Shared UI: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Theme settings: reads theme (evidence: `frontend/src/pages/Dashboard.jsx`)
- API client → HTTP API: sends API requests
- HTTP API → Auth routes: mounts (evidence: `backend/server.js`)
- HTTP API → Profile service: mounts profile routes
- HTTP API → Tracker service: mounts tracker routes (evidence: `backend/server.js`)
- HTTP API → Dashboard summary: mounts dashboard routes (evidence: `backend/server.js`)
- HTTP API → Risk service: mounts risk routes (evidence: `backend/server.js`)
- HTTP API → Fitness planning: mounts fitness routes (evidence: `backend/server.js`)
- HTTP API → Meal planning: mounts meal routes (evidence: `backend/server.js`)
- Auth routes → Account and recovery: dispatches (evidence: `backend/routes/authRoutes.js`)
- Auth routes → JWT authorization: protects session route (evidence: `backend/routes/authRoutes.js`)
- Account and recovery → User records: reads and updates (evidence: `backend/controllers/authController.js`)
- JWT authorization → User records: loads user (evidence: `backend/middleware/authMiddleware.js`)
- Profile service → User records: reads and updates (evidence: `backend/controllers/profileController.js`)
- Profile service → BMI calculation: calculates (evidence: `backend/controllers/profileController.js`)
- Tracker service → Health logs: reads and writes (evidence: `backend/controllers/trackerController.js`)
- Dashboard summary → User records: reads profile (evidence: `backend/controllers/dashboardController.js`)
- Dashboard summary → Health logs: reads logs (evidence: `backend/controllers/dashboardController.js`)
- Dashboard summary → BMI calculation: calculates (evidence: `backend/controllers/dashboardController.js`)
- Dashboard summary → Health score: calculates (evidence: `backend/controllers/dashboardController.js`)
- Fitness planning → Plan generation: generates plan (evidence: `backend/controllers/fitnessController.js`)
- Meal planning → Meal generation: generates plan
- Risk service → Risk history: stores history (evidence: `backend/controllers/riskController.js`)
- Risk service → Prediction API: proxies prediction
- Prediction API → Prediction schemas: uses schemas (evidence: `ml-service/app/main.py`)
- HTTP API → MongoDB: persists application data
