# spidy52/heart_attack architecture

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

- Interactive diagram: https://gitdiagram.com/spidy52/heart_attack
- Repository: https://github.com/spidy52/heart_attack

## Overview

This repository is a heart-disease prediction and analysis project with parallel decision-tree and XGBoost workflows, fuzzy-clustering analysis, generated reports, and an XGBoost Flask risk-entry interface. Training scripts read the heart dataset, fit classifiers, evaluate them, and produce prediction outputs and artifacts. The web app accepts patient measurements and uses the saved XGBoost model to return a risk presentation. The graph reflects the sampled scripts; the README is empty, and artifact relationships are included only where shown by source.

Main entry points: [`heart.csv`](https://github.com/spidy52/heart_attack/blob/main/heart.csv) (Heart Dataset), [`Decisiontree.py`](https://github.com/spidy52/heart_attack/blob/main/Decisiontree.py) (Train and Evaluate), [`Xgboost.py`](https://github.com/spidy52/heart_attack/blob/main/Xgboost.py) (Train and Evaluate), [`xgboost/app.py`](https://github.com/spidy52/heart_attack/blob/main/xgboost/app.py) (Risk Prediction and Display)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset"]
  node_heartdata["Heart Dataset<br/>[heart.csv]"]
end

subgraph group_dt["Decision Tree Analysis"]
  node_dttrain["Train and Evaluate<br/>[Decisiontree.py]"]
  node_dtvisual["Tree and Fuzzy Reports<br/>[decisiontreepng.py]"]
  node_dtmodel["Decision Tree Model<br/>[decision_tree.pkl]"]
  node_dtpred["DT Predictions"]
  node_dtreport["DT Report Artifacts<br/>[full_report.pdf]"]
end

subgraph group_xgb["XGBoost Analysis"]
  node_xgbtrain["Train and Evaluate<br/>[Xgboost.py]"]
  node_xgbvisual["Fuzzy and Report Outputs<br/>[xgboostpng.py]"]
  node_xgbmodel["XGBoost Model<br/>[xgb_model.pkl]"]
  node_xgbpred["XGBoost Predictions"]
  node_xgbreport["XGBoost Report<br/>[full_report.pdf]"]
end

subgraph group_web["Risk Web App"]
  node_form["Patient Risk Form<br/>[app.py]"]
  node_risk["Risk Prediction and Display<br/>[app.py]"]
end

node_user(("Patient / User"))
node_clinician(("Clinician"))

node_dttrain -->|"reads"| node_heartdata
node_dtvisual -->|"reads"| node_heartdata
node_dttrain -->|"writes"| node_dtmodel
node_dttrain -->|"writes"| node_dtpred
node_dtvisual -->|"writes"| node_dtreport
node_xgbtrain -->|"reads"| node_heartdata
node_xgbvisual -->|"reads"| node_heartdata
node_xgbtrain -->|"writes"| node_xgbmodel
node_xgbtrain -->|"writes"| node_xgbpred
node_xgbvisual -->|"writes"| node_xgbreport
node_clinician -->|"enters data"| node_form
node_form -->|"submits measurements"| node_risk
node_risk -->|"loads and predicts"| node_xgbmodel
node_risk -->|"displays risk"| node_clinician

click node_heartdata "https://github.com/spidy52/heart_attack/blob/main/heart.csv"
click node_dttrain "https://github.com/spidy52/heart_attack/blob/main/Decisiontree.py"
click node_dtvisual "https://github.com/spidy52/heart_attack/blob/main/decisiontreepng.py"
click node_dtmodel "https://github.com/spidy52/heart_attack/blob/main/output/decision_tree.pkl"
click node_dtpred "https://github.com/spidy52/heart_attack/blob/main/decision_tree_predictions.csv"
click node_dtreport "https://github.com/spidy52/heart_attack/blob/main/output/full_report.pdf"
click node_xgbtrain "https://github.com/spidy52/heart_attack/blob/main/Xgboost.py"
click node_xgbvisual "https://github.com/spidy52/heart_attack/blob/main/xgboostpng.py"
click node_xgbmodel "https://github.com/spidy52/heart_attack/blob/main/xgboost/xgb_model.pkl"
click node_xgbpred "https://github.com/spidy52/heart_attack/blob/main/xgboost_predictions.csv"
click node_xgbreport "https://github.com/spidy52/heart_attack/blob/main/xgboost/full_report.pdf"
click node_form "https://github.com/spidy52/heart_attack/blob/main/xgboost/app.py"
click node_risk "https://github.com/spidy52/heart_attack/blob/main/xgboost/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_heartdata,node_user toneBlue
class node_dttrain,node_dtvisual,node_dtmodel,node_dtpred,node_dtreport toneAmber
class node_xgbtrain,node_xgbvisual,node_xgbmodel,node_xgbpred,node_xgbreport toneMint
class node_form,node_risk toneRose
class node_clinician toneIndigo
```

## Components

### Dataset

- [Heart Dataset](https://github.com/spidy52/heart_attack/blob/main/heart.csv): `heart.csv`

### Decision Tree Analysis

- [Train and Evaluate](https://github.com/spidy52/heart_attack/blob/main/Decisiontree.py): `Decisiontree.py`
- [Tree and Fuzzy Reports](https://github.com/spidy52/heart_attack/blob/main/decisiontreepng.py): `decisiontreepng.py`
- [Decision Tree Model](https://github.com/spidy52/heart_attack/blob/main/output/decision_tree.pkl): `output/decision_tree.pkl`
- [DT Predictions](https://github.com/spidy52/heart_attack/blob/main/decision_tree_predictions.csv): `decision_tree_predictions.csv`
- [DT Report Artifacts](https://github.com/spidy52/heart_attack/blob/main/output/full_report.pdf): `output/full_report.pdf`

### XGBoost Analysis

- [Train and Evaluate](https://github.com/spidy52/heart_attack/blob/main/Xgboost.py): `Xgboost.py`
- [Fuzzy and Report Outputs](https://github.com/spidy52/heart_attack/blob/main/xgboostpng.py): `xgboostpng.py`
- [XGBoost Model](https://github.com/spidy52/heart_attack/blob/main/xgboost/xgb_model.pkl): `xgboost/xgb_model.pkl`
- [XGBoost Predictions](https://github.com/spidy52/heart_attack/blob/main/xgboost_predictions.csv): `xgboost_predictions.csv`
- [XGBoost Report](https://github.com/spidy52/heart_attack/blob/main/xgboost/full_report.pdf): `xgboost/full_report.pdf`

### Risk Web App

- [Patient Risk Form](https://github.com/spidy52/heart_attack/blob/main/xgboost/app.py): `xgboost/app.py`
- [Risk Prediction and Display](https://github.com/spidy52/heart_attack/blob/main/xgboost/app.py): `xgboost/app.py`

### Other components

- **Patient / User**
- **Clinician**

## Connections

- Train and Evaluate → Heart Dataset: reads (evidence: `Decisiontree.py`)
- Tree and Fuzzy Reports → Heart Dataset: reads (evidence: `decisiontreepng.py`)
- Train and Evaluate → Decision Tree Model: writes
- Train and Evaluate → DT Predictions: writes (evidence: `Decisiontree.py`)
- Tree and Fuzzy Reports → DT Report Artifacts: writes (evidence: `decisiontreepng.py`)
- Train and Evaluate → Heart Dataset: reads (evidence: `Xgboost.py`)
- Fuzzy and Report Outputs → Heart Dataset: reads (evidence: `xgboostpng.py`)
- Train and Evaluate → XGBoost Model: writes
- Train and Evaluate → XGBoost Predictions: writes (evidence: `Xgboost.py`)
- Fuzzy and Report Outputs → XGBoost Report: writes (evidence: `xgboostpng.py`)
- Clinician → Patient Risk Form: enters data (evidence: `xgboost/app.py`)
- Patient Risk Form → Risk Prediction and Display: submits measurements (evidence: `xgboost/app.py`)
- Risk Prediction and Display → XGBoost Model: loads and predicts (evidence: `xgboost/app.py`)
- Risk Prediction and Display → Clinician: displays risk (evidence: `xgboost/app.py`)
