# anand-nayak-git/stroke-prediction-system architecture

> Architecture diagram of the GitHub repository anand-nayak-git/stroke-prediction-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anand-nayak-git/stroke-prediction-system
- Repository: https://github.com/anand-nayak-git/stroke-prediction-system

## Overview

This Flask application serves a stroke-risk form, converts submitted demographic and health fields into model inputs, combines a trained-model prediction with threshold-based risk rules, and displays a result. Its other visible user-facing branches include a BMI calculator and counseling page. The README describes model training and evaluation, and the tree contains a dataset and training script; the sampled training code is commented out, so that branch is shown as inactive. The CTA route references a template absent from the tree. Evidence is limited to the README, tree, and sampled files.

Main entry points: [`app.py`](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py) (Flask routes), [`strokenew.pkl`](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/strokenew.pkl) (Trained model), [`templates/predict.html`](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/predict.html) (Prediction form), [`templates/bmi.html`](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/bmi.html) (BMI page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_index["Home page<br/>[index.html]"]
  node_predict_form["Prediction form<br/>[predict.html]"]
  node_counsel_page["Counseling page<br/>[counsel.html]"]
end

subgraph group_prediction["Stroke prediction"]
  node_flask["Flask routes<br/>[app.py]"]
  node_input_mapping["Input mapping<br/>[app.py]"]
  node_risk_rules["Risk decision<br/>[app.py]"]
  node_model["Trained model<br/>[strokenew.pkl]"]
  node_result["Prediction result<br/>[predict.html]"]
end

subgraph group_wellness["Health tools"]
  node_bmi_page["BMI page<br/>[bmi.html]"]
  node_bmi_calc["BMI calculator<br/>[bmijs.js]"]
  node_counsel_route["Counsel route<br/>[app.py]"]
end

subgraph group_training["Model development"]
  node_dataset["Stroke dataset"]
  node_training_script["Training pipeline<br/>[traincode.py]"]
end

node_user(("User"))

node_user -->|"opens"| node_index
node_user -->|"enters health data"| node_predict_form
node_predict_form -->|"submits form"| node_flask
node_flask -->|"processes fields"| node_input_mapping
node_input_mapping -->|"predicts with"| node_model
node_flask -->|"applies thresholds"| node_risk_rules
node_model -->|"returns class"| node_risk_rules
node_risk_rules -->|"selects message"| node_result
node_flask -->|"renders result"| node_result
node_user -->|"opens"| node_bmi_page
node_bmi_page -->|"uses calculator"| node_bmi_calc
node_user -->|"opens"| node_counsel_page
node_flask -->|"serves page"| node_counsel_route
node_dataset -.->|"loads data"| node_training_script
node_training_script -.->|"would serialize"| node_model

click node_index "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/index.html"
click node_predict_form "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/predict.html"
click node_counsel_page "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/counsel.html"
click node_flask "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py"
click node_input_mapping "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py"
click node_risk_rules "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py"
click node_model "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/strokenew.pkl"
click node_result "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/predict.html"
click node_bmi_page "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/bmi.html"
click node_bmi_calc "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/static/bmijs.js"
click node_counsel_route "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py"
click node_dataset "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/stroke%20prediction.csv"
click node_training_script "https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/traincode.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_index,node_predict_form,node_counsel_page,node_user toneBlue
class node_flask,node_input_mapping,node_risk_rules,node_model,node_result toneAmber
class node_bmi_page,node_bmi_calc,node_counsel_route toneMint
class node_dataset,node_training_script toneRose
```

## Components

### Web interface

- [Home page](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/index.html): `templates/index.html`
- [Prediction form](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/predict.html): `templates/predict.html`
- [Counseling page](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/counsel.html): `templates/counsel.html`

### Stroke prediction

- [Flask routes](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py): `app.py`
- [Input mapping](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py): `app.py`
- [Risk decision](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py): `app.py`
- [Trained model](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/strokenew.pkl): `strokenew.pkl`
- [Prediction result](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/predict.html): `templates/predict.html`

### Health tools

- [BMI page](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/templates/bmi.html): `templates/bmi.html`
- [BMI calculator](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/static/bmijs.js): `static/bmijs.js`
- [Counsel route](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/app.py): `app.py`

### Model development

- [Stroke dataset](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/stroke%20prediction.csv): `stroke prediction.csv`
- [Training pipeline](https://github.com/anand-nayak-git/stroke-prediction-system/blob/main/traincode.py): `traincode.py`

### Other components

- **User**

## Connections

- User → Home page: opens
- User → Prediction form: enters health data
- Prediction form → Flask routes: submits form
- Flask routes → Input mapping: processes fields
- Input mapping → Trained model: predicts with
- Flask routes → Risk decision: applies thresholds
- Trained model → Risk decision: returns class
- Risk decision → Prediction result: selects message
- Flask routes → Prediction result: renders result
- User → BMI page: opens
- BMI page → BMI calculator: uses calculator
- User → Counseling page: opens
- Flask routes → Counsel route: serves page
- Stroke dataset → Training pipeline: loads data
- Training pipeline → Trained model: would serialize
