# tanmayvaity/disease-prediction-system architecture

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

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

## Overview

##### Project Type and Purpose
- The project is centered around machine learning for disease prediction.
- It includes training multiple models (decision tree, random forest, and gradient boosting), persisting these models, and deploying them for inference (likely via a web interface using Streamlit).
- A Jupyter Notebook is included for exploratory or demonstration purposes.

##### Main Components
a. Data Layer:
- Dataset: Represent the “dataset” folder containing the training (training_data.csv) and test (test_data.csv) data.
- Data Ingestion/Preprocessing: Indicate that data is read from CSV files to be used in the model training process.

b. Model Training Pipeline:
- Training Script: Include the “train.py” file, which illustrates the process of reading data, preprocessing, training the models using scikit-learn, and evaluating them.
- Configuration Management: Represent “config.yaml” as the configuration component that holds various parameters for training and inference setups.

c. Inference/Serving Layer:
- Web Application: Mark “app.py” as the entry point for the user-facing application. Considering the use of Streamlit, highlight that this component provides the web UI for disease prediction.
- Helper/Runner: “main.py” could be used as an additional executable to manage the overall workflow or integrate multiple components.

d. Analysis & Experimentation:
- Notebook Component: Include “notebook/disease-prediciton.ipynb”, which is likely used for data analysis, experimentation, and visualization of predictions results.

##### Relationships and Interactions
- Data flows from the Dataset (CSV files) into the Training Pipeline (train.py), where preprocessing and model training occur.
- Trained models are saved into the Model Persistence component (saved_model).
- The Inference Service (app.py) reads configuration parameters from config.yaml and loads the appropriate saved model to serve predictions to the user.
- Optionally, “main.py” may orchestrate these processes or serve as a command-line interface.
- That the Notebook is used for exploratory analysis which may influence model improvements or parameter tuning.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: Distinguish between data preprocessing/training, model persistence, and the inference/presentation layer.
- Modular Design: Each script (train.py, app.py, main.py) encapsulates a specific functionality of the system.
- Configurable Behavior: Use the config.yaml file as a single source of truth for various runtime parameters, ensuring flexibility.
- Reusability: The saved models are decoupled from application logic, allowing for independent model updates without affecting the service layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        DS(("Dataset (CSV Files)"))
    end

    %% Model Training Pipeline
    subgraph "Model Training Pipeline"
        TR["Training Script (train.py)"]
        CF["Configuration (config.yaml)"]
        SM(("Saved Models (joblib)"))
    end

    %% Inference/Serving Layer
    subgraph "Inference/Serving Layer"
        UI["Web Application (app.py)"]
        MA["Workflow Orchestration (main.py)"]
    end

    %% Analysis & Experimentation
    subgraph "Analysis & Experimentation"
        NB["Notebook (disease-prediciton.ipynb)"]
    end

    %% Relationships and Data Flow
    DS -->|"reads_data"| TR
    CF -->|"configures"| TR
    TR -->|"saves_model"| SM
    SM -->|"loads_model"| UI
    CF -->|"provides_config"| UI
    MA -->|"orchestrates"| TR
    MA -->|"orchestrates"| UI
    NB -->|"analyzes"| TR

    %% Click Events
    click DS "https://github.com/tanmayvaity/disease-prediction-system/tree/main/dataset/"
    click TR "https://github.com/tanmayvaity/disease-prediction-system/blob/main/train.py"
    click CF "https://github.com/tanmayvaity/disease-prediction-system/blob/main/config.yaml"
    click SM "https://github.com/tanmayvaity/disease-prediction-system/tree/main/saved_model/"
    click UI "https://github.com/tanmayvaity/disease-prediction-system/blob/main/app.py"
    click MA "https://github.com/tanmayvaity/disease-prediction-system/blob/main/main.py"
    click NB "https://github.com/tanmayvaity/disease-prediction-system/blob/main/notebook/disease-prediciton.ipynb"

    %% Styles
    classDef datalayer fill:#D1E8E2,stroke:#333,stroke-width:2px;
    classDef training fill:#ECE2B6,stroke:#333,stroke-width:2px;
    classDef inference fill:#F4CCCC,stroke:#333,stroke-width:2px;
    classDef analysis fill:#D9EAD3,stroke:#333,stroke-width:2px;

    class DS datalayer;
    class TR,CF,SM training;
    class UI,MA inference;
    class NB analysis;
```
