# prerit002/predictor_disease architecture

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

- Interactive diagram: https://gitdiagram.com/prerit002/predictor_disease
- Repository: https://github.com/prerit002/predictor_disease

## Overview

##### Project type and purpose
- From the file tree and minimal README, this is a monolithic Python web application (“Predictor_disease”) that uses a pre-trained machine-learning model to predict diseases based on user-submitted symptoms.
- It bundles a Flask (or similar) app (`app.py`), Jinja2 templates for the UI (`templates/`), and serialized model artifacts (`models/`).

##### File structure
- Top-level files:
- `app.py` – the main Flask application (routes, request handling, model loading).
- `requirements.txt` – Python dependencies (Flask, scikit-learn, etc.).
- Directories:
- `templates/` – Jinja2 HTML templates (`index.html`, `predict.html`, `about.html`, `base.html`).
- `models/` – pickled artifacts:
– `model.pkl` (trained ML model)
– `label_encoder.pkl` (to map model outputs to disease labels)
– `symptom_vocab.pkl` (vocabulary for converting symptom input to feature vectors)

##### Extract insights (README)
- The README only provides the project name, but file names imply a symptom-to-disease predictor.

##### Main components & interactions
a. Components:
- Client (Web browser)
- Web Server / WSGI Gateway (e.g., Gunicorn or Flask’s built-in server)
- Application layer (`app.py`)
- ML Model artifacts (`models/`)
- Template Engine (Jinja2 in `templates/`)
- Optional: Reverse proxy or load balancer in front of the app

b. Data flow / relationships:
1. User opens `index.html` → selects symptoms → submits form.
2. HTTP POST to Flask route (`/predict`) in `app.py`.
3. `app.py` loads `symptom_vocab.pkl` to vectorize inputs.
4. `model.pkl` processes vector -> numeric prediction.
5. `label_encoder.pkl` maps numeric code → disease name.
6. Flask renders `predict.html` with the result.
7. Response returns to the user’s browser.

c. Architectural patterns / principles:
- MVC (Model-View-Controller):
- Model: pickled ML artifacts + data preprocessor.
- View: HTML templates.
- Controller: route handlers in `app.py`.
- Stateless requests: each prediction is computed on-the-fly.
- Single codebase (monolith) with clear separation of concerns.

d. Key technologies:
- Python 3.x
- Flask (web framework)
- Jinja2 (templating)
- scikit-learn (model framework)
- Pickle (artifact serialization)

##### Detail
- How `symptom_vocab.pkl`, `model.pkl`, and `label_encoder.pkl` feed into the prediction pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Tier"
        Browser["Web Browser"]:::frontend
    end

    subgraph "Network Layer"
        Proxy["Reverse Proxy / Load Balancer"]:::proxy
    end

    subgraph "Backend Tier"
        subgraph "Application Server"
            FlaskApp["Flask App (app.py)"]:::appserver
        end

        subgraph "Template Engine"
            TemplateEngine["Jinja2 Template Engine"]:::template
        end

        subgraph "Model Artifacts"
            DirModels["models/"]:::model
            MPKL["model.pkl"]:::model
            LEPKL["label_encoder.pkl"]:::model
            SVPKL["symptom_vocab.pkl"]:::model
        end
    end

    subgraph "Project Files"
        Req["requirements.txt"]:::fs
        Readme["README.md"]:::fs
    end

    Browser -->|"HTTP GET/POST"| Proxy
    Proxy -->|"HTTP Request"| FlaskApp
    FlaskApp -->|"file I/O"| MPKL
    FlaskApp -->|"file I/O"| LEPKL
    FlaskApp -->|"file I/O"| SVPKL
    FlaskApp -->|"renders"| TemplateEngine
    TemplateEngine -->|"HTML Response"| Browser

    DirModels --> MPKL
    DirModels --> LEPKL
    DirModels --> SVPKL

    click FlaskApp "https://github.com/prerit002/predictor_disease/blob/main/app.py"
    click MPKL "https://github.com/prerit002/predictor_disease/blob/main/models/model.pkl"
    click LEPKL "https://github.com/prerit002/predictor_disease/blob/main/models/label_encoder.pkl"
    click SVPKL "https://github.com/prerit002/predictor_disease/blob/main/models/symptom_vocab.pkl"
    click Req "https://github.com/prerit002/predictor_disease/blob/main/requirements.txt"
    click Readme "https://github.com/prerit002/predictor_disease/blob/main/README.md"

    classDef frontend fill:#BBDEFB,stroke:#333,stroke-width:1px
    classDef proxy fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef appserver fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef model fill:#FFF9C4,stroke:#333,stroke-width:1px
    classDef template fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef fs fill:#D7CCC8,stroke:#333,stroke-width:1px
```
