# huzaifamustafa1126/hospital-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/huzaifamustafa1126/hospital-management-system
- Repository: https://github.com/huzaifamustafa1126/hospital-management-system

## Overview

This is a role- and permission-controlled hospital operations system. Staff authenticate, register patients once, create repeat visits, associate doctors, fees and services, then manage visit billing and print invoices or receipts; administrators also manage revenue, audit activity and operational modules. The graph separates the React experience, API/auth boundary, clinical workflows, administration and persistence. Core patient, dashboard, lab, blood-bank and notification modules are retained from the source index, but their internal calls are not inferred where excerpts do not show them.

Main entry points: [`client/src/App.jsx`](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/App.jsx) (Route application), [`client/src/services/api.js`](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/api.js) (HTTP client), [`server/src/db/database.js`](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/db/database.js) (MySQL pool), [`client/src/pages/ServicesPage.jsx`](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/ServicesPage.jsx) (Services management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Staff experience"]
  node_app["Route application<br/>[App.jsx]"]
  node_patient_ui["Patient workflows"]
  node_dashboard_ui["Dashboard<br/>[DashboardPage.jsx]"]
  node_lab_ui["Laboratory management"]
  node_blood_ui["Blood bank patient"]
  node_services_ui["Services management<br/>[ServicesPage.jsx]"]
  node_print_ui["Invoice preview"]
end

subgraph group_security["Identity and access"]
  node_auth_context["Session context<br/>[AuthContext.jsx]"]
  node_client_api["HTTP client<br/>[api.js]"]
  node_auth_middleware["API access control<br/>[auth.middleware.js]"]
  node_auth_service["Authentication service<br/>[auth.service.js]"]
end

subgraph group_clinical["Patient care"]
  node_patient_api["Patient requests<br/>[patient.service.js]"]
  node_lab_catalog_api["Lab catalog requests"]
  node_patient_controller["Patient endpoints"]
  node_patient_service["Patient and visits<br/>[patient.service.js]"]
  node_lab_controller["Lab catalog endpoints"]
  node_lab_service["Lab catalog"]
end

subgraph group_operations["Hospital operations"]
  node_billing_api["Billing requests<br/>[billing.service.js]"]
  node_service_api["Service requests<br/>[service.service.js]"]
  node_billing_service["Visit billing<br/>[billing.service.js]"]
  node_audit_service["Audit activity<br/>[audit.service.js]"]
end

subgraph group_backend["API and persistence"]
  node_api_server["Hospital REST API<br/>[app.js]"]
  node_database[("MySQL pool<br/>[database.js]")]
  node_lab_routes["Lab catalog routes"]
end

node_staff(("Hospital staff"))

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_patient_ui
node_app -->|"routes to"| node_dashboard_ui
node_app -->|"routes to"| node_lab_ui
node_app -->|"routes to"| node_blood_ui
node_app -->|"routes to"| node_services_ui
node_app -.->|"protects routes"| node_auth_context
node_patient_ui -.->|"requests data"| node_patient_api
node_lab_ui -.->|"requests data"| node_lab_catalog_api
node_services_ui -->|"calls service"| node_service_api
node_services_ui -.->|"loads departments"| node_client_api
node_print_ui -->|"loads bill"| node_billing_api
node_patient_api -->|"uses HTTP"| node_client_api
node_lab_catalog_api -->|"uses HTTP"| node_client_api
node_billing_api -->|"uses HTTP"| node_client_api
node_service_api -.->|"uses HTTP"| node_client_api
node_auth_context -.->|"sends requests"| node_client_api
node_client_api -.->|"calls API"| node_api_server
node_api_server -->|"mounts routes"| node_lab_routes
node_lab_routes -->|"authenticates"| node_auth_middleware
node_lab_routes -->|"dispatches"| node_lab_controller
node_lab_controller -->|"calls"| node_lab_service
node_auth_middleware -->|"loads user"| node_auth_service
node_auth_service -->|"queries"| node_database
node_patient_controller -->|"calls"| node_patient_service
node_patient_service -->|"queries"| node_database
node_lab_service -->|"queries"| node_database
node_lab_service -->|"records activity"| node_audit_service
node_audit_service -->|"writes records"| node_database
node_billing_service -.->|"persists billing"| node_database

click node_app "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/App.jsx"
click node_patient_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/PatientDetailPage.jsx"
click node_dashboard_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/DashboardPage.jsx"
click node_lab_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/LabManagementPage.jsx"
click node_blood_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/BloodBankPatientPage.jsx"
click node_services_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/ServicesPage.jsx"
click node_print_ui "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/InvoicePreviewPage.jsx"
click node_auth_context "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/context/AuthContext.jsx"
click node_client_api "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/api.js"
click node_patient_api "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/patient.service.js"
click node_lab_catalog_api "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/lab-catalog.service.js"
click node_billing_api "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/billing.service.js"
click node_service_api "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/service.service.js"
click node_api_server "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/app.js"
click node_auth_middleware "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/middleware/auth.middleware.js"
click node_auth_service "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/auth.service.js"
click node_patient_controller "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/controllers/patient.controller.js"
click node_patient_service "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/patient.service.js"
click node_lab_controller "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/controllers/lab-catalog.controller.js"
click node_lab_service "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/lab-catalog.service.js"
click node_billing_service "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/billing.service.js"
click node_audit_service "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/audit.service.js"
click node_database "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/db/database.js"
click node_lab_routes "https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/routes/lab-catalog.routes.js"

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_patient_ui,node_dashboard_ui,node_lab_ui,node_blood_ui,node_services_ui,node_print_ui toneBlue
class node_auth_context,node_client_api,node_auth_middleware,node_auth_service toneAmber
class node_patient_api,node_lab_catalog_api,node_patient_controller,node_patient_service,node_lab_controller,node_lab_service toneMint
class node_billing_api,node_service_api,node_billing_service,node_audit_service toneRose
class node_api_server,node_database,node_lab_routes,node_staff toneIndigo
```

## Components

### Staff experience

- [Route application](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Patient workflows](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/PatientDetailPage.jsx): `client/src/pages/PatientDetailPage.jsx`
- [Dashboard](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Laboratory management](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/LabManagementPage.jsx): `client/src/pages/LabManagementPage.jsx`
- [Blood bank patient](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/BloodBankPatientPage.jsx): `client/src/pages/BloodBankPatientPage.jsx`
- [Services management](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/ServicesPage.jsx): `client/src/pages/ServicesPage.jsx`
- [Invoice preview](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/pages/InvoicePreviewPage.jsx): `client/src/pages/InvoicePreviewPage.jsx`

### Identity and access

- [Session context](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [HTTP client](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [API access control](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/middleware/auth.middleware.js): `server/src/middleware/auth.middleware.js`
- [Authentication service](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/auth.service.js): `server/src/services/auth.service.js`

### Patient care

- [Patient requests](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/patient.service.js): `client/src/services/patient.service.js`
- [Lab catalog requests](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/lab-catalog.service.js): `client/src/services/lab-catalog.service.js`
- [Patient endpoints](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/controllers/patient.controller.js): `server/src/controllers/patient.controller.js`
- [Patient and visits](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/patient.service.js): `server/src/services/patient.service.js`
- [Lab catalog endpoints](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/controllers/lab-catalog.controller.js): `server/src/controllers/lab-catalog.controller.js`
- [Lab catalog](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/lab-catalog.service.js): `server/src/services/lab-catalog.service.js`

### Hospital operations

- [Billing requests](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/billing.service.js): `client/src/services/billing.service.js`
- [Service requests](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/client/src/services/service.service.js): `client/src/services/service.service.js`
- [Visit billing](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/billing.service.js): `server/src/services/billing.service.js`
- [Audit activity](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/services/audit.service.js): `server/src/services/audit.service.js`

### API and persistence

- [Hospital REST API](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/app.js): `server/src/app.js`
- [MySQL pool](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/db/database.js): `server/src/db/database.js`
- [Lab catalog routes](https://github.com/huzaifamustafa1126/hospital-management-system/blob/main/server/src/routes/lab-catalog.routes.js): `server/src/routes/lab-catalog.routes.js`

### Other components

- **Hospital staff**

## Connections

- Hospital staff → Route application: uses (evidence: `README.md`)
- Route application → Patient workflows: routes to (evidence: `client/src/App.jsx`)
- Route application → Dashboard: routes to (evidence: `client/src/App.jsx`)
- Route application → Laboratory management: routes to (evidence: `client/src/App.jsx`)
- Route application → Blood bank patient: routes to (evidence: `client/src/App.jsx`)
- Route application → Services management: routes to (evidence: `client/src/App.jsx`)
- Route application → Session context: protects routes
- Patient workflows → Patient requests: requests data
- Laboratory management → Lab catalog requests: requests data
- Services management → Service requests: calls service (evidence: `client/src/pages/ServicesPage.jsx`)
- Services management → HTTP client: loads departments
- Invoice preview → Billing requests: loads bill (evidence: `client/src/pages/InvoicePreviewPage.jsx`)
- Patient requests → HTTP client: uses HTTP (evidence: `client/src/services/patient.service.js`)
- Lab catalog requests → HTTP client: uses HTTP (evidence: `client/src/services/lab-catalog.service.js`)
- Billing requests → HTTP client: uses HTTP (evidence: `client/src/services/billing.service.js`)
- Service requests → HTTP client: uses HTTP
- Session context → HTTP client: sends requests
- HTTP client → Hospital REST API: calls API
- Hospital REST API → Lab catalog routes: mounts routes (evidence: `server/src/app.js`)
- Lab catalog routes → API access control: authenticates (evidence: `server/src/routes/lab-catalog.routes.js`)
- Lab catalog routes → Lab catalog endpoints: dispatches (evidence: `server/src/routes/lab-catalog.routes.js`)
- Lab catalog endpoints → Lab catalog: calls (evidence: `server/src/controllers/lab-catalog.controller.js`)
- API access control → Authentication service: loads user (evidence: `server/src/middleware/auth.middleware.js`)
- Authentication service → MySQL pool: queries (evidence: `server/src/services/auth.service.js`)
- Patient endpoints → Patient and visits: calls (evidence: `server/src/controllers/patient.controller.js`)
- Patient and visits → MySQL pool: queries (evidence: `server/src/services/patient.service.js`)
- Lab catalog → MySQL pool: queries (evidence: `server/src/services/lab-catalog.service.js`)
- Lab catalog → Audit activity: records activity (evidence: `server/src/services/lab-catalog.service.js`)
- Audit activity → MySQL pool: writes records (evidence: `server/src/services/audit.service.js`)
- Visit billing → MySQL pool: persists billing
