# krishjain-2301/ai_health_project architecture

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

- Interactive diagram: https://gitdiagram.com/krishjain-2301/ai_health_project
- Repository: https://github.com/krishjain-2301/ai_health_project

## Overview

HealthAI is a patient-health dashboard with clinician/patient chat and health-trajectory risk predictions. Users select a patient; the dashboard requests patient history and metrics, displays activity, sleep, heart-rate and intensity charts, and requests predictions from the recent data. Chat requests use the selected patient’s merged health record to produce role-specific guidance. The CSV collection supplies the merged data; predictions use either the CNN or optional TinyML inference path. Connections reflect shown calls and router registration; no README was provided, and unsampled modules are represented only where the source index or tree supports them.

Main entry points: [`client/src/App.tsx`](https://github.com/krishjain-2301/ai_health_project/blob/main/client/src/App.tsx) (Health Dashboard), [`server/api/ml_routes.py`](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/ml_routes.py) (Prediction API), [`server/api/dataset_merger.py`](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/dataset_merger.py) (Dataset Merger), [`server/main.py`](https://github.com/krishjain-2301/ai_health_project/blob/main/server/main.py) (FastAPI App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Health Dashboard<br/>[App.tsx]"]
end

subgraph group_api["API Services"]
  node_api_app["FastAPI App<br/>[main.py]"]
  node_data_api["Patient Data API<br/>[data_routes.py]"]
  node_chat_api["Health Chat API<br/>[chat_routes.py]"]
  node_prediction_api["Prediction API<br/>[ml_routes.py]"]
end

subgraph group_data["Health Data"]
  node_merged_data["Dataset Merger<br/>[dataset_merger.py]"]
  node_fitabase[("Fitabase CSVs")]
end

subgraph group_models["Risk Models"]
  node_cnn["CNN Trajectory Model<br/>[cnn_model.py]"]
  node_tinyml["TinyML Inference<br/>[tinyml_model.py]"]
end

node_users(("Clinician / Patient"))

node_users -->|"use dashboard"| node_dashboard
node_dashboard -->|"request patient data"| node_data_api
node_dashboard -->|"request prediction"| node_prediction_api
node_dashboard -->|"send chat"| node_chat_api
node_api_app -->|"registers router"| node_data_api
node_api_app -->|"registers router"| node_chat_api
node_api_app -->|"registers router"| node_prediction_api
node_data_api -->|"loads merged data"| node_merged_data
node_chat_api -->|"loads merged data"| node_merged_data
node_prediction_api -->|"runs CNN prediction"| node_cnn
node_prediction_api -->|"runs TinyML prediction"| node_tinyml
node_cnn -->|"prepares training data"| node_merged_data
node_tinyml -->|"gets Keras model"| node_cnn
node_merged_data -->|"reads CSV files"| node_fitabase

click node_dashboard "https://github.com/krishjain-2301/ai_health_project/blob/main/client/src/App.tsx"
click node_api_app "https://github.com/krishjain-2301/ai_health_project/blob/main/server/main.py"
click node_data_api "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/data_routes.py"
click node_chat_api "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/chat_routes.py"
click node_prediction_api "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/ml_routes.py"
click node_merged_data "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/dataset_merger.py"
click node_fitabase "https://github.com/krishjain-2301/ai_health_project/tree/main/Fitabase%20Data%204.12.16-5.12.16"
click node_cnn "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/cnn_model.py"
click node_tinyml "https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/tinyml_model.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_dashboard toneBlue
class node_api_app,node_data_api,node_chat_api,node_prediction_api toneAmber
class node_merged_data,node_fitabase toneMint
class node_cnn,node_tinyml toneRose
class node_users toneIndigo
```

## Components

### Dashboard

- [Health Dashboard](https://github.com/krishjain-2301/ai_health_project/blob/main/client/src/App.tsx): `client/src/App.tsx`

### API Services

- [FastAPI App](https://github.com/krishjain-2301/ai_health_project/blob/main/server/main.py): `server/main.py`
- [Patient Data API](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/data_routes.py): `server/api/data_routes.py`
- [Health Chat API](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/chat_routes.py): `server/api/chat_routes.py`
- [Prediction API](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/ml_routes.py): `server/api/ml_routes.py`

### Health Data

- [Dataset Merger](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/dataset_merger.py): `server/api/dataset_merger.py`
- [Fitabase CSVs](https://github.com/krishjain-2301/ai_health_project/tree/main/Fitabase%20Data%204.12.16-5.12.16): `Fitabase Data 4.12.16-5.12.16`

### Risk Models

- [CNN Trajectory Model](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/cnn_model.py): `server/api/cnn_model.py`
- [TinyML Inference](https://github.com/krishjain-2301/ai_health_project/blob/main/server/api/tinyml_model.py): `server/api/tinyml_model.py`

### Other components

- **Clinician / Patient**

## Connections

- Clinician / Patient → Health Dashboard: use dashboard (evidence: `client/src/App.tsx`)
- Health Dashboard → Patient Data API: request patient data (evidence: `client/src/App.tsx`)
- Health Dashboard → Prediction API: request prediction (evidence: `client/src/App.tsx`)
- Health Dashboard → Health Chat API: send chat (evidence: `client/src/App.tsx`)
- FastAPI App → Patient Data API: registers router (evidence: `server/main.py`)
- FastAPI App → Health Chat API: registers router (evidence: `server/main.py`)
- FastAPI App → Prediction API: registers router (evidence: `server/main.py`)
- Patient Data API → Dataset Merger: loads merged data (evidence: `server/api/data_routes.py`)
- Health Chat API → Dataset Merger: loads merged data (evidence: `server/api/chat_routes.py`)
- Prediction API → CNN Trajectory Model: runs CNN prediction (evidence: `server/api/ml_routes.py`)
- Prediction API → TinyML Inference: runs TinyML prediction (evidence: `server/api/ml_routes.py`)
- CNN Trajectory Model → Dataset Merger: prepares training data (evidence: `server/api/cnn_model.py`)
- TinyML Inference → CNN Trajectory Model: gets Keras model (evidence: `server/api/tinyml_model.py`)
- Dataset Merger → Fitabase CSVs: reads CSV files (evidence: `server/api/dataset_merger.py`)
