# mohamedhamed5/diabetes_prediction_project architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedhamed5/diabetes_prediction_project
- Repository: https://github.com/mohamedhamed5/diabetes_prediction_project

## Overview

This is a Streamlit diabetes-risk prediction assistant. A user enters health features, submits them for scaled three-class prediction, reviews probabilities and an interpretation, and can have the encounter recorded and download a PDF report. A separate model-development script explores the BRFSS dataset, balances training data with SMOTE, evaluates logistic regression, and saves the model and scaler used by the app. The source excerpts show these responsibilities, but not a separate service boundary; both runtime and training are implemented in single Python files.

Main entry points: [`code/app.py`](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py) (Prediction engine), [`code/model.py`](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/model.py) (Training pipeline), [`model.pkl`](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/model.pkl) (Classifier), [`scaler.pkl`](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/scaler.pkl) (Feature scaler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Prediction experience"]
  node_health_form["Health form<br/>[app.py]"]
  node_results["Results view<br/>[app.py]"]
end

subgraph group_inference["Prediction and records"]
  node_prediction["Prediction engine<br/>[app.py]"]
  node_model_artifact["Classifier<br/>[model.pkl]"]
  node_scaler_artifact["Feature scaler<br/>[scaler.pkl]"]
  node_record_store[("Patient records")]
  node_report["PDF report<br/>[app.py]"]
  node_report_files[("Report files")]
end

subgraph group_modeling["Model development"]
  node_brfss["BRFSS dataset"]
  node_training["Training pipeline<br/>[model.py]"]
  node_evaluation["Model evaluation<br/>[model.py]"]
  node_figures["Analysis figures"]
end

node_patient(("Patient"))

node_patient -->|"enters features"| node_health_form
node_health_form -->|"submits features"| node_prediction
node_prediction -->|"transforms with"| node_scaler_artifact
node_prediction -->|"predicts with"| node_model_artifact
node_prediction -->|"renders probabilities"| node_results
node_prediction -->|"appends record"| node_record_store
node_prediction -->|"creates report"| node_report
node_report -->|"writes PDF"| node_report_files
node_results -->|"offers download"| node_patient
node_brfss -->|"loads data"| node_training
node_training -->|"evaluates model"| node_evaluation
node_training -->|"saves analysis"| node_figures
node_training -->|"saves classifier"| node_model_artifact
node_training -->|"saves scaler"| node_scaler_artifact

click node_health_form "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py"
click node_prediction "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py"
click node_model_artifact "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/model.pkl"
click node_scaler_artifact "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/scaler.pkl"
click node_results "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py"
click node_record_store "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/patients_records.csv"
click node_report "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py"
click node_report_files "https://github.com/mohamedhamed5/diabetes_prediction_project/tree/master/Patient%20files"
click node_brfss "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/diabetes_012_health_indicators_BRFSS2015.csv"
click node_training "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/model.py"
click node_evaluation "https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/model.py"
click node_figures "https://github.com/mohamedhamed5/diabetes_prediction_project/tree/master/figures"

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_health_form,node_results toneBlue
class node_prediction,node_model_artifact,node_scaler_artifact,node_record_store,node_report,node_report_files toneAmber
class node_brfss,node_training,node_evaluation,node_figures toneMint
class node_patient toneIndigo
```

## Components

### Prediction experience

- [Health form](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py): `code/app.py`
- [Results view](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py): `code/app.py`

### Prediction and records

- [Prediction engine](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py): `code/app.py`
- [Classifier](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/model.pkl): `model.pkl`
- [Feature scaler](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/scaler.pkl): `scaler.pkl`
- [Patient records](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/patients_records.csv): `patients_records.csv`
- [PDF report](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/app.py): `code/app.py`
- [Report files](https://github.com/mohamedhamed5/diabetes_prediction_project/tree/master/Patient%20files): `Patient files`

### Model development

- [BRFSS dataset](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/diabetes_012_health_indicators_BRFSS2015.csv): `diabetes_012_health_indicators_BRFSS2015.csv`
- [Training pipeline](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/model.py): `code/model.py`
- [Model evaluation](https://github.com/mohamedhamed5/diabetes_prediction_project/blob/master/code/model.py): `code/model.py`
- [Analysis figures](https://github.com/mohamedhamed5/diabetes_prediction_project/tree/master/figures): `figures`

### Other components

- **Patient**

## Connections

- Patient → Health form: enters features (evidence: `code/app.py`)
- Health form → Prediction engine: submits features (evidence: `code/app.py`)
- Prediction engine → Feature scaler: transforms with (evidence: `code/app.py`)
- Prediction engine → Classifier: predicts with (evidence: `code/app.py`)
- Prediction engine → Results view: renders probabilities (evidence: `code/app.py`)
- Prediction engine → Patient records: appends record (evidence: `code/app.py`)
- Prediction engine → PDF report: creates report (evidence: `code/app.py`)
- PDF report → Report files: writes PDF (evidence: `code/app.py`)
- Results view → Patient: offers download (evidence: `code/app.py`)
- BRFSS dataset → Training pipeline: loads data (evidence: `code/model.py`)
- Training pipeline → Model evaluation: evaluates model (evidence: `code/model.py`)
- Training pipeline → Analysis figures: saves analysis (evidence: `code/model.py`)
- Training pipeline → Classifier: saves classifier (evidence: `code/model.py`)
- Training pipeline → Feature scaler: saves scaler (evidence: `code/model.py`)
