# gyanu-2000/diabetes-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/gyanu-2000/diabetes-prediction
- Repository: https://github.com/gyanu-2000/diabetes-prediction

## Overview

DiaPredict is a Flask diabetes-risk prediction app with a browser UI, a validated prediction endpoint, and an optional Anthropic health-insight proxy. The core workflow accepts four patient measurements, applies a LogisticRegression model trained from the CSV dataset (or loaded from a saved artifact), and returns a classification and probability. The graph follows the documented routes and inspected Python code; the template’s internal behavior was not sampled, so no frontend-to-endpoint call is asserted.

Main entry points: [`app.py`](https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py) (Prediction endpoint), [`model.py`](https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py) (Model loader), [`templates/diabetes_predictor.html`](https://github.com/gyanu-2000/diabetes-prediction/blob/main/templates/diabetes_predictor.html) (Predictor page), [`diabetes.csv`](https://github.com/gyanu-2000/diabetes-prediction/blob/main/diabetes.csv) (Diabetes dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask application<br/>[app.py]"]
  node_page["Predictor page"]
  node_insight_route["Insight proxy<br/>[app.py]"]
end

subgraph group_prediction["Risk prediction"]
  node_predict_route["Prediction endpoint<br/>[app.py]"]
  node_validation["Input validation<br/>[app.py]"]
  node_predict["Risk prediction<br/>[model.py]"]
end

subgraph group_model["Model lifecycle"]
  node_loader["Model loader<br/>[model.py]"]
  node_training["Model training<br/>[model.py]"]
  node_dataset["Diabetes dataset<br/>[diabetes.csv]"]
  node_artifact["Saved model artifact<br/>[model.py]"]
end

node_browser(("Browser user"))
node_anthropic["Anthropic API"]

node_browser -->|"requests pages"| node_flask
node_flask -->|"renders"| node_page
node_browser -->|"submits measurements"| node_predict_route
node_predict_route -->|"validates"| node_validation
node_predict_route -->|"requests prediction"| node_predict
node_predict -->|"returns result"| node_predict_route
node_flask -->|"loads at startup"| node_loader
node_loader -->|"loads if present"| node_artifact
node_loader -->|"trains if absent"| node_training
node_training -->|"reads"| node_dataset
node_training -->|"saves model"| node_artifact
node_browser -.->|"requests insights"| node_insight_route
node_insight_route -.->|"forwards request"| node_anthropic

click node_flask "https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py"
click node_page "https://github.com/gyanu-2000/diabetes-prediction/blob/main/templates/diabetes_predictor.html"
click node_predict_route "https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py"
click node_validation "https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py"
click node_predict "https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py"
click node_loader "https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py"
click node_training "https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py"
click node_dataset "https://github.com/gyanu-2000/diabetes-prediction/blob/main/diabetes.csv"
click node_artifact "https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py"
click node_insight_route "https://github.com/gyanu-2000/diabetes-prediction/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_flask,node_page,node_insight_route,node_browser toneBlue
class node_predict_route,node_validation,node_predict toneAmber
class node_loader,node_training,node_dataset,node_artifact,node_anthropic toneMint
```

## Components

### Web interface

- [Flask application](https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py): `app.py`
- [Predictor page](https://github.com/gyanu-2000/diabetes-prediction/blob/main/templates/diabetes_predictor.html): `templates/diabetes_predictor.html`
- [Insight proxy](https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py): `app.py`

### Risk prediction

- [Prediction endpoint](https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py): `app.py`
- [Input validation](https://github.com/gyanu-2000/diabetes-prediction/blob/main/app.py): `app.py`
- [Risk prediction](https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py): `model.py`

### Model lifecycle

- [Model loader](https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py): `model.py`
- [Model training](https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py): `model.py`
- [Diabetes dataset](https://github.com/gyanu-2000/diabetes-prediction/blob/main/diabetes.csv): `diabetes.csv`
- [Saved model artifact](https://github.com/gyanu-2000/diabetes-prediction/blob/main/model.py): `model.py`

### Other components

- **Browser user**
- **Anthropic API**

## Connections

- Browser user → Flask application: requests pages
- Flask application → Predictor page: renders
- Browser user → Prediction endpoint: submits measurements
- Prediction endpoint → Input validation: validates
- Prediction endpoint → Risk prediction: requests prediction
- Risk prediction → Prediction endpoint: returns result
- Flask application → Model loader: loads at startup
- Model loader → Saved model artifact: loads if present
- Model loader → Model training: trains if absent
- Model training → Diabetes dataset: reads
- Model training → Saved model artifact: saves model
- Browser user → Insight proxy: requests insights
- Insight proxy → Anthropic API: forwards request
