# moneshram/neurorisk-ai architecture

> Architecture diagram of the GitHub repository moneshram/neurorisk-ai, 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/moneshram/neurorisk-ai
- Repository: https://github.com/moneshram/neurorisk-ai

## Overview

NeuroRisk AI is a full-stack, tabular stroke-risk assessment application with user and administrator experiences. Users register or sign in, submit clinical and demographic inputs, receive a risk estimate, and review dashboards, history, and reports. Administrators also have batch CSV analysis and reporting capabilities. The backend combines Flask API routes, JWT role checks, persisted user and prediction records, and an ML pipeline. Edges reflect sampled imports/calls or README statements; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/App.tsx) (Routes and app shell), [`backend/app.py`](https://github.com/moneshram/neurorisk-ai/blob/main/backend/app.py) (Flask API routes), [`frontend/src/lib/api.ts`](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/lib/api.ts) (API client), [`frontend/src/pages/Register.tsx`](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Register.tsx) (Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend experience"]
  node_app_ui["Routes and app shell<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_identity["Identity and accounts"]
  node_register_ui["Registration<br/>[Register.tsx]"]
  node_account_ui["Login and account flows"]
  node_role_guard["JWT role guard<br/>[auth.py]"]
end

subgraph group_assessment["Risk assessment"]
  node_assessment_ui["Clinical assessment form<br/>[Assessment.tsx]"]
  node_history_ui["Dashboard and history"]
  node_results_ui["Prediction results<br/>[Results.tsx]"]
end

subgraph group_operations["Admin and batch"]
  node_batch_ui["Batch analysis screens"]
  node_batch_client["Batch API client<br/>[batchApi.ts]"]
  node_batch_engine["Batch prediction<br/>[batch.py]"]
  node_batch_report["Batch reports<br/>[batch_report.py]"]
end

subgraph group_backend["API and model"]
  node_flask_api["Flask API routes<br/>[app.py]"]
  node_records[("User and prediction records<br/>[models.py]")]
  node_ml_pipeline["Prediction pipeline<br/>[pipeline.py]"]
  node_report_engine["PDF reports<br/>[report.py]"]
  node_trainer["Model training"]
end

node_user(("User"))
node_admin(("Administrator"))
node_smtp["SMTP email service"]
node_google["Google sign-in"]

node_user -->|"uses"| node_app_ui
node_admin -->|"uses"| node_app_ui
node_app_ui -->|"routes to"| node_register_ui
node_app_ui -->|"routes to"| node_account_ui
node_app_ui -->|"routes to"| node_assessment_ui
node_app_ui -->|"routes to"| node_history_ui
node_app_ui -->|"routes to"| node_results_ui
node_app_ui -->|"routes to"| node_batch_ui
node_register_ui -->|"submits registration"| node_api_client
node_assessment_ui -->|"requests prediction"| node_api_client
node_api_client -->|"sends API requests"| node_flask_api
node_flask_api -->|"checks roles"| node_role_guard
node_flask_api -->|"reads and writes"| node_records
node_flask_api -->|"loads prediction pipeline"| node_ml_pipeline
node_flask_api -->|"invokes batch analysis"| node_batch_engine
node_flask_api -->|"uses report generation"| node_report_engine
node_batch_ui -->|"uses batch API"| node_batch_client
node_batch_client -->|"sends batch requests"| node_flask_api
node_batch_engine -.->|"generates batch report"| node_batch_report
node_trainer -->|"saves trained pipeline"| node_ml_pipeline
node_flask_api -.->|"sends reset email"| node_smtp
node_account_ui -.->|"offers sign-in"| node_google

click node_app_ui "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/App.tsx"
click node_register_ui "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Register.tsx"
click node_account_ui "https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages"
click node_api_client "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/lib/api.ts"
click node_assessment_ui "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Assessment.tsx"
click node_history_ui "https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages"
click node_results_ui "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Results.tsx"
click node_batch_ui "https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages"
click node_batch_client "https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/lib/batchApi.ts"
click node_flask_api "https://github.com/moneshram/neurorisk-ai/blob/main/backend/app.py"
click node_role_guard "https://github.com/moneshram/neurorisk-ai/blob/main/backend/auth.py"
click node_records "https://github.com/moneshram/neurorisk-ai/blob/main/backend/models.py"
click node_ml_pipeline "https://github.com/moneshram/neurorisk-ai/blob/main/backend/ml/pipeline.py"
click node_batch_engine "https://github.com/moneshram/neurorisk-ai/blob/main/backend/batch.py"
click node_report_engine "https://github.com/moneshram/neurorisk-ai/blob/main/backend/report.py"
click node_batch_report "https://github.com/moneshram/neurorisk-ai/blob/main/backend/batch_report.py"
click node_trainer "https://github.com/moneshram/neurorisk-ai/blob/main/backend/train_stroke_model.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_app_ui,node_api_client,node_user toneBlue
class node_register_ui,node_account_ui,node_role_guard toneAmber
class node_assessment_ui,node_history_ui,node_results_ui toneMint
class node_batch_ui,node_batch_client,node_batch_engine,node_batch_report toneRose
class node_flask_api,node_records,node_ml_pipeline,node_report_engine,node_trainer,node_admin,node_smtp,node_google toneIndigo
```

## Components

### Frontend experience

- [Routes and app shell](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Identity and accounts

- [Registration](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Register.tsx): `frontend/src/pages/Register.tsx`
- [Login and account flows](https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages): `frontend/src/pages`
- [JWT role guard](https://github.com/moneshram/neurorisk-ai/blob/main/backend/auth.py): `backend/auth.py`

### Risk assessment

- [Clinical assessment form](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Assessment.tsx): `frontend/src/pages/Assessment.tsx`
- [Dashboard and history](https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages): `frontend/src/pages`
- [Prediction results](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/pages/Results.tsx): `frontend/src/pages/Results.tsx`

### Admin and batch

- [Batch analysis screens](https://github.com/moneshram/neurorisk-ai/tree/main/frontend/src/pages): `frontend/src/pages`
- [Batch API client](https://github.com/moneshram/neurorisk-ai/blob/main/frontend/src/lib/batchApi.ts): `frontend/src/lib/batchApi.ts`
- [Batch prediction](https://github.com/moneshram/neurorisk-ai/blob/main/backend/batch.py): `backend/batch.py`
- [Batch reports](https://github.com/moneshram/neurorisk-ai/blob/main/backend/batch_report.py): `backend/batch_report.py`

### API and model

- [Flask API routes](https://github.com/moneshram/neurorisk-ai/blob/main/backend/app.py): `backend/app.py`
- [User and prediction records](https://github.com/moneshram/neurorisk-ai/blob/main/backend/models.py): `backend/models.py`
- [Prediction pipeline](https://github.com/moneshram/neurorisk-ai/blob/main/backend/ml/pipeline.py): `backend/ml/pipeline.py`
- [PDF reports](https://github.com/moneshram/neurorisk-ai/blob/main/backend/report.py): `backend/report.py`
- [Model training](https://github.com/moneshram/neurorisk-ai/blob/main/backend/train_stroke_model.py): `backend/train_stroke_model.py`

### Other components

- **User**
- **Administrator**
- **SMTP email service**
- **Google sign-in**

## Connections

- User → Routes and app shell: uses (evidence: `frontend/src/App.tsx`)
- Administrator → Routes and app shell: uses (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Registration: routes to (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Login and account flows: routes to (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Clinical assessment form: routes to (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Dashboard and history: routes to (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Prediction results: routes to (evidence: `frontend/src/App.tsx`)
- Routes and app shell → Batch analysis screens: routes to (evidence: `frontend/src/App.tsx`)
- Registration → API client: submits registration (evidence: `frontend/src/pages/Register.tsx`)
- Clinical assessment form → API client: requests prediction (evidence: `frontend/src/pages/Assessment.tsx`)
- API client → Flask API routes: sends API requests (evidence: `frontend/src/lib/api.ts`)
- Flask API routes → JWT role guard: checks roles (evidence: `backend/app.py`)
- Flask API routes → User and prediction records: reads and writes (evidence: `backend/app.py`)
- Flask API routes → Prediction pipeline: loads prediction pipeline (evidence: `backend/app.py`)
- Flask API routes → Batch prediction: invokes batch analysis (evidence: `backend/app.py`)
- Flask API routes → PDF reports: uses report generation (evidence: `backend/app.py`)
- Batch analysis screens → Batch API client: uses batch API (evidence: `frontend/src/pages/batch/ResultsTable.tsx`)
- Batch API client → Flask API routes: sends batch requests (evidence: `frontend/src/lib/batchApi.ts`)
- Batch prediction → Batch reports: generates batch report
- Model training → Prediction pipeline: saves trained pipeline (evidence: `README.md`)
- Flask API routes → SMTP email service: sends reset email (evidence: `README.md`)
- Login and account flows → Google sign-in: offers sign-in (evidence: `README.md`)
