# madhav-73/disease-prediction-and-drug-recommendation architecture

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

- Interactive diagram: https://gitdiagram.com/madhav-73/disease-prediction-and-drug-recommendation
- Repository: https://github.com/madhav-73/disease-prediction-and-drug-recommendation

## Overview

##### Project type and purpose
- This is a machine-learning-based prediction service: it takes patient symptom data (and possibly processed drug-review text), runs a trained model, and returns both a disease prediction and a set of recommended drugs.
- The presence of Jupyter notebooks (“Disease_condition_detection_drug_reviews.ipynb” and “disease-condition-prediction.ipynb”) indicates an offline/experimental pipeline; “app.py” plus two pickle files (passmodel.pkl and tfidfvectorizer.pkl) form the runtime inference service.

##### File structure
- Top level:
- README.md – project overview and features
- app.py – inference service entry point (likely a Flask/FastAPI/CLI wrapper around the model)
- passmodel.pkl – trained classification model
- tfidfvectorizer.pkl – text vectorizer for feature extraction
- .ipynb_checkpoints – intermediate notebook checkpoints (iterative development, not part of production)
- No separate “frontend” or “backend” directories → single service architecture

##### README for additional insights
- Confirms two main capabilities: disease prediction and drug recommendation.
- Mentions “modular structure,” but in fact the codebase is compact: offline notebooks (development) vs. a standalone inference app.

a. Main components
1. User Interface (UI) or Client
‑ Could be a web UI, REST client, or CLI (not part of repo but assumed)
2. Inference Service (app.py)
‑ HTTP/CLI endpoint that accepts input (symptoms, optional text)
‑ Orchestrates preprocessing, model loading, postprocessing
3. Preprocessing Module
‑ Uses tfidfvectorizer.pkl to transform raw text/symptoms into feature vectors
4. Predictive Model
‑ passmodel.pkl to predict disease labels
5. Recommendation Engine
‑ Maps predicted disease to top-3 drug recommendations (likely internal lookup)
6. (Offline) Experimentation Pipeline
‑ Jupyter notebooks: data ingestion → feature engineering → model training → serialization
7. External Dependencies
‑ scikit-learn, pandas, Flask/FastAPI (or whichever web framework), numpy
b. Relationships & interactions
- Client sends request → Inference Service
- Inference Service loads vectorizer → transforms input → passes features to Model
- Model outputs disease label → Recommendation Engine selects drugs → Service returns response
- Offline notebooks connect to raw datasets, produce serializations used by the service
c. Architectural patterns / design principles
- Separation of concerns:
- Offline training vs. online serving
- Preprocessing, inference, and recommendation as distinct modules
- Model serialization for decoupling training from serving
- Stateless service: no persistent storage; all state is in model files
d. Key technologies
- Python 3.x
- scikit-learn (model training & inference)
- pickle (model/vectorizer serialization)
- Flask or FastAPI (app.py likely)
- Jupyter (notebooks)

##### Elements
- Client → Service request
- Service → Vectorizer → Model → Recommender → Service response → Client
- Notebooks → create .pkl artifacts → Service
- Blue for runtime components
- Gray for offline/training components
- Green for external libraries/dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        direction TB
        Notebook1["Disease_condition_detection_drug_reviews.ipynb checkpoint"]:::offline
        Notebook2["disease-condition-prediction.ipynb checkpoint"]:::offline
        Notebook1 -->|generates| VectorizerArtifact
        Notebook2 -->|generates| ModelArtifact
    end

    VectorizerArtifact[("tfidfvectorizer.pkl")]:::artifact
    ModelArtifact[("passmodel.pkl")]:::artifact

    %% Documentation
    README["README.md (Project Overview)"]:::doc

    %% Runtime Inference Service
    subgraph "Online Inference Service"
        direction TB
        Client["Client (cURL/REST UI)"]:::external
        Service["Inference Service (app.py)"]:::runtime
        Preprocessor["Text Vectorization Module"]:::runtime
        Model["Predictive Model"]:::runtime
        Recommender["Recommendation Engine"]:::runtime
    end

    %% External Dependencies
    ExternalLibs["External Libraries\n(scikit-learn, pandas,\nFlask/FastAPI, numpy)"]:::external

    %% Data Flow
    Client -->|"HTTP Request\n(symptoms, text)"| Service
    Service -->|"load vectorizer"| VectorizerArtifact
    Service --> Preprocessor
    Preprocessor -->|"feature vectors"| Service
    Service -->|"load model"| ModelArtifact
    Service --> Model
    Model -->|"disease label"| Recommender
    Recommender -->|"recommended drugs"| Service
    Service -->|"HTTP Response\n(prediction + drugs)"| Client

    %% Artifacts usage
    VectorizerArtifact -.-> Preprocessor
    ModelArtifact -.-> Model

    %% Training artifacts linkage
    Notebook1 -.-> VectorizerArtifact
    Notebook2 -.-> ModelArtifact
    README -.-> Notebook1
    README -.-> Notebook2

    %% Dependencies
    Service --> ExternalLibs
    Preprocessor --> ExternalLibs
    Model --> ExternalLibs
    Recommender --> ExternalLibs

    %% Click Events
    click Notebook1 "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/tree/master/.ipynb_checkpoints/"
    click Notebook2 "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/tree/master/.ipynb_checkpoints/"
    click Service "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/blob/master/app.py"
    click VectorizerArtifact "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/blob/master/tfidfvectorizer.pkl"
    click ModelArtifact "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/blob/master/passmodel.pkl"
    click README "https://github.com/madhav-73/disease-prediction-and-drug-recommendation/blob/master/README.md"

    %% Styles
    classDef runtime fill:#D0E8F2,stroke:#333,stroke-width:1px
    classDef offline fill:#E0E0E0,stroke:#666,stroke-width:1px
    classDef artifact fill:#FFFFFF,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef external fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef doc fill:#FFF3CD,stroke:#333,stroke-width:1px
```
