# dharshiniramdj/heart-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/dharshiniramdj/heart-analyzer
- Repository: https://github.com/dharshiniramdj/heart-analyzer

## Overview

Heart Analyzer is a local Streamlit screening app: users enter clinical measurements, submit them for an SVM prediction, and receive a risk message, health score, likely contributing factor, and follow-up guidance. The main source combines data preparation, model training, the interface, and inference. The README describes heart.csv as the training dataset, but the shown code reads from a hard-coded machine-specific path, so the graph does not assert that the repository CSV is actually loaded. All implementation nodes therefore point to the single sampled source file.

Main entry points: [`heart_analyzer.py`](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py) (Risk prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model preparation"]
  node_source_data["Clinical data file"]
  node_preparation["Load and prepare data<br/>[heart_analyzer.py]"]
  node_scaler["Feature scaler<br/>[heart_analyzer.py]"]
  node_classifier["SVM classifier<br/>[heart_analyzer.py]"]
end

subgraph group_interaction["User interaction"]
  node_medical_sidebar["Medical guidance sidebar<br/>[heart_analyzer.py]"]
  node_parameter_form["Health parameter inputs<br/>[heart_analyzer.py]"]
  node_encoding["Input encoding<br/>[heart_analyzer.py]"]
end

subgraph group_results["Risk results"]
  node_prediction["Risk prediction<br/>[heart_analyzer.py]"]
  node_risk_message["Risk status message<br/>[heart_analyzer.py]"]
  node_health_score["Health score<br/>[heart_analyzer.py]"]
  node_risk_factors["Likely risk factors<br/>[heart_analyzer.py]"]
  node_next_steps["Follow-up guidance<br/>[heart_analyzer.py]"]
end

node_user(("Health app user"))

node_user -->|"enters values"| node_parameter_form
node_user -->|"views guidance"| node_medical_sidebar
node_source_data -->|"loads data"| node_preparation
node_preparation -->|"fits on features"| node_scaler
node_scaler -->|"transforms training data"| node_classifier
node_preparation -->|"trains model"| node_classifier
node_parameter_form -->|"provides selections"| node_encoding
node_encoding -->|"transforms input"| node_scaler
node_encoding -->|"submits on click"| node_prediction
node_prediction -->|"calls predict"| node_classifier
node_prediction -->|"calls predict_proba"| node_classifier
node_prediction -->|"displays result"| node_risk_message
node_prediction -->|"computes score"| node_health_score
node_prediction -->|"ranks factors"| node_risk_factors
node_prediction -->|"shows guidance"| node_next_steps

click node_preparation "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_scaler "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_classifier "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_medical_sidebar "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_parameter_form "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_encoding "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_prediction "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_risk_message "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_health_score "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_risk_factors "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py"
click node_next_steps "https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.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_source_data,node_preparation,node_scaler,node_classifier,node_user toneBlue
class node_medical_sidebar,node_parameter_form,node_encoding toneAmber
class node_prediction,node_risk_message,node_health_score,node_risk_factors,node_next_steps toneMint
```

## Components

### Model preparation

- **Clinical data file**
- [Load and prepare data](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Feature scaler](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [SVM classifier](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`

### User interaction

- [Medical guidance sidebar](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Health parameter inputs](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Input encoding](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`

### Risk results

- [Risk prediction](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Risk status message](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Health score](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Likely risk factors](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`
- [Follow-up guidance](https://github.com/dharshiniramdj/heart-analyzer/blob/main/heart_analyzer.py): `heart_analyzer.py`

### Other components

- **Health app user**

## Connections

- Health app user → Health parameter inputs: enters values (evidence: `heart_analyzer.py`)
- Health app user → Medical guidance sidebar: views guidance (evidence: `heart_analyzer.py`)
- Clinical data file → Load and prepare data: loads data (evidence: `heart_analyzer.py`)
- Load and prepare data → Feature scaler: fits on features (evidence: `heart_analyzer.py`)
- Feature scaler → SVM classifier: transforms training data (evidence: `heart_analyzer.py`)
- Load and prepare data → SVM classifier: trains model (evidence: `heart_analyzer.py`)
- Health parameter inputs → Input encoding: provides selections (evidence: `heart_analyzer.py`)
- Input encoding → Feature scaler: transforms input (evidence: `heart_analyzer.py`)
- Input encoding → Risk prediction: submits on click (evidence: `heart_analyzer.py`)
- Risk prediction → SVM classifier: calls predict (evidence: `heart_analyzer.py`)
- Risk prediction → SVM classifier: calls predict_proba (evidence: `heart_analyzer.py`)
- Risk prediction → Risk status message: displays result (evidence: `heart_analyzer.py`)
- Risk prediction → Health score: computes score (evidence: `heart_analyzer.py`)
- Risk prediction → Likely risk factors: ranks factors (evidence: `heart_analyzer.py`)
- Risk prediction → Follow-up guidance: shows guidance (evidence: `heart_analyzer.py`)
