# killich8/end-to-end-cardiovascular-disease architecture

> Architecture diagram of the GitHub repository killich8/end-to-end-cardiovascular-disease, 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/killich8/end-to-end-cardiovascular-disease
- Repository: https://github.com/killich8/end-to-end-cardiovascular-disease

## Overview

##### Project type and purpose
- This is an end-to-end machine-learning application for cardiovascular disease prediction.
- It contains both an ML-pipeline (data ingestion → validation → transformation → training → evaluation) and a web front-end (HTML/CSS/JS templates served via `app.py`) for user input and prediction results.

##### File structure
- Top-level code:
- main.py – CLI entry point to run the entire pipeline
- app.py – Flask (or similar) web server for prediction
- template.py – likely auxiliary template rendering logic
- Dockerfile, .github/workflows/cicd.yaml – containerization & CI/CD
- Artifacts directory – intermediate outputs (raw ingested data, transformed datasets, trained model, evaluation metrics)
- config/ + params.yaml + schema.yaml – configuration & hyperparameters
- src/Cardiovascular_Disease/ – core Python package
- components/ – data_ingestion, data_validation, data_transformation, model_trainer, model_evaluation
- pipeline/ – orchestration of stages (stage_01_… through stage_05_…) + prediction pipeline
- config/ – code to load config files
- entity/ – dataclasses or config entities
- utils/ – common helper functions
- static/ + templates/ – front-end assets and HTML

##### README (and image)
- Confirms that the repo covers the full lifecycle of a cardio-disease model, from EDA in research/ to deployment.

