# baddamakshaya01-star/svasthya architecture

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

- Interactive diagram: https://gitdiagram.com/baddamakshaya01-star/svasthya
- Repository: https://github.com/baddamakshaya01-star/svasthya

## Overview

BlazeX is a heatwave early-warning system: users view ward-level forecasts and thermal-risk indicators in a dashboard, while API clients can submit weather observations for heat-stress evaluation. The backend computes thermal indices, predicts hospitalization risk, and evaluates configured alerts; the frontend fetches the ward forecast from the API. Model training and synthetic-data generation support prediction. The README is empty, so capability descriptions come from the sampled source; forecast-to-model loading details are partly omitted, and the separate frontend/src entry appears to be a starter rather than the dashboard.

Main entry points: [`blazex/api.py`](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/api.py) (Risk endpoints), [`blazex/ml/train_model.py`](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/train_model.py) (Model training), [`blazex/alerts.py`](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/alerts.py) (Alert engine), [`frontend/main.js`](https://github.com/baddamakshaya01-star/svasthya/blob/main/frontend/main.js) (Risk dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Dashboard"]
  node_dashboard["Risk dashboard<br/>[main.js]"]
  node_starter["Starter counter<br/>[counter.js]"]
end

subgraph group_service["Risk API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_api["Risk endpoints<br/>[api.py]"]
  node_calculators["Thermal calculators<br/>[calculators.py]"]
end

subgraph group_prediction["Risk Modeling"]
  node_riskmodel["Risk model<br/>[risk_model.joblib]"]
  node_training["Model training<br/>[train_model.py]"]
  node_simulator["Synthetic data<br/>[data_simulator.py]"]
  node_history["Historical data"]
end

subgraph group_alerting["Alerts"]
  node_alertengine["Alert engine<br/>[alerts.py]"]
  node_alertdb[("Alert rule and log store<br/>[alerts.py]")]
end

node_user(("Dashboard user"))
node_twilio["Twilio SMS"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"fetches forecasts"| node_api
node_app -->|"registers router"| node_api
node_api -->|"calculates indices"| node_calculators
node_api -.->|"predicts risk"| node_riskmodel
node_api -->|"evaluates alerts"| node_alertengine
node_alertengine -->|"reads and writes"| node_alertdb
node_alertengine -->|"sends SMS"| node_twilio
node_training -->|"generates missing data"| node_simulator
node_simulator -->|"computes indices"| node_calculators
node_training -->|"reads training data"| node_history
node_training -->|"saves model"| node_riskmodel

click node_dashboard "https://github.com/baddamakshaya01-star/svasthya/blob/main/frontend/main.js"
click node_starter "https://github.com/baddamakshaya01-star/svasthya/blob/main/frontend/src/counter.js"
click node_app "https://github.com/baddamakshaya01-star/svasthya/blob/main/main.py"
click node_api "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/api.py"
click node_calculators "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/calculators.py"
click node_riskmodel "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/models/risk_model.joblib"
click node_training "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/train_model.py"
click node_simulator "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/data_simulator.py"
click node_history "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/historical_data.csv"
click node_alertengine "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/alerts.py"
click node_alertdb "https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/alerts.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,node_starter,node_user toneBlue
class node_app,node_api,node_calculators toneAmber
class node_riskmodel,node_training,node_simulator,node_history toneMint
class node_alertengine,node_alertdb toneRose
class node_twilio toneIndigo
```

## Components

### Dashboard

- [Risk dashboard](https://github.com/baddamakshaya01-star/svasthya/blob/main/frontend/main.js): `frontend/main.js`
- [Starter counter](https://github.com/baddamakshaya01-star/svasthya/blob/main/frontend/src/counter.js): `frontend/src/counter.js`

### Risk API

- [FastAPI application](https://github.com/baddamakshaya01-star/svasthya/blob/main/main.py): `main.py`
- [Risk endpoints](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/api.py): `blazex/api.py`
- [Thermal calculators](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/calculators.py): `blazex/calculators.py`

### Risk Modeling

- [Risk model](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/models/risk_model.joblib): `blazex/ml/models/risk_model.joblib`
- [Model training](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/train_model.py): `blazex/ml/train_model.py`
- [Synthetic data](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/data_simulator.py): `blazex/ml/data_simulator.py`
- [Historical data](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/ml/historical_data.csv): `blazex/ml/historical_data.csv`

### Alerts

- [Alert engine](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/alerts.py): `blazex/alerts.py`
- [Alert rule and log store](https://github.com/baddamakshaya01-star/svasthya/blob/main/blazex/alerts.py): `blazex/alerts.py`

### Other components

- **Dashboard user**
- **Twilio SMS**

## Connections

- Dashboard user → Risk dashboard: uses
- Risk dashboard → Risk endpoints: fetches forecasts (evidence: `frontend/main.js`)
- FastAPI application → Risk endpoints: registers router (evidence: `main.py`)
- Risk endpoints → Thermal calculators: calculates indices (evidence: `blazex/api.py`)
- Risk endpoints → Risk model: predicts risk
- Risk endpoints → Alert engine: evaluates alerts (evidence: `blazex/api.py`)
- Alert engine → Alert rule and log store: reads and writes (evidence: `blazex/alerts.py`)
- Alert engine → Twilio SMS: sends SMS (evidence: `blazex/alerts.py`)
- Model training → Synthetic data: generates missing data (evidence: `blazex/ml/train_model.py`)
- Synthetic data → Thermal calculators: computes indices (evidence: `blazex/ml/data_simulator.py`)
- Model training → Historical data: reads training data (evidence: `blazex/ml/train_model.py`)
- Model training → Risk model: saves model (evidence: `blazex/ml/train_model.py`)
