# rajatkapoor01/heart-disease-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/rajatkapoor01/heart-disease-prediction
- Repository: https://github.com/rajatkapoor01/heart-disease-prediction

## Overview

##### Main Components
- Data & Model Training:
- Data Source: The CSV file (heart.csv) serves as the dataset.
- Notebook: “Heart disease predicition.ipynb” illustrates the experimentation, data preprocessing, feature engineering, and model training steps.
- Model Artifact: “heart_disease_model.sav” is the saved model after evaluation and selection.
- Application (Backend & Deployment):
- Flask Application: “app.py” forms the backend that loads the ML model for predictions.
- Templates: HTML files (input.html and output.html in the templates directory) provide the user’s frontend interface.
- Static Assets: The images folder holds UI images that support documentation/screenshots.
- Dependencies & Environment:
- Requirements: “requirements.txt” and “lib.txt” ensure that all needed Python libraries (like Pandas, NumPy, Scikit-learn, Flask, etc.) are installed.
- Additional Scripts: “requirements_version_fetching.py” might be used to track or enforce specific package versions.

##### Relationships and Interactions
- Data Flow: Begin with the data ingestion from heart.csv, passing through preprocessing and model training in the Jupyter Notebook, which in turn produces the saved model.
- Deployment Flow: The Flask app (app.py) loads the trained model (heart_disease_model.sav) and, upon receiving user input via the HTML forms, processes the input data, computes predictions, and sends the result back to the output view.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project cleanly separates ML model training from deployment. The experimentation and training occur outside of the deployed application, while the Flask app focuses on delivering predictions.
- Lightweight Web Service: Flask is used to ensure a simple yet effective deployment of the prediction service.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% ML Training Pipeline
    subgraph "ML Training Pipeline"
        A("Data Source: heart.csv"):::data
        B("Notebook: Heart disease predicition.ipynb"):::ml
        C("Saved Model: heart_disease_model.sav"):::data
    end
    A -->|"DataInput"| B
    B -->|"ModelTraining"| C

    %% Web Application Layer
    subgraph "Web Application"
        D("Flask Web Server: app.py"):::backend
        E("Frontend View: templates/input.html"):::frontend
        F("Frontend View: templates/output.html"):::frontend
    end
    C -->|"LoadModel"| D
    D -->|"ServeInput"| E
    D -->|"ServeOutput"| F

    %% User Interaction
    G("User (Web Browser)"):::external
    G -->|"AccessWebApp"| D

    %% Environment & Assets
    subgraph "Environment & Assets"
        H("Static Assets: images"):::static
        I("Requirements: requirements.txt"):::env
        J("Lib: lib.txt"):::env
        K("Script: requirement_version_fetching.py"):::env
    end
    E -->|"LoadAssets"| H
    B ---|"Requires"| I
    B ---|"Requires"| J
    B ---|"Requires"| K
    D ---|"Uses"| I
    D ---|"Uses"| J
    D ---|"Uses"| K

    %% Click Events
    click A "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/heart.csv"
    click B "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/Heart disease predicition.ipynb"
    click C "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/heart_disease_model.sav"
    click D "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/app.py"
    click E "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/templates/input.html"
    click F "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/templates/output.html"
    click H "https://github.com/rajatkapoor01/heart-disease-prediction/tree/main/images"
    click I "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/requirements.txt"
    click J "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/lib.txt"
    click K "https://github.com/rajatkapoor01/heart-disease-prediction/blob/main/requirement_version_fetching.py"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef ml fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef frontend fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef static fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef env fill:#DDA0DD,stroke:#333,stroke-width:2px;
```
