# anishadhikari7/arogya_saathi architecture

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

- Interactive diagram: https://gitdiagram.com/anishadhikari7/arogya_saathi
- Repository: https://github.com/anishadhikari7/arogya_saathi

## Overview

Arogya Saathi is a symptom-based health information app: users create an account or log in, choose symptoms, receive ranked condition predictions with severity and precautions, and can review prediction history. The Node backend owns authentication, protected prediction requests, and persistence; it delegates inference to a Flask service. The frontend also provides password recovery and dashboard flows. Training code and supplied datasets support model creation. Some frontend modules and the database schema were not excerpted, so their internal behavior and unshown connections are represented conservatively.

Main entry points: [`backend/routes/predict.js`](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/routes/predict.js) (Prediction and history API), [`frontend/js/symptom-checker.js`](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/symptom-checker.js) (Symptom checker), [`backend/server.js`](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/server.js) (HTTP server), [`backend/config/db.js`](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/db.js) (MySQL connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_authui["Sign-in UI<br/>[auth.js]"]
  node_forgotui["Password recovery UI<br/>[forgot-password.js]"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_checker["Symptom checker<br/>[symptom-checker.js]"]
  node_resultsui["Results view<br/>[results.js]"]
  node_historyui["History view<br/>[history.js]"]
  node_apiclient["API client<br/>[api.js]"]
end

subgraph group_backend["Application backend"]
  node_server["HTTP server<br/>[server.js]"]
  node_authroutes["Account and recovery<br/>[auth.js]"]
  node_predictroutes["Prediction and history API<br/>[predict.js]"]
  node_jwt["JWT verification<br/>[auth.js]"]
  node_mysqlpool["MySQL connection<br/>[db.js]"]
end

subgraph group_ml["Prediction service"]
  node_mlapi["Flask inference API<br/>[app.py]"]
  node_modeldata[("Model artifacts")]
end

subgraph group_data["Persistent data"]
  node_usersdb[("User records<br/>[schema.sql]")]
  node_historydb[("Prediction records<br/>[schema.sql]")]
end

subgraph group_training["Model preparation"]
  node_training["Model training<br/>[train_model.py]"]
  node_datasets[("Training datasets")]
end

node_patient(("User"))
node_email["Email provider"]

node_patient -->|"uses"| node_authui
node_authui -->|"submits login"| node_server
node_server -->|"mounts routes"| node_authroutes
node_authroutes -->|"queries users"| node_mysqlpool
node_mysqlpool -.->|"reads/writes"| node_usersdb
node_forgotui -.->|"requests recovery"| node_server
node_authroutes -->|"sends OTP"| node_email
node_patient -->|"selects symptoms"| node_checker
node_checker -->|"calls helper"| node_apiclient
node_checker -->|"requests predictions"| node_predictroutes
node_server -->|"mounts routes"| node_predictroutes
node_predictroutes -->|"checks token"| node_jwt
node_predictroutes -->|"forwards symptoms"| node_mlapi
node_mlapi -->|"loads artifacts"| node_modeldata
node_mlapi -->|"returns predictions"| node_predictroutes
node_predictroutes -->|"stores and reads"| node_mysqlpool
node_mysqlpool -.->|"reads/writes"| node_historydb
node_checker -->|"shares result"| node_resultsui
node_patient -->|"views results"| node_resultsui
node_patient -->|"views history"| node_historyui
node_historyui -->|"calls helper"| node_apiclient
node_historyui -.->|"requests history"| node_predictroutes
node_patient -.->|"opens dashboard"| node_dashboard
node_datasets -.->|"provides data"| node_training
node_training -->|"writes artifacts"| node_modeldata

click node_authui "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/auth.js"
click node_forgotui "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/forgot-password.js"
click node_dashboard "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/dashboard.js"
click node_checker "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/symptom-checker.js"
click node_resultsui "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/results.js"
click node_historyui "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/history.js"
click node_apiclient "https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/api.js"
click node_server "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/server.js"
click node_authroutes "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/routes/auth.js"
click node_predictroutes "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/routes/predict.js"
click node_jwt "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/middleware/auth.js"
click node_mysqlpool "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/db.js"
click node_usersdb "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/schema.sql"
click node_historydb "https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/schema.sql"
click node_mlapi "https://github.com/anishadhikari7/arogya_saathi/blob/main/ml-service/app.py"
click node_modeldata "https://github.com/anishadhikari7/arogya_saathi/tree/main/ml-service/model"
click node_training "https://github.com/anishadhikari7/arogya_saathi/blob/main/ml-service/train_model.py"
click node_datasets "https://github.com/anishadhikari7/arogya_saathi/tree/main/ml-service/data"

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_authui,node_forgotui,node_dashboard,node_checker,node_resultsui,node_historyui,node_apiclient,node_patient toneBlue
class node_server,node_authroutes,node_predictroutes,node_jwt,node_mysqlpool toneAmber
class node_mlapi,node_modeldata toneMint
class node_usersdb,node_historydb toneRose
class node_training,node_datasets,node_email toneIndigo
```

## Components

### Web experience

- [Sign-in UI](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/auth.js): `frontend/js/auth.js`
- [Password recovery UI](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/forgot-password.js): `frontend/js/forgot-password.js`
- [Dashboard](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/dashboard.js): `frontend/js/dashboard.js`
- [Symptom checker](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/symptom-checker.js): `frontend/js/symptom-checker.js`
- [Results view](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/results.js): `frontend/js/results.js`
- [History view](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/history.js): `frontend/js/history.js`
- [API client](https://github.com/anishadhikari7/arogya_saathi/blob/main/frontend/js/api.js): `frontend/js/api.js`

### Application backend

- [HTTP server](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/server.js): `backend/server.js`
- [Account and recovery](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Prediction and history API](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/routes/predict.js): `backend/routes/predict.js`
- [JWT verification](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [MySQL connection](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/db.js): `backend/config/db.js`

### Prediction service

- [Flask inference API](https://github.com/anishadhikari7/arogya_saathi/blob/main/ml-service/app.py): `ml-service/app.py`
- [Model artifacts](https://github.com/anishadhikari7/arogya_saathi/tree/main/ml-service/model): `ml-service/model`

### Persistent data

- [User records](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/schema.sql): `backend/config/schema.sql`
- [Prediction records](https://github.com/anishadhikari7/arogya_saathi/blob/main/backend/config/schema.sql): `backend/config/schema.sql`

### Model preparation

- [Model training](https://github.com/anishadhikari7/arogya_saathi/blob/main/ml-service/train_model.py): `ml-service/train_model.py`
- [Training datasets](https://github.com/anishadhikari7/arogya_saathi/tree/main/ml-service/data): `ml-service/data`

### Other components

- **User**
- **Email provider**

## Connections

- User → Sign-in UI: uses (evidence: `frontend/js/auth.js`)
- Sign-in UI → HTTP server: submits login (evidence: `frontend/js/auth.js`)
- HTTP server → Account and recovery: mounts routes (evidence: `backend/server.js`)
- Account and recovery → MySQL connection: queries users (evidence: `backend/routes/auth.js`)
- MySQL connection → User records: reads/writes
- Password recovery UI → HTTP server: requests recovery
- Account and recovery → Email provider: sends OTP (evidence: `backend/routes/auth.js`)
- User → Symptom checker: selects symptoms (evidence: `frontend/js/symptom-checker.js`)
- Symptom checker → API client: calls helper (evidence: `frontend/js/symptom-checker.js`)
- Symptom checker → Prediction and history API: requests predictions (evidence: `frontend/js/symptom-checker.js`)
- HTTP server → Prediction and history API: mounts routes (evidence: `backend/server.js`)
- Prediction and history API → JWT verification: checks token (evidence: `backend/routes/predict.js`)
- Prediction and history API → Flask inference API: forwards symptoms (evidence: `backend/routes/predict.js`)
- Flask inference API → Model artifacts: loads artifacts (evidence: `ml-service/app.py`)
- Flask inference API → Prediction and history API: returns predictions (evidence: `backend/routes/predict.js`)
- Prediction and history API → MySQL connection: stores and reads (evidence: `backend/routes/predict.js`)
- MySQL connection → Prediction records: reads/writes
- Symptom checker → Results view: shares result (evidence: `frontend/js/symptom-checker.js`)
- User → Results view: views results (evidence: `frontend/js/results.js`)
- User → History view: views history (evidence: `frontend/js/history.js`)
- History view → API client: calls helper (evidence: `frontend/js/history.js`)
- History view → Prediction and history API: requests history
- User → Dashboard: opens dashboard
- Training datasets → Model training: provides data
- Model training → Model artifacts: writes artifacts (evidence: `ml-service/train_model.py`)
