# vikaskarnati/neurax architecture

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

- Interactive diagram: https://gitdiagram.com/vikaskarnati/neurax
- Repository: https://github.com/vikaskarnati/neurax

## Overview

Neurax is a Flask healthcare-management system for patients, hospitals, and administrators. Users enter through role-specific portals; authentication and role checks protect workflows for appointments, medical records, cross-hospital access, and administration. Patients can also use the health assistant and download a medical-history PDF. PostgreSQL stores application data, while helper functions support notifications, email, and auditing. The README documents capabilities such as OTP resets and appointment alerts; some route implementations were not sampled, so those links are shown only where documented or evidenced.

Main entry points: [`routes/public.py`](https://github.com/vikaskarnati/neurax/blob/main/routes/public.py) (Portal Pages), [`database.py`](https://github.com/vikaskarnati/neurax/blob/main/database.py) (PostgreSQL Data), [`routes/auth.py`](https://github.com/vikaskarnati/neurax/blob/main/routes/auth.py) (Authentication), [`routes/patient.py`](https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py) (Patient Workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web Entry"]
  node_app["Flask App<br/>[app.py]"]
  node_pages["Portal Pages<br/>[public.py]"]
  node_patientui["Patient Portal<br/>[patient.html]"]
  node_hospitalui["Hospital Portal<br/>[hospital.html]"]
  node_adminui["Admin Portal<br/>[admin.html]"]
end

subgraph group_identity["Identity &amp; Access"]
  node_auth["Authentication<br/>[auth.py]"]
  node_access["Role Access<br/>[database.py]"]
end

subgraph group_care["Care Workflows"]
  node_patient["Patient Workflows<br/>[patient.py]"]
  node_appointments["Appointments &amp; Doctors<br/>[patient.py]"]
  node_records["Medical Records<br/>[hospital.py]"]
  node_crossaccess["Cross-Hospital Access<br/>[hospital.py]"]
  node_assistant["AI Health Assistant<br/>[patient.py]"]
  node_pdf["Health Card PDF<br/>[pdf_generator.py]"]
end

subgraph group_operations["Hospital &amp; Admin"]
  node_hospital["Hospital Operations<br/>[hospital.py]"]
  node_admin["Administration<br/>[admin.py]"]
end

subgraph group_platform["Data &amp; Services"]
  node_db[("PostgreSQL Data<br/>[database.py]")]
  node_helpers["Notifications &amp; Audit<br/>[helpers.py]"]
  node_config["Runtime Configuration<br/>[config.py]"]
end

node_user(("Healthcare User"))
node_gemini{{"Google Gemini"}}
node_email{{"SMTP Email"}}

node_user -->|"uses"| node_app
node_app -->|"registers routes"| node_pages
node_app -->|"initializes schema"| node_db
node_app -->|"loads settings"| node_config
node_pages -->|"renders"| node_patientui
node_pages -->|"renders"| node_hospitalui
node_pages -->|"renders"| node_adminui
node_pages -->|"registers blueprint"| node_auth
node_pages -->|"registers blueprint"| node_patient
node_pages -->|"registers blueprint"| node_hospital
node_pages -->|"registers blueprint"| node_admin
node_patientui -.->|"submits credentials"| node_auth
node_hospitalui -.->|"submits credentials"| node_auth
node_adminui -.->|"submits credentials"| node_auth
node_auth -->|"reads and writes"| node_db
node_auth -->|"uses account helpers"| node_helpers
node_auth -.->|"issues role tokens"| node_access
node_patient -->|"reads and writes"| node_db
node_patient -->|"handles booking"| node_appointments
node_patient -->|"handles chat"| node_assistant
node_patient -->|"generates card"| node_pdf
node_appointments -->|"stores bookings"| node_db
node_hospital -->|"reads and writes"| node_db
node_hospital -->|"manages records"| node_records
node_hospital -->|"handles access requests"| node_crossaccess
node_hospital -->|"notifies and audits"| node_helpers
node_admin -->|"queries system data"| node_db
node_assistant -->|"loads patient context"| node_db
node_assistant -->|"requests responses"| node_gemini
node_pdf -->|"returns download"| node_user
node_helpers -->|"writes alerts and logs"| node_db
node_helpers -->|"sends messages"| node_email
node_config -->|"provides connection settings"| node_db
node_patient -->|"uses shared helpers"| node_helpers

click node_app "https://github.com/vikaskarnati/neurax/blob/main/app.py"
click node_pages "https://github.com/vikaskarnati/neurax/blob/main/routes/public.py"
click node_patientui "https://github.com/vikaskarnati/neurax/blob/main/templates/patient.html"
click node_hospitalui "https://github.com/vikaskarnati/neurax/blob/main/templates/hospital.html"
click node_adminui "https://github.com/vikaskarnati/neurax/blob/main/templates/admin.html"
click node_auth "https://github.com/vikaskarnati/neurax/blob/main/routes/auth.py"
click node_access "https://github.com/vikaskarnati/neurax/blob/main/database.py"
click node_patient "https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py"
click node_appointments "https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py"
click node_records "https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py"
click node_crossaccess "https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py"
click node_assistant "https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py"
click node_pdf "https://github.com/vikaskarnati/neurax/blob/main/services/pdf_generator.py"
click node_hospital "https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py"
click node_admin "https://github.com/vikaskarnati/neurax/blob/main/routes/admin.py"
click node_db "https://github.com/vikaskarnati/neurax/blob/main/database.py"
click node_helpers "https://github.com/vikaskarnati/neurax/blob/main/utils/helpers.py"
click node_config "https://github.com/vikaskarnati/neurax/blob/main/config.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,node_pages,node_patientui,node_hospitalui,node_adminui,node_user toneBlue
class node_auth,node_access toneAmber
class node_patient,node_appointments,node_records,node_crossaccess,node_assistant,node_pdf toneMint
class node_hospital,node_admin toneRose
class node_db,node_helpers,node_config,node_gemini,node_email toneIndigo
```

## Components

### Web Entry

- [Flask App](https://github.com/vikaskarnati/neurax/blob/main/app.py): `app.py`
- [Portal Pages](https://github.com/vikaskarnati/neurax/blob/main/routes/public.py): `routes/public.py`
- [Patient Portal](https://github.com/vikaskarnati/neurax/blob/main/templates/patient.html): `templates/patient.html`
- [Hospital Portal](https://github.com/vikaskarnati/neurax/blob/main/templates/hospital.html): `templates/hospital.html`
- [Admin Portal](https://github.com/vikaskarnati/neurax/blob/main/templates/admin.html): `templates/admin.html`

### Identity & Access

- [Authentication](https://github.com/vikaskarnati/neurax/blob/main/routes/auth.py): `routes/auth.py`
- [Role Access](https://github.com/vikaskarnati/neurax/blob/main/database.py): `database.py`

### Care Workflows

- [Patient Workflows](https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py): `routes/patient.py`
- [Appointments & Doctors](https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py): `routes/patient.py`
- [Medical Records](https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py): `routes/hospital.py`
- [Cross-Hospital Access](https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py): `routes/hospital.py`
- [AI Health Assistant](https://github.com/vikaskarnati/neurax/blob/main/routes/patient.py): `routes/patient.py`
- [Health Card PDF](https://github.com/vikaskarnati/neurax/blob/main/services/pdf_generator.py): `services/pdf_generator.py`

### Hospital & Admin

- [Hospital Operations](https://github.com/vikaskarnati/neurax/blob/main/routes/hospital.py): `routes/hospital.py`
- [Administration](https://github.com/vikaskarnati/neurax/blob/main/routes/admin.py): `routes/admin.py`

### Data & Services

- [PostgreSQL Data](https://github.com/vikaskarnati/neurax/blob/main/database.py): `database.py`
- [Notifications & Audit](https://github.com/vikaskarnati/neurax/blob/main/utils/helpers.py): `utils/helpers.py`
- [Runtime Configuration](https://github.com/vikaskarnati/neurax/blob/main/config.py): `config.py`

### Other components

- **Healthcare User**
- **Google Gemini**
- **SMTP Email**

## Connections

- Healthcare User → Flask App: uses (evidence: `README.md`)
- Flask App → Portal Pages: registers routes (evidence: `app.py`)
- Flask App → PostgreSQL Data: initializes schema (evidence: `app.py`)
- Flask App → Runtime Configuration: loads settings (evidence: `app.py`)
- Portal Pages → Patient Portal: renders (evidence: `routes/public.py`)
- Portal Pages → Hospital Portal: renders (evidence: `routes/public.py`)
- Portal Pages → Admin Portal: renders (evidence: `routes/public.py`)
- Portal Pages → Authentication: registers blueprint (evidence: `routes/__init__.py`)
- Portal Pages → Patient Workflows: registers blueprint (evidence: `routes/__init__.py`)
- Portal Pages → Hospital Operations: registers blueprint (evidence: `routes/__init__.py`)
- Portal Pages → Administration: registers blueprint (evidence: `routes/__init__.py`)
- Patient Portal → Authentication: submits credentials
- Hospital Portal → Authentication: submits credentials
- Admin Portal → Authentication: submits credentials
- Authentication → PostgreSQL Data: reads and writes (evidence: `routes/auth.py`)
- Authentication → Notifications & Audit: uses account helpers (evidence: `routes/auth.py`)
- Authentication → Role Access: issues role tokens (evidence: `README.md`)
- Patient Workflows → PostgreSQL Data: reads and writes (evidence: `routes/patient.py`)
- Patient Workflows → Appointments & Doctors: handles booking (evidence: `routes/patient.py`)
- Patient Workflows → AI Health Assistant: handles chat (evidence: `routes/patient.py`)
- Patient Workflows → Health Card PDF: generates card (evidence: `routes/patient.py`)
- Appointments & Doctors → PostgreSQL Data: stores bookings (evidence: `routes/patient.py`)
- Hospital Operations → PostgreSQL Data: reads and writes (evidence: `routes/hospital.py`)
- Hospital Operations → Medical Records: manages records (evidence: `routes/hospital.py`)
- Hospital Operations → Cross-Hospital Access: handles access requests (evidence: `routes/hospital.py`)
- Hospital Operations → Notifications & Audit: notifies and audits (evidence: `routes/hospital.py`)
- Administration → PostgreSQL Data: queries system data (evidence: `routes/admin.py`)
- AI Health Assistant → PostgreSQL Data: loads patient context (evidence: `routes/patient.py`)
- AI Health Assistant → Google Gemini: requests responses (evidence: `routes/patient.py`)
- Health Card PDF → Healthcare User: returns download (evidence: `services/pdf_generator.py`)
- Notifications & Audit → PostgreSQL Data: writes alerts and logs (evidence: `utils/helpers.py`)
- Notifications & Audit → SMTP Email: sends messages (evidence: `utils/helpers.py`)
- Runtime Configuration → PostgreSQL Data: provides connection settings (evidence: `database.py`)
- Patient Workflows → Notifications & Audit: uses shared helpers (evidence: `routes/patient.py`)
