# sudhanshu-ambastha/multiple-disease-prediction-bot architecture

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

- Interactive diagram: https://gitdiagram.com/sudhanshu-ambastha/multiple-disease-prediction-bot
- Repository: https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot

## Overview

##### Project Type & Purpose
- This is a monolithic, single-page machine-learning web application built with Streamlit.
- Purpose: allow end users to enter symptoms → preprocess input → call a pre-trained classifier → decode prediction → display disease name.

##### File Structure Analysis
Top-level files (no subdirectories):
- multiple_disease_prediction.py (primary Streamlit app)
- Multiple_disease_prediction_bot_trained_model.sav (serialized sklearn model)
- label_encoder.sav (serialized LabelEncoder)
- Training.csv / Testing.csv (data sources for symptom list and optional evaluation)
- Jupyter notebooks & Python scripts (LabelEncoder.ipynb, development history – not part of runtime)
- README.md (project documentation)

##### Key Architecture Insights from README
- Streamlit serves both frontend (UI) and backend (logic) in one process.
- Dependencies: streamlit, joblib (model loading), pandas/numpy (data handling), scikit-learn (inference).
- Workflow: load CSV for symptom vocabulary → load model & encoder → user enters comma-separated symptoms → preprocess → predict → decode → render result.

##### Main Components
a. User Interface (Web Browser)
b. Streamlit Application Server (Python runtime)
- Input Module (text area + button)
- Preprocessing Module (tokenize, map to feature vector)
- Inference Module (load `.sav` files, call model.predict)
- Postprocessing Module (decode numeric label → string)
- Presentation Module (display result)
c. Data Stores (Local File System)
- Training.csv (symptom list)
- Testing.csv (optional eval data)
- multiple_disease_prediction_bot_trained_model.sav
- label_encoder.sav
d. External Dependencies (Python libraries, e.g., pandas, sklearn)

##### Relationships & Interactions
- User ↔ Browser UI ↔ Streamlit Server
- Server reads CSVs at startup → builds in-memory structures
- On “Predict” click: UI → Preprocessing → Inference → Postprocessing → UI update
- Inference Module accesses two file-based artifacts (model .sav + encoder .sav)
- All data flows are synchronous within the same process

##### Architectural Patterns & Principles
- Single-process, single-page “full-stack” pattern via Streamlit
- Separation of concerns: Input / Preprocessing / Inference / Postprocessing / Presentation
- Filesystem‐based model persistence (no external database)
- Dependency injection at startup (model + encoder loaded once)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors and UI
    User((User)):::external
    UI["Web Browser / Streamlit UI"]:::ui

    User -->|"Enter symptoms; click Predict"| UI

    %% Streamlit App Container
    subgraph "Streamlit App"
        direction TB
        Input["Input Module"]:::compute
        Preprocessing["Preprocessing Module"]:::compute
        Inference["Inference Module"]:::compute
        Postprocessing["Postprocessing Module"]:::compute
        Presentation["Presentation Module"]:::compute
        Startup["App Initialization"]:::compute
    end

    UI --> Input
    Input --> Preprocessing
    Preprocessing --> Inference
    Inference --> Postprocessing
    Postprocessing --> Presentation
    Presentation -->|"Display result"| UI

    %% Startup sequence
    Startup -->|load symptom vocabulary| dsTraining
    Startup -->|load evaluation data| dsTesting
    Startup -->|load model artifact| dsModel
    Startup -->|load encoder artifact| dsEncoder

    %% Data stores
    dsTraining[(Training.csv)]:::datastore
    dsTesting[(Testing.csv)]:::datastore
    dsModel[(multiple_disease_prediction_bot_trained_model.sav)]:::datastore
    dsEncoder[(label_encoder.sav)]:::datastore

    %% Module data access
    Preprocessing -->|fetch symptom list| dsTraining
    Inference -->|load model| dsModel
    Inference -->|load encoder| dsEncoder

    %% External Dependencies
    Dependencies["Dependencies: pandas, numpy, scikit-learn, joblib, streamlit"]:::external

    %% Click Events
    click Input "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click Preprocessing "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click Inference "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click Postprocessing "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click Presentation "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click Startup "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction.py"
    click dsTraining "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/Training.csv"
    click dsTesting "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/Testing.csv"
    click dsModel "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/multiple_disease_prediction_bot_trained_model.sav"
    click dsEncoder "https://github.com/sudhanshu-ambastha/multiple-disease-prediction-bot/blob/main/label_encoder.sav"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef compute fill:#90EE90,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
