# zaid7821/multiple-disease-prediction-system architecture

> Architecture diagram of the GitHub repository zaid7821/multiple-disease-prediction-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zaid7821/multiple-disease-prediction-system
- Repository: https://github.com/zaid7821/multiple-disease-prediction-system

## Overview

##### Project Type and Purpose
- This is a single‐page machine-learning web application built with Streamlit. It loads pre-trained models to predict diseases (diabetes, heart disease, Parkinson’s) based on user-entered symptoms.
- It’s packaged in Docker for easy deployment.

##### File Structure
- Top level:
- Dataset/ : CSV files used to train models
- Models/  : Serialized ML models (.sav)
- DiabPred.ipynb : Notebook for exploratory analysis / model training
- app.py    : Streamlit app entry point (the web “frontend” and “backend” in one)
- Dockerfile & requirements.txt : containerization and dependencies
- No separate “frontend” vs “backend” directories; Streamlit handles both UI and request handling.
- Models are file-based; no external database or microservice.

##### Key README Insights
- Technologies: Python, Streamlit, Docker.
- The user interacts via a browser to a Streamlit server.
- Docker container listens on port 8501.

##### Main Components
a. User Interface
- Browser / HTTP client
- Shows form fields (symptoms), “Predict” button, and prediction results.
b. Streamlit Application (app.py)
- HTTP server (port 8501)
- UI rendering + input validation
- Prediction controller that orchestrates model loading and inference.
c. Model Loader & Inference Modules
- Python modules that load .sav files from Models/
- Each model (diabetes, heart, parkinsons) encapsulated in its own inference function.
d. Model Artifacts
- Serialized models stored on disk (Models/*.sav)
- Optionally the original datasets (Dataset/*.csv) for retraining or auditing.
e. Docker Container
- Encapsulates the entire Streamlit app, dependencies from requirements.txt, and model artifacts.
f. (Optional) Future Extension Points
- New disease modules (new .sav files + inference code)
- A database service (e.g., PostgreSQL) to store user submissions and logs
- External ML pipeline / scheduler

##### Relationships and Data Flow
1. User opens browser → sends HTTP GET to Streamlit server in Docker container
2. Streamlit serves the symptom form
3. User inputs symptom values → clicks “Predict” → HTTP POST to same server
4. Streamlit’s prediction controller invokes the appropriate model loader
5. Model loader reads the .sav file from disk → runs inference on input features
6. Inference result (disease probability / class) returned to Streamlit UI
7. Browser renders result
8. (Future) Optionally log request/result to database or file

##### Architectural Patterns and Design Principles
- Single‐page application pattern using Streamlit (combines UI + business logic)
- Separation of concerns: UI rendering vs. inference code vs. model artifacts
- Containerization (12-factor app): code + config + dependencies + models reside in one Docker image
- Extensibility: add new disease models by dropping new .sav files + adding inference functions

- Container boundary for Docker with port mapping annotated

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Browser["Browser (User)"]:::external

    %% Docker Container Boundary
    subgraph "Docker Container (port 8501)"
        direction TB
        App["Streamlit App (app.py)"]:::server
        ML["ML Inference Module"]:::server
        subgraph "Model Artifacts"
            direction TB
            Diab["diab_model.sav"]:::storage
            Heart["heart_disease_model.sav"]:::storage
            Park["parkinsons_model.sav"]:::storage
        end
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        Notebook["DiabPred.ipynb"]:::docs
        subgraph "Dataset Artifacts"
            direction TB
            Data1["diabetes.csv"]:::docs
            Data2["heart_disease.csv"]:::docs
            Data3["parkinsons.csv"]:::docs
        end
        Dockerfile["Dockerfile"]:::docs
        Req["requirements.txt"]:::docs
        Readme["README.md"]:::docs
    end

    %% Data Flow
    Browser -->|"HTTP GET/POST"| App
    App -->|"invoke inference"| ML
    ML -->|"load model"| Diab
    ML -->|"load model"| Heart
    ML -->|"load model"| Park
    ML -->|"return result"| App
    App -->|"HTTP response"| Browser

    %% Click Events
    click App "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/app.py"
    click ML "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/app.py"
    click Diab "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Models/diab_model.sav"
    click Heart "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Models/heart_disease_model.sav"
    click Park "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Models/parkinsons_model.sav"
    click Notebook "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/DiabPred.ipynb"
    click Data1 "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Dataset/diabetes.csv"
    click Data2 "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Dataset/heart_disease.csv"
    click Data3 "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/Dataset/parkinsons.csv"
    click Dockerfile "https://github.com/zaid7821/multiple-disease-prediction-system/tree/master/Dockerfile"
    click Req "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/requirements.txt"
    click Readme "https://github.com/zaid7821/multiple-disease-prediction-system/blob/master/README.md"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000;
    classDef server fill:#98FB98,stroke:#000;
    classDef storage fill:#D3D3D3,stroke:#000;
    classDef docs fill:#FFDAB9,stroke:#000;
```
