# isaac-y67/ai-disease-detection architecture

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

- Interactive diagram: https://gitdiagram.com/isaac-y67/ai-disease-detection
- Repository: https://github.com/isaac-y67/ai-disease-detection

## Overview

This is a Flask-based clinical decision-support web app for predicting indicators and risk for heart disease, diabetes, hypertension, and lung cancer. A user submits a disease-specific form; browser JavaScript sends its fields to Flask, which scales them, runs a loaded model, classifies risk, and returns a result for display. The repository also contains raw and processed data and training notebooks. The README lists MySQL, but the sampled backend does not show it participating in predictions; unsampled training details are therefore represented without asserting specific calls.

Main entry points: [`frontend/static/js/script.js`](https://github.com/isaac-y67/ai-disease-detection/blob/main/frontend/static/js/script.js) (Form submission UI), [`backend/app/main.py`](https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py) (Flask routes), [`frontend/templates`](https://github.com/isaac-y67/ai-disease-detection/tree/main/frontend/templates) (Disease pages), [`ml/scripts/clean_data.py`](https://github.com/isaac-y67/ai-disease-detection/blob/main/ml/scripts/clean_data.py) (Data cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_pages["Disease pages"]
  node_browser["Form submission UI<br/>[script.js]"]
  node_styles["Page styling<br/>[style.css]"]
end

subgraph group_prediction["Prediction runtime"]
  node_flask["Flask routes<br/>[main.py]"]
  node_predict["Prediction pipeline<br/>[main.py]"]
  node_response["Risk result<br/>[main.py]"]
end

subgraph group_ml["ML assets and data"]
  node_raw["Raw datasets"]
  node_cleaner["Data cleaning<br/>[clean_data.py]"]
  node_processed["Processed datasets"]
  node_training["Disease training"]
  node_models["Models and scalers"]
end

subgraph group_database["Database utilities"]
  node_dbscripts["Database utilities"]
end

node_user(("Patient or clinician"))
node_mysql[("MySQL database")]

node_user -->|"opens"| node_pages
node_pages -->|"provides forms"| node_browser
node_browser -->|"posts fields"| node_flask
node_flask -->|"renders"| node_pages
node_flask -->|"dispatches"| node_predict
node_predict -->|"loads and uses"| node_models
node_predict -->|"returns prediction"| node_response
node_browser -->|"displays result"| node_response
node_raw -->|"reads data"| node_cleaner
node_cleaner -->|"writes data"| node_processed
node_processed -.->|"training input"| node_training
node_training -.->|"produces assets"| node_models
node_dbscripts -->|"queries or provisions"| node_mysql

click node_pages "https://github.com/isaac-y67/ai-disease-detection/tree/main/frontend/templates"
click node_browser "https://github.com/isaac-y67/ai-disease-detection/blob/main/frontend/static/js/script.js"
click node_styles "https://github.com/isaac-y67/ai-disease-detection/blob/main/frontend/static/css/style.css"
click node_flask "https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py"
click node_predict "https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py"
click node_response "https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py"
click node_raw "https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/data/raw"
click node_cleaner "https://github.com/isaac-y67/ai-disease-detection/blob/main/ml/scripts/clean_data.py"
click node_processed "https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/data/processed"
click node_training "https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/notebooks"
click node_models "https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/saved_models"
click node_dbscripts "https://github.com/isaac-y67/ai-disease-detection/tree/main/database"

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_pages,node_browser,node_styles toneBlue
class node_flask,node_predict,node_response,node_mysql toneAmber
class node_raw,node_cleaner,node_processed,node_training,node_models toneMint
class node_dbscripts toneRose
class node_user toneIndigo
```

## Components

### Web experience

- [Disease pages](https://github.com/isaac-y67/ai-disease-detection/tree/main/frontend/templates): `frontend/templates`
- [Form submission UI](https://github.com/isaac-y67/ai-disease-detection/blob/main/frontend/static/js/script.js): `frontend/static/js/script.js`
- [Page styling](https://github.com/isaac-y67/ai-disease-detection/blob/main/frontend/static/css/style.css): `frontend/static/css/style.css`

### Prediction runtime

- [Flask routes](https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prediction pipeline](https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py): `backend/app/main.py`
- [Risk result](https://github.com/isaac-y67/ai-disease-detection/blob/main/backend/app/main.py): `backend/app/main.py`

### ML assets and data

- [Raw datasets](https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/data/raw): `ml/data/raw`
- [Data cleaning](https://github.com/isaac-y67/ai-disease-detection/blob/main/ml/scripts/clean_data.py): `ml/scripts/clean_data.py`
- [Processed datasets](https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/data/processed): `ml/data/processed`
- [Disease training](https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/notebooks): `ml/notebooks`
- [Models and scalers](https://github.com/isaac-y67/ai-disease-detection/tree/main/ml/saved_models): `ml/saved_models`

### Database utilities

- [Database utilities](https://github.com/isaac-y67/ai-disease-detection/tree/main/database): `database`

### Other components

- **Patient or clinician**
- **MySQL database**

## Connections

- Patient or clinician → Disease pages: opens
- Disease pages → Form submission UI: provides forms (evidence: `frontend/static/js/script.js`)
- Form submission UI → Flask routes: posts fields (evidence: `frontend/static/js/script.js`)
- Flask routes → Disease pages: renders (evidence: `backend/app/main.py`)
- Flask routes → Prediction pipeline: dispatches (evidence: `backend/app/main.py`)
- Prediction pipeline → Models and scalers: loads and uses (evidence: `backend/app/main.py`)
- Prediction pipeline → Risk result: returns prediction (evidence: `backend/app/main.py`)
- Form submission UI → Risk result: displays result (evidence: `frontend/static/js/script.js`)
- Raw datasets → Data cleaning: reads data (evidence: `ml/scripts/clean_data.py`)
- Data cleaning → Processed datasets: writes data (evidence: `ml/scripts/clean_data.py`)
- Processed datasets → Disease training: training input
- Disease training → Models and scalers: produces assets
- Database utilities → MySQL database: queries or provisions (evidence: `database/create_admin.py`)
