# ishansharma1811/healthcare-prediction-system architecture

> Architecture diagram of the GitHub repository ishansharma1811/healthcare-prediction-system, 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/ishansharma1811/healthcare-prediction-system
- Repository: https://github.com/ishansharma1811/healthcare-prediction-system

## Overview

This is a Flask diabetes-risk prediction application with a separate model-training workflow. Patients submit clinical measurements through the web interface; the Flask endpoint scales inputs, predicts risk, and returns a score and recommendations for display. Training reads the diabetes dataset, preprocesses and tunes a Random Forest, evaluates it, and saves model artifacts used by the application. The main runtime and training files were excerpted; other interface and artifact relationships follow README documentation or explicit references in those excerpts.

Main entry points: [`app.py`](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py) (Flask routes), [`train_model.py`](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py) (Preprocessing), [`templates/index.html`](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/templates/index.html) (Prediction form), [`static/js/main.js`](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/static/js/main.js) (Form and results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_preparation["Preprocessing<br/>[train_model.py]"]
  node_model_training["Model tuning<br/>[train_model.py]"]
  node_evaluation["Model evaluation<br/>[train_model.py]"]
end

subgraph group_serving["Prediction service"]
  node_flask_routes["Flask routes<br/>[app.py]"]
  node_inference["Risk prediction<br/>[app.py]"]
  node_recommendations["Health recommendations<br/>[app.py]"]
end

subgraph group_interface["User interface"]
  node_web_page["Prediction form<br/>[index.html]"]
  node_browser_logic["Form and results<br/>[main.js]"]
end

subgraph group_assets["Data and artifacts"]
  node_training_data["Diabetes dataset<br/>[diabetes.csv]"]
  node_trained_model["Classifier"]
  node_scaler["Feature scaler<br/>[scaler.pkl]"]
end

node_patient(("Patient"))
node_api_client(("API client"))

node_training_data -->|"loads data"| node_preparation
node_preparation -->|"prepares features"| node_model_training
node_model_training -->|"evaluates model"| node_evaluation
node_model_training -->|"saves classifier"| node_trained_model
node_preparation -->|"saves scaler"| node_scaler
node_patient -->|"enters measurements"| node_web_page
node_web_page -.->|"uses scripts"| node_browser_logic
node_browser_logic -->|"posts prediction"| node_flask_routes
node_api_client -->|"posts prediction"| node_flask_routes
node_flask_routes -->|"renders page"| node_web_page
node_flask_routes -->|"processes inputs"| node_inference
node_inference -->|"loads scaler"| node_scaler
node_inference -->|"loads model"| node_trained_model
node_inference -->|"generates guidance"| node_recommendations
node_flask_routes -->|"returns results"| node_browser_logic

click node_training_data "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/data/diabetes.csv"
click node_preparation "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py"
click node_model_training "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py"
click node_evaluation "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py"
click node_trained_model "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/model/healthcare_model.pkl"
click node_scaler "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/model/scaler.pkl"
click node_web_page "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/templates/index.html"
click node_browser_logic "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/static/js/main.js"
click node_flask_routes "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py"
click node_inference "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py"
click node_recommendations "https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.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_preparation,node_model_training,node_evaluation,node_api_client toneBlue
class node_flask_routes,node_inference,node_recommendations toneAmber
class node_web_page,node_browser_logic toneMint
class node_training_data,node_trained_model,node_scaler toneRose
class node_patient toneIndigo
```

## Components

### Model training

- [Preprocessing](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py): `train_model.py`
- [Model tuning](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py): `train_model.py`
- [Model evaluation](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/train_model.py): `train_model.py`

### Prediction service

- [Flask routes](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py): `app.py`
- [Risk prediction](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py): `app.py`
- [Health recommendations](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/app.py): `app.py`

### User interface

- [Prediction form](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/templates/index.html): `templates/index.html`
- [Form and results](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/static/js/main.js): `static/js/main.js`

### Data and artifacts

- [Diabetes dataset](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/data/diabetes.csv): `data/diabetes.csv`
- [Classifier](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/model/healthcare_model.pkl): `model/healthcare_model.pkl`
- [Feature scaler](https://github.com/ishansharma1811/healthcare-prediction-system/blob/main/model/scaler.pkl): `model/scaler.pkl`

### Other components

- **Patient**
- **API client**

## Connections

- Diabetes dataset → Preprocessing: loads data (evidence: `train_model.py`)
- Preprocessing → Model tuning: prepares features (evidence: `train_model.py`)
- Model tuning → Model evaluation: evaluates model (evidence: `train_model.py`)
- Model tuning → Classifier: saves classifier (evidence: `train_model.py`)
- Preprocessing → Feature scaler: saves scaler (evidence: `train_model.py`)
- Patient → Prediction form: enters measurements (evidence: `README.md`)
- Prediction form → Form and results: uses scripts
- Form and results → Flask routes: posts prediction (evidence: `static/js/main.js`)
- API client → Flask routes: posts prediction (evidence: `README.md`)
- Flask routes → Prediction form: renders page (evidence: `app.py`)
- Flask routes → Risk prediction: processes inputs (evidence: `app.py`)
- Risk prediction → Feature scaler: loads scaler (evidence: `app.py`)
- Risk prediction → Classifier: loads model (evidence: `app.py`)
- Risk prediction → Health recommendations: generates guidance (evidence: `app.py`)
- Flask routes → Form and results: returns results (evidence: `static/js/main.js`)
