# termuxbash/hospitalmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/termuxbash/hospitalmanagement
- Repository: https://github.com/termuxbash/hospitalmanagement

## Overview

CareDesk is a Flask hospital-records application: staff log in, then review the dashboard or manage patients, doctors, consultations, and consultation-linked billing. The app owns request handling, validation, and SQLite access; SQL files provide the schema, summary views, and audit/history triggers. Database selection is persisted in a configuration file. The README documents these capabilities, but most route implementations and SQL files were not sampled, so unsampled links rely only on documented relationships.

Main entry points: [`app.py`](https://github.com/termuxbash/hospitalmanagement/blob/main/app.py) (Flask routes), [`hospital.db`](https://github.com/termuxbash/hospitalmanagement/blob/main/hospital.db) (SQLite database), [`init.sql`](https://github.com/termuxbash/hospitalmanagement/blob/main/init.sql) (Core schema), [`views.sql`](https://github.com/termuxbash/hospitalmanagement/blob/main/views.sql) (Summary views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask routes<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
  node_login["Staff login<br/>[login.html]"]
end

subgraph group_records["Clinical records"]
  node_patient["Patient directory<br/>[patients.html]"]
  node_doctor["Doctor directory<br/>[doctors.html]"]
  node_consultation["Consultations<br/>[consultations.html]"]
  node_patientform["Patient entry<br/>[patient_form.html]"]
  node_doctorform["Doctor entry<br/>[doctor_form.html]"]
  node_consultform["Consultation entry"]
end

subgraph group_billing["Billing"]
  node_billing["Billing ledger<br/>[billing.html]"]
  node_billingform["Billing entry<br/>[billing_form.html]"]
  node_audit["Billing audit<br/>[billing_audit.html]"]
end

subgraph group_storage["Persistence"]
  node_settings["Database settings"]
  node_config["Database selection"]
  node_schema["Core schema<br/>[init.sql]"]
  node_views["Summary views<br/>[views.sql]"]
  node_triggers["History and audit triggers<br/>[triggers.sql]"]
  node_db[("SQLite database<br/>[hospital.db]")]
end

node_staff(("Hospital staff"))

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_login
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_patient
node_app -->|"renders"| node_doctor
node_app -->|"renders"| node_consultation
node_app -->|"renders"| node_billing
node_app -.->|"renders"| node_billingform
node_app -->|"renders"| node_audit
node_app -->|"renders"| node_settings
node_app -.->|"renders"| node_patientform
node_app -.->|"renders"| node_doctorform
node_app -.->|"renders"| node_consultform
node_app -->|"reads and writes"| node_db
node_app -->|"reads and updates"| node_config
node_app -->|"initializes from"| node_schema
node_app -->|"initializes from"| node_views
node_app -->|"initializes from"| node_triggers
node_schema -->|"defines tables"| node_db
node_views -->|"provides summaries"| node_db
node_triggers -->|"records history and audit"| node_db
node_app -->|"shows totals"| node_dashboard
node_app -->|"searches patients"| node_patient
node_app -->|"links patient and doctor"| node_consultation
node_app -->|"links billing to consultations"| node_billing
node_app -->|"reviews billing changes"| node_audit

click node_app "https://github.com/termuxbash/hospitalmanagement/blob/main/app.py"
click node_dashboard "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/dashboard.html"
click node_login "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/login.html"
click node_patient "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/patients.html"
click node_doctor "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/doctors.html"
click node_consultation "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/consultations.html"
click node_patientform "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/patient_form.html"
click node_doctorform "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/doctor_form.html"
click node_consultform "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/consultation_form.html"
click node_billing "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing.html"
click node_billingform "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing_form.html"
click node_audit "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing_audit.html"
click node_settings "https://github.com/termuxbash/hospitalmanagement/blob/main/templates/database_settings.html"
click node_config "https://github.com/termuxbash/hospitalmanagement/blob/main/database_config.json"
click node_schema "https://github.com/termuxbash/hospitalmanagement/blob/main/init.sql"
click node_views "https://github.com/termuxbash/hospitalmanagement/blob/main/views.sql"
click node_triggers "https://github.com/termuxbash/hospitalmanagement/blob/main/triggers.sql"
click node_db "https://github.com/termuxbash/hospitalmanagement/blob/main/hospital.db"

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_dashboard,node_login toneBlue
class node_patient,node_doctor,node_consultation,node_patientform,node_doctorform,node_consultform toneAmber
class node_billing,node_billingform,node_audit toneMint
class node_settings,node_config,node_schema,node_views,node_triggers,node_db toneRose
class node_staff toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/termuxbash/hospitalmanagement/blob/main/app.py): `app.py`
- [Dashboard](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Staff login](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/login.html): `templates/login.html`

