# user-waron/med_project architecture

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

- Interactive diagram: https://gitdiagram.com/user-waron/med_project
- Repository: https://github.com/user-waron/med_project

## Overview

This is a clinical intake and risk-triage dashboard. Staff upload a report for extraction or enter CBC/CMP values manually; the browser sends the patient data to Flask, which scores and routes the case, persists it, and the dashboard retrieves cases for intern or senior review. Report extraction and the external notification integration are separate capabilities. Source excerpts show the browser calls, database operations, and extraction request; model inference details and some UI wiring are in omitted sections, so those links are marked unverified or omitted.

Main entry points: [`app.py`](https://github.com/user-waron/med_project/blob/main/app.py) (Flask routes), [`static/js/api.js`](https://github.com/user-waron/med_project/blob/main/static/js/api.js) (Browser API), [`static/js/main.js`](https://github.com/user-waron/med_project/blob/main/static/js/main.js) (Intake workflow), [`patients.db`](https://github.com/user-waron/med_project/blob/main/patients.db) (Patient reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Clinical dashboard"]
  node_dashboard["Dashboard shell<br/>[index.html]"]
  node_workflow["Intake workflow<br/>[main.js]"]
  node_api["Browser API<br/>[api.js]"]
  node_views["Dashboard views<br/>[ui.js]"]
end

subgraph group_server["Triage backend"]
  node_routes["Flask routes<br/>[app.py]"]
  node_extraction["Report extraction<br/>[app.py]"]
  node_risk["Risk scoring<br/>[app.py]"]
  node_triage["Case routing<br/>[app.py]"]
  node_case_queries["Dashboard queries<br/>[app.py]"]
  node_database[("Patient reports<br/>[patients.db]")]
  node_model_training["Risk model training<br/>[train_model.py]"]
end

subgraph group_integrations["External services"]
  node_groq{{"Groq extraction API"}}
  node_n8n{{"n8n notifications"}}
end

node_clinician(("Clinical staff"))

node_clinician -.->|"enters data"| node_workflow
node_workflow -->|"requests data"| node_api
node_workflow -->|"renders views"| node_views
node_api -->|"calls endpoints"| node_routes
node_routes -->|"reads cases"| node_database
node_routes -->|"upserts reports"| node_database
node_routes -.->|"scores patients"| node_risk
node_risk -.->|"assigns cases"| node_triage
node_triage -->|"stores assignment"| node_database
node_api -->|"uploads report"| node_extraction
node_extraction -->|"requests extraction"| node_groq
node_extraction -->|"returns fields"| node_workflow
node_routes -->|"sends alerts"| node_n8n
node_model_training -.->|"trains model"| node_risk
node_case_queries -->|"queries cases"| node_database
node_routes -.->|"serves dashboards"| node_case_queries
node_api -->|"fetches dashboards"| node_case_queries

click node_dashboard "https://github.com/user-waron/med_project/blob/main/static/index.html"
click node_workflow "https://github.com/user-waron/med_project/blob/main/static/js/main.js"
click node_api "https://github.com/user-waron/med_project/blob/main/static/js/api.js"
click node_views "https://github.com/user-waron/med_project/blob/main/static/js/ui.js"
click node_routes "https://github.com/user-waron/med_project/blob/main/app.py"
click node_extraction "https://github.com/user-waron/med_project/blob/main/app.py"
click node_risk "https://github.com/user-waron/med_project/blob/main/app.py"
click node_triage "https://github.com/user-waron/med_project/blob/main/app.py"
click node_case_queries "https://github.com/user-waron/med_project/blob/main/app.py"
click node_database "https://github.com/user-waron/med_project/blob/main/patients.db"
click node_model_training "https://github.com/user-waron/med_project/blob/main/train_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_dashboard,node_workflow,node_api,node_views toneBlue
class node_routes,node_extraction,node_risk,node_triage,node_case_queries,node_database,node_model_training toneAmber
class node_groq,node_n8n toneMint
class node_clinician toneIndigo
```

## Components

### Clinical dashboard

- [Dashboard shell](https://github.com/user-waron/med_project/blob/main/static/index.html): `static/index.html`
- [Intake workflow](https://github.com/user-waron/med_project/blob/main/static/js/main.js): `static/js/main.js`
- [Browser API](https://github.com/user-waron/med_project/blob/main/static/js/api.js): `static/js/api.js`
- [Dashboard views](https://github.com/user-waron/med_project/blob/main/static/js/ui.js): `static/js/ui.js`

### Triage backend

- [Flask routes](https://github.com/user-waron/med_project/blob/main/app.py): `app.py`
- [Report extraction](https://github.com/user-waron/med_project/blob/main/app.py): `app.py`
- [Risk scoring](https://github.com/user-waron/med_project/blob/main/app.py): `app.py`
- [Case routing](https://github.com/user-waron/med_project/blob/main/app.py): `app.py`
- [Dashboard queries](https://github.com/user-waron/med_project/blob/main/app.py): `app.py`
- [Patient reports](https://github.com/user-waron/med_project/blob/main/patients.db): `patients.db`
- [Risk model training](https://github.com/user-waron/med_project/blob/main/train_model.py): `train_model.py`

### External services

- **Groq extraction API**
- **n8n notifications**

### Other components

- **Clinical staff**

## Connections

- Clinical staff → Intake workflow: enters data
- Intake workflow → Browser API: requests data (evidence: `static/js/main.js`)
- Intake workflow → Dashboard views: renders views (evidence: `static/js/main.js`)
- Browser API → Flask routes: calls endpoints (evidence: `static/js/api.js`)
- Flask routes → Patient reports: reads cases (evidence: `app.py`)
- Flask routes → Patient reports: upserts reports (evidence: `app.py`)
- Flask routes → Risk scoring: scores patients (evidence: `app.py`)
- Risk scoring → Case routing: assigns cases (evidence: `app.py`)
- Case routing → Patient reports: stores assignment (evidence: `app.py`)
- Browser API → Report extraction: uploads report (evidence: `static/js/api.js`)
- Report extraction → Groq extraction API: requests extraction (evidence: `app.py`)
- Report extraction → Intake workflow: returns fields (evidence: `static/js/main.js`)
- Flask routes → n8n notifications: sends alerts (evidence: `app.py`)
- Risk model training → Risk scoring: trains model
- Dashboard queries → Patient reports: queries cases (evidence: `app.py`)
- Flask routes → Dashboard queries: serves dashboards (evidence: `app.py`)
- Browser API → Dashboard queries: fetches dashboards (evidence: `static/js/api.js`)
