# purvaagine/diabetes-detect architecture

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

- Interactive diagram: https://gitdiagram.com/purvaagine/diabetes-detect
- Repository: https://github.com/purvaagine/diabetes-detect

## Overview

##### Project type and purpose
- This is a full-stack, machine learning–based web application.
- Purpose: train an SVM model on diabetes data, persist it, and expose a Streamlit UI for real-time predictions.

##### File structure
- Top-level scripts:
- Diabetes Prediction System.py (likely contains training pipeline)
- predictive_system.py (core preprocessing and prediction functions)
- trained_dia_model.sav (pickled SVM model)
- No separate frontend/backend folders; the web UI (Streamlit) and ML logic co-exist in the same codebase.
- Implicit components: data ingestion (CSV), preprocessing, model training, model persistence, UI.

##### README insights
- Tech stack: Python, Pandas, NumPy, scikit-learn, pickle, Streamlit.
- Process flow clearly defined: Data Prep → Model Training → Model Deployment → Web Interface.

##### Main components
a. Data Layer
- CSV Data Source
- Data Preprocessor (Pandas + StandardScaler)
b. Model Training & Evaluation
- SVM Training Module (scikit-learn)
- Train/Test Split & Accuracy Calculator
c. Model Persistence
- Pickle Serialization → trained_dia_model.sav
d. Prediction Engine
- Model Loader (pickle.load)
- Prediction Function (predict_proba or predict)
e. Web Interface (Streamlit)
- Input Forms (Pregnancy, Glucose, etc.)
- Output Display (Prediction result)
f. Supporting Libraries/Services (optional layer)
- NumPy, Pandas, scikit-learn, Streamlit

##### Relationships and interactions
- From User Input → Prediction Engine → UI Output
- Libraries as side-dependencies connected to each component

##### Highlighted architectural patterns
- Layered architecture: Data → Business Logic → Presentation
- Separation of concerns: preprocessing, training, persistence, prediction, UI
- Reusable modules: predictive_system.py encapsulates core logic used by both training and UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        DataCSV["CSV Data Source"]:::data
        Preprocessor["Data Preprocessor<br/><i>(pandas, StandardScaler)</i>"]:::data
    end
    DataCSV -->|"load data"| Preprocessor

    %% Model Training Layer
    subgraph "Model Training Layer"
        Split["Train/Test Split & Accuracy Calculator"]:::logic
        Trainer["SVM Training Module<br/><i>(scikit-learn SVM)</i>"]:::logic
    end
    Preprocessor -->|"standardize features"| Split
    Split -->|"train model"| Trainer
    Trainer -->|"serialize model"| Persistence

    %% Model Persistence
    Persistence[(trained_dia_model.sav)]:::storage

    %% Prediction Engine
    subgraph "Prediction Engine"
        Loader["Model Loader<br/><i>(pickle.load)</i>"]:::logic
        Predictor["Prediction Function<br/><i>(predict())</i>"]:::logic
    end
    Persistence -->|"load model"| Loader
    Loader --> Predictor

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Streamlit UI"]:::ui
        Inputs["Input Form<br/>(user features)"]:::ui
        Outputs["Output Display<br/>(prediction)"]:::ui
    end
    UI --> Inputs
    Inputs -->|"user data"| Predictor
    Predictor -->|"prediction result"| Outputs

    %% Supporting Libraries
    Pandas["Pandas"]:::lib
    NumPy["NumPy"]:::lib
    Sklearn["scikit-learn"]:::lib
    StreamlitLib["Streamlit"]:::lib

    Pandas -.-> Preprocessor
    NumPy -.-> Preprocessor
    Sklearn -.-> Trainer
    Sklearn -.-> Predictor
    StreamlitLib -.-> UI

    %% Click Events
    click Preprocessor "https://github.com/purvaagine/diabetes-detect/blob/main/predictive_system.py"
    click Loader "https://github.com/purvaagine/diabetes-detect/blob/main/predictive_system.py"
    click Predictor "https://github.com/purvaagine/diabetes-detect/blob/main/predictive_system.py"
    click Trainer "https://github.com/purvaagine/diabetes-detect/blob/main/Diabetes Prediction System.py"
    click UI "https://github.com/purvaagine/diabetes-detect/blob/main/Diabetes Prediction System.py"
    click Persistence "https://github.com/purvaagine/diabetes-detect/blob/main/trained_dia_model.sav"

    %% Styles
    classDef data fill:#E0F7FA,stroke:#006064,color:#004D40;
    classDef logic fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32;
    classDef storage fill:#FFF3E0,stroke:#E65100,color:#BF360C;
    classDef ui fill:#FFF8E1,stroke:#FF6F00,color:#E65100;
    classDef lib fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
```