### Clinical records

- [Patient directory](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/patients.html): `templates/patients.html`
- [Doctor directory](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/doctors.html): `templates/doctors.html`
- [Consultations](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/consultations.html): `templates/consultations.html`
- [Patient entry](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/patient_form.html): `templates/patient_form.html`
- [Doctor entry](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/doctor_form.html): `templates/doctor_form.html`
- [Consultation entry](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/consultation_form.html): `templates/consultation_form.html`

### Billing

- [Billing ledger](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing.html): `templates/billing.html`
- [Billing entry](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing_form.html): `templates/billing_form.html`
- [Billing audit](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/billing_audit.html): `templates/billing_audit.html`

### Persistence

- [Database settings](https://github.com/termuxbash/hospitalmanagement/blob/main/templates/database_settings.html): `templates/database_settings.html`
- [Database selection](https://github.com/termuxbash/hospitalmanagement/blob/main/database_config.json): `database_config.json`
- [Core schema](https://github.com/termuxbash/hospitalmanagement/blob/main/init.sql): `init.sql`
- [Summary views](https://github.com/termuxbash/hospitalmanagement/blob/main/views.sql): `views.sql`
- [History and audit triggers](https://github.com/termuxbash/hospitalmanagement/blob/main/triggers.sql): `triggers.sql`
- [SQLite database](https://github.com/termuxbash/hospitalmanagement/blob/main/hospital.db): `hospital.db`

### Other components

- **Hospital staff**

## Connections

- Hospital staff → Flask routes: uses (evidence: `README.md`)
- Flask routes → Staff login: renders (evidence: `app.py`)
- Flask routes → Dashboard: renders (evidence: `app.py`)
- Flask routes → Patient directory: renders (evidence: `app.py`)
- Flask routes → Doctor directory: renders (evidence: `app.py`)
- Flask routes → Consultations: renders (evidence: `app.py`)
- Flask routes → Billing ledger: renders (evidence: `app.py`)
- Flask routes → Billing entry: renders
- Flask routes → Billing audit: renders (evidence: `app.py`)
- Flask routes → Database settings: renders (evidence: `app.py`)
- Flask routes → Patient entry: renders
- Flask routes → Doctor entry: renders
- Flask routes → Consultation entry: renders
- Flask routes → SQLite database: reads and writes (evidence: `app.py`)
- Flask routes → Database selection: reads and updates (evidence: `app.py`)
- Flask routes → Core schema: initializes from (evidence: `app.py`)
- Flask routes → Summary views: initializes from (evidence: `app.py`)
- Flask routes → History and audit triggers: initializes from (evidence: `app.py`)
- Core schema → SQLite database: defines tables (evidence: `README.md`)
- Summary views → SQLite database: provides summaries (evidence: `README.md`)
- History and audit triggers → SQLite database: records history and audit (evidence: `README.md`)
- Flask routes → Dashboard: shows totals (evidence: `README.md`)
- Flask routes → Patient directory: searches patients (evidence: `README.md`)
- Flask routes → Consultations: links patient and doctor (evidence: `README.md`)
- Flask routes → Billing ledger: links billing to consultations (evidence: `README.md`)
- Flask routes → Billing audit: reviews billing changes (evidence: `README.md`)
