# guptamanvi1106/-diabetes-prediction-system architecture

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

- Interactive diagram: https://gitdiagram.com/guptamanvi1106/-diabetes-prediction-system
- Repository: https://github.com/guptamanvi1106/-diabetes-prediction-system

## Overview

This is a Flask-based diabetes-risk prediction application. Its main workflow takes patient measurements from a browser or API client, validates them, runs single or CSV-batch predictions, and returns labels with confidence scores; batch results can also be downloaded as CSV. Model training is a separate lifecycle that reads the PIMA dataset and saves the SVM and scaler used at runtime. README-described browser capabilities are represented at the existing `index.html` path, but its implementation was not sampled, so the UI-to-API relationship is documented rather than source-verified.

Main entry points: [`backend/app.py`](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py) (Flask endpoints), [`backend/utils.py`](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py) (Model loading), [`backend/train_model.py`](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/train_model.py) (Model training), [`index.html`](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/index.html) (Prediction interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_browser["Prediction interface<br/>[index.html]"]
end

subgraph group_api["Prediction API"]
  node_flask_api["Flask endpoints<br/>[app.py]"]
  node_validation["Input validation<br/>[utils.py]"]
  node_single_prediction["Single prediction<br/>[utils.py]"]
  node_batch_prediction["Batch prediction<br/>[utils.py]"]
  node_response["Prediction results<br/>[app.py]"]
end

subgraph group_ml["Model lifecycle"]
  node_training["Model training<br/>[train_model.py]"]
  node_dataset["PIMA dataset<br/>[diabetes.csv]"]
  node_model[("SVM model<br/>[model.pkl]")]
  node_scaler[("StandardScaler<br/>[scaler.pkl]")]
end

subgraph group_ops["Runtime support"]
  node_model_loading["Model loading<br/>[utils.py]"]
  node_request_logging["Request logging<br/>[app.py]"]
  node_logging_setup["Logging setup<br/>[utils.py]"]
end

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

node_patient -->|"enters measurements"| node_browser
node_browser -.->|"sends requests"| node_flask_api
node_api_client -->|"calls endpoints"| node_flask_api
node_flask_api -->|"validates input"| node_validation
node_flask_api -->|"requests prediction"| node_single_prediction
node_flask_api -->|"requests batch prediction"| node_batch_prediction
node_flask_api -->|"returns results"| node_response
node_training -->|"loads data"| node_dataset
node_training -->|"saves model"| node_model
node_training -->|"saves scaler"| node_scaler
node_model_loading -->|"loads model"| node_model
node_model_loading -->|"loads scaler"| node_scaler
node_single_prediction -->|"gets model and scaler"| node_model_loading
node_batch_prediction -->|"gets model and scaler"| node_model_loading
node_flask_api -->|"logs requests"| node_request_logging
node_request_logging -->|"uses logger"| node_logging_setup

click node_browser "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/index.html"
click node_flask_api "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py"
click node_validation "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py"
click node_single_prediction "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py"
click node_batch_prediction "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py"
click node_response "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py"
click node_training "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/train_model.py"
click node_dataset "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/dataset/diabetes.csv"
click node_model "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/model.pkl"
click node_scaler "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/scaler.pkl"
click node_model_loading "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py"
click node_request_logging "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py"
click node_logging_setup "https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.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_browser,node_patient,node_api_client toneBlue
class node_flask_api,node_validation,node_single_prediction,node_batch_prediction,node_response toneAmber
class node_training,node_dataset,node_model,node_scaler toneMint
class node_model_loading,node_request_logging,node_logging_setup toneRose
```

## Components

### Client experience

- [Prediction interface](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/index.html): `index.html`

### Prediction API

- [Flask endpoints](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py): `backend/app.py`
- [Input validation](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py): `backend/utils.py`
- [Single prediction](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py): `backend/utils.py`
- [Batch prediction](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py): `backend/utils.py`
- [Prediction results](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py): `backend/app.py`

### Model lifecycle

- [Model training](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/train_model.py): `backend/train_model.py`
- [PIMA dataset](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/dataset/diabetes.csv): `backend/dataset/diabetes.csv`
- [SVM model](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/model.pkl): `backend/model.pkl`
- [StandardScaler](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/scaler.pkl): `backend/scaler.pkl`

### Runtime support

- [Model loading](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py): `backend/utils.py`
- [Request logging](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/app.py): `backend/app.py`
- [Logging setup](https://github.com/guptamanvi1106/-diabetes-prediction-system/blob/master/backend/utils.py): `backend/utils.py`

### Other components

- **Patient / user**
- **API client**

## Connections

- Patient / user → Prediction interface: enters measurements (evidence: `README.md`)
- Prediction interface → Flask endpoints: sends requests (evidence: `README.md`)
- API client → Flask endpoints: calls endpoints (evidence: `README.md`)
- Flask endpoints → Input validation: validates input (evidence: `backend/app.py`)
- Flask endpoints → Single prediction: requests prediction (evidence: `backend/app.py`)
- Flask endpoints → Batch prediction: requests batch prediction (evidence: `backend/app.py`)
- Flask endpoints → Prediction results: returns results (evidence: `backend/app.py`)
- Model training → PIMA dataset: loads data (evidence: `backend/train_model.py`)
- Model training → SVM model: saves model (evidence: `backend/train_model.py`)
- Model training → StandardScaler: saves scaler (evidence: `backend/train_model.py`)
- Model loading → SVM model: loads model (evidence: `backend/utils.py`)
- Model loading → StandardScaler: loads scaler (evidence: `backend/utils.py`)
- Single prediction → Model loading: gets model and scaler (evidence: `backend/utils.py`)
- Batch prediction → Model loading: gets model and scaler (evidence: `backend/utils.py`)
- Flask endpoints → Request logging: logs requests (evidence: `backend/app.py`)
- Request logging → Logging setup: uses logger (evidence: `backend/app.py`)
