# ali-islam111/heart-disease-risk-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/ali-islam111/heart-disease-risk-prediction
- Repository: https://github.com/ali-islam111/heart-disease-risk-prediction

## Overview

##### Project type and purpose
- This is a full-stack machine-learning web application for heart-disease risk prediction.
- The pipeline covers data ingestion, preprocessing, feature engineering, modeling (both supervised and unsupervised), hyperparameter tuning, model export, and a Streamlit-based UI exposed via an ngrok tunnel.

##### File structure
- Top-level folders:
- UI: contains `app.py` (Streamlit frontend)
- model: contains the serialized pipeline `final_tuned_pipeline.pkl`
- datasets: raw and intermediate CSVs for preprocessing, feature selection, PCA
- notebooks: exploratory and modeling steps (preprocessing, EDA, feature selection, PCA, supervised & unsupervised learning, hyperparameter tuning)
- deployment: the script `deploy_with_ngrok.py` that launches Streamlit and opens an ngrok tunnel
- results: evaluation output (Results.txt)
- Config files: `requirements.txt` for dependencies, `README.md` for project overview.

##### README for additional insights
- The README outlines project phases, technology stack (Python, Streamlit, scikit-learn, ngrok), and how the final artifact (`final_tuned_pipeline.pkl`) is consumed by `app.py`.
- Deployment instructions show how the pieces fit at runtime: the UI loads the model, exposes endpoints, and streams results to users via an ngrok URL.

##### Elements
- Blue rectangles for data pipelines
- Orange rectangles for runtime services (Streamlit, ngrok)

##### Detail without overcomplicating
- Every stage: raw data → preprocessing → feature selection → PCA → model training → model export → UI → deployment.
- Notebooks block as “Development / Exploration” but do not detail every notebook—group by phase.
- That `deploy_with_ngrok.py` orchestrates both launching Streamlit and creating the ngrok tunnel.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Development / Exploration"
        DS[(Data Sources)]:::cylinder
        EP1["01 - Preprocessing"]:::process
        EP2["02 - EDA & FeatureEng"]:::process
        FS["03 - Feature Selection"]:::process
        PCA["04 - PCA Analysis"]:::process
        subgraph "Modeling & Tuning"
            ML1["05 - Supervised Learning"]:::process
            ML2["06 - Unsupervised Learning"]:::process
            ML3["07 - Hyperparameter Tuning"]:::process
        end
        RS[(Results & Evaluation)]:::cylinder
    end

    DS --> EP1 --> EP2 --> FS --> PCA --> ML1 --> ML2 --> ML3 --> Artifact[(final_tuned_pipeline.pkl)]:::cylinder
    ML3 --> RS

    subgraph "Deployment & UI"
        ST["Streamlit UI"]:::runtime
        DP["deploy_with_ngrok.py"]:::runtime
        NG["ngrok Tunnel"]:::runtime
    end

    Artifact --> ST --> DP --> NG --> User[/"End Users"/]:::user

    click DS "https://github.com/ali-islam111/heart-disease-risk-prediction/tree/main/datasets/"
    click EP1 "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/01_heart_disease_preprocessing.ipynb"
    click EP2 "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/02_EDA+FeatureENG_Correlation.ipynb"
    click FS "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/03_heart_feature_selection_(chi_square_feature_importance_RFE).ipynb"
    click PCA "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/04_heart_disease_PCA_analysis.ipynb"
    click ML1 "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/05_Supervised_Learning_.ipynb"
    click ML2 "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/06_Unsupervised_Learning.ipynb"
    click ML3 "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/notebooks/07_Hyperparameter_Tuning.ipynb"
    click Artifact "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/model/final_tuned_pipeline.pkl"
    click ST "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/UI/app.py"
    click DP "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/deployment/deploy_with_ngrok.py"
    click RS "https://github.com/ali-islam111/heart-disease-risk-prediction/blob/main/results/Results.txt"

    classDef cylinder fill:#9f6,stroke:#333,stroke-width:1px
    classDef process fill:#bbf,stroke:#333,stroke-width:1px
    classDef runtime fill:#fb0,stroke:#333,stroke-width:1px
    classDef user fill:#fff,stroke:#333,stroke-width:1px
```