a. Main components:
- Data Sources: raw CSV in data/ (heart_failure.csv)
- Configuration: config/config.yaml, params.yaml, schema.yaml
- ML Pipeline (CLI via main.py):
– Data Ingestion → Data Validation → Data Transformation → Model Trainer → Model Evaluator
– Artifacts stored under artifacts/
- Web Layer (via app.py):
– HTTP Server (Flask) + Templates/static assets
– Prediction Pipeline (loads model.joblib, scalers.pkl, label_encoders.pkl)
- Continuous Integration/Deployment:
– GitHub Actions workflow (cicd.yaml) + Dockerfile
b. Relationships and interactions:
- main.py reads configs → invokes pipeline stages in sequence → writes artifacts
- app.py loads trained model artifact → serves prediction endpoint → renders templates
- Both CLI and Web share src/Cardiovascular_Disease package
- CI/CD builds Docker image → runs tests and deploys container
c. Architectural patterns / design principles:
- Modular pipeline stages (separation of concerns)
- Config-driven design (all paths & hyperparameters in YAML)
- Package structure for reusability (components, utils, entity, config)
- Single application serving both CLI and Web
d. Key technologies / frameworks:
- Python package with setup.py
- Flask (or similar) web framework
- scikit-learn (model.joblib), pandas, numpy
- GitHub Actions, Docker

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    subgraph "Data Source"
        DS["heart_failure.csv"]:::data
    end

    %% Configuration Store
    subgraph "Configuration Store"
        YAML1["config.yaml"]:::config
        YAMLP["params.yaml"]:::config
        SCHEMA["schema.yaml"]:::config
        CONFIG_CODE["configuration.py"]:::config
        ENTITY["config_entity.py"]:::config
    end

    %% Pipeline Layer
    subgraph "Pipeline Layer"
        MAIN["main.py"]:::cli
        PACKAGE["src/Cardiovascular_Disease"]:::lib
        subgraph "Pipeline Stages"
            DI["Data Ingestion"]:::pipeline
            DV["Data Validation"]:::pipeline
            DT["Data Transformation"]:::pipeline
            MT["Model Trainer"]:::pipeline
            ME["Model Evaluation"]:::pipeline
        end
        PRED["Prediction Pipeline"]:::pipeline
    end

    %% Artifacts Store
    subgraph "Artifacts Store"
        ART_DI["data_ingestion/"]:::storage
        ART_DV["data_validation/"]:::storage
        ART_DT["data_transformation/"]:::storage
        ART_MT["model_trainer/"]:::storage
        ART_ME["model_evaluation/"]:::storage
    end

    %% Web Layer
    subgraph "Web Layer"
        APP["app.py"]:::web
        TEMPLATE["template.py"]:::web
        subgraph "Frontend Assets"
            INDEX["index.html"]:::frontend
            RESULTS["results.html"]:::frontend
            CSS["styles.css"]:::frontend
            CSS2["css2/*.css"]:::frontend
            JS["scripts.js"]:::frontend
            IMG["img/"]:::frontend
        end
    end

    %% CI/CD
    subgraph "CI/CD"
        CICD[".github/workflows/cicd.yaml"]:::ci
        DOCKER["Dockerfile"]:::ci
    end

    %% Client
    CLIENT["Browser"]:::client

    %% Data Flow: Pipeline
    DS -->|reads| DI
    YAML1 -->|loaded by| CONFIG_CODE
    YAMLP -->|loaded by| CONFIG_CODE
    SCHEMA -->|loaded by| CONFIG_CODE
    ENTITY -->|used by| CONFIG_CODE
    CONFIG_CODE -->|provides config to| DI
    CONFIG_CODE -->|provides config to| DV
    CONFIG_CODE -->|provides config to| DT
    CONFIG_CODE -->|provides config to| MT
    CONFIG_CODE -->|provides config to| ME

    MAIN -->|executes| DI
    DI -->|outputs| ART_DI
    MAIN -->|executes| DV
    ART_DI -->|input to| DV
    DV -->|outputs| ART_DV
    MAIN -->|executes| DT
    ART_DV -->|input to| DT
    DT -->|outputs| ART_DT
    MAIN -->|executes| MT
    ART_DT -->|input to| MT
    MT -->|outputs| ART_MT
    MAIN -->|executes| ME
    ART_MT -->|input to| ME
    ME -->|outputs| ART_ME

    MAIN -->|imports| PACKAGE
    APP -->|imports| PACKAGE

    %% Prediction Flow
    CLIENT -->|HTTP Request| APP
    APP -->|calls| PRED
    ART_ME -->|model artifact| PRED
    PRED -->|prediction result| APP
    APP -->|HTTP Response| CLIENT

    %% CI/CD Flow
    CICD -->|triggers| DOCKER
    DOCKER -->|builds image for| APP

    %% Click Events
    click DS "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/data/heart_failure.csv"
    click YAML1 "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/config/config.yaml"
    click YAMLP "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/params.yaml"
    click SCHEMA "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/schema.yaml"
    click CONFIG_CODE "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/config/configuration.py"
    click ENTITY "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/entity/config_entity.py"
    click DI "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/components/data_ingestion.py"
    click DI "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/stage_01_data_ingestion.py"
    click DV "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/components/data_validation.py"
    click DV "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/stage_02_data_validation.py"
    click DT "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/components/data_transformation.py"
    click DT "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/stage_03_data_transformation.py"
    click MT "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/components/model_trainer.py"
    click MT "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/stage_04_model_trainer.py"
    click ME "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/components/model_evaluation.py"
    click ME "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/stage_05_model_evaluation.py"
    click PRED "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/src/Cardiovascular_Disease/pipeline/prediction.py"
    click MAIN "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/main.py"
    click APP "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/app.py"
    click TEMPLATE "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/template.py"
    click INDEX "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/templates/index.html"
    click RESULTS "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/templates/results.html"
    click CSS "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/static/css/styles.css"
    click CSS2 "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/static/css2"
    click JS "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/static/js/scripts.js"
    click IMG "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/static/assets/img"
    click ART_DI "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/artifacts/data_ingestion/"
    click ART_DV "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/artifacts/data_validation/"
    click ART_DT "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/artifacts/data_transformation/"
    click ART_MT "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/artifacts/model_trainer/"
    click ART_ME "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/artifacts/model_evaluation/"
    click CICD "https://github.com/killich8/end-to-end-cardiovascular-disease/blob/main/.github/workflows/cicd.yaml"
    click DOCKER "https://github.com/killich8/end-to-end-cardiovascular-disease/tree/main/Dockerfile"

    %% Styles
    classDef data fill:#FFEB99,stroke:#333,stroke-width:1px
    classDef config fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef pipeline fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef storage fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef web fill:#D5E8D4,stroke:#333,stroke-width:1px
    classDef frontend fill:#E2EFDA,stroke:#333,stroke-width:1px
    classDef cli fill:#F8CECC,stroke:#333,stroke-width:1px
    classDef lib fill:#DAE8FC,stroke:#333,stroke-width:1px
    classDef client fill:#E1D5E7,stroke:#333,stroke-width:1px
    classDef ci fill:#F4CCCC,stroke:#333,stroke-width:1px
```
