# saagarrk/hospital-management-system architecture

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

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

## Overview

MedPulse is a role-based hospital management system with a React SPA, Spring Boot REST API and MySQL-backed domain services. Users authenticate and receive role-gated workflows; the frontend requests operational data through service clients, and the backend exposes clinical, administrative and financial capabilities. The README documents appointments, patient records, inpatient care, labs, prescriptions, pharmacy, billing, audit and dashboards. Source excerpts confirm selected frontend routing/authentication, dashboard fallback and backend authentication/appointment/pharmacy contracts; other domain links are documented or left unasserted where source was not sampled.

Main entry points: [`backend-springboot/src/main/java/com/hospital/management/controller`](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/controller) (Spring REST API), [`src/api/axiosClient.js`](https://github.com/saagarrk/hospital-management-system/blob/main/src/api/axiosClient.js) (HTTP client), [`src/App.jsx`](https://github.com/saagarrk/hospital-management-system/blob/main/src/App.jsx) (SPA routes), [`src/services/dashboardService.js`](https://github.com/saagarrk/hospital-management-system/blob/main/src/services/dashboardService.js) (Dashboard client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["SPA routes<br/>[App.jsx]"]
  node_api["HTTP client<br/>[axiosClient.js]"]
  node_dashui["Role dashboards"]
  node_dashclient["Dashboard client"]
  node_modules["Hospital modules"]
  node_mock[("Local rule engine<br/>[mockDataService.js]")]
end

subgraph group_identity["Identity and access"]
  node_authctx["Auth state<br/>[AuthContext.jsx]"]
  node_authui["Login and registration"]
  node_authclient["Auth client<br/>[authService.js]"]
  node_authcontroller["Auth API"]
  node_authservice["Authentication service"]
  node_jwt["JWT services<br/>[JwtService.java]"]
  node_authuserdetails["User details lookup"]
end

subgraph group_clinical["Clinical operations"]
  node_appointments["Appointment management"]
  node_records["Medical records"]
  node_inpatient["Inpatient care"]
  node_lab["Laboratory"]
  node_prescriptions["Prescriptions"]
  node_patients["Patient and doctor records"]
end

subgraph group_operations["Hospital operations"]
  node_pharmacy["Pharmacy inventory"]
  node_billing["Billing and payments"]
  node_audit["Audit logs"]
  node_dashbackend["Dashboard aggregation"]
end

subgraph group_backend["Backend platform"]
  node_webapi["Spring REST API"]
end

subgraph group_persistence["Persistence"]
  node_mysql[("MySQL database")]
end

node_user(("Hospital user"))

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_authctx
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_modules
node_authui -.->|"submits credentials"| node_authctx
node_authctx -->|"authenticates via"| node_authclient
node_authclient -->|"sends requests"| node_api
node_api -.->|"calls REST API"| node_authcontroller
node_api -.->|"calls REST API"| node_webapi
node_dashui -->|"loads dashboard"| node_dashclient
node_dashclient -->|"requests metrics"| node_api
node_dashclient -->|"falls back"| node_mock
node_api -.->|"sends REST requests"| node_webapi
node_authcontroller -.->|"delegates auth"| node_authservice
node_authservice -->|"issues tokens"| node_jwt
node_authservice -.->|"authenticates user"| node_authuserdetails
node_webapi -.->|"routes requests"| node_appointments
node_webapi -.->|"routes requests"| node_records
node_webapi -.->|"routes requests"| node_inpatient
node_webapi -.->|"routes requests"| node_lab
node_webapi -.->|"routes requests"| node_prescriptions
node_webapi -.->|"routes requests"| node_patients
node_webapi -->|"routes requests"| node_pharmacy
node_webapi -.->|"routes requests"| node_billing
node_webapi -.->|"routes requests"| node_audit
node_webapi -.->|"routes requests"| node_dashbackend
node_authuserdetails -.->|"reads user"| node_mysql
node_appointments -.->|"reads and writes"| node_mysql
node_records -.->|"reads and writes"| node_mysql
node_inpatient -.->|"reads and writes"| node_mysql
node_lab -.->|"reads and writes"| node_mysql
node_prescriptions -.->|"reads and writes"| node_mysql
node_patients -.->|"reads and writes"| node_mysql
node_pharmacy -.->|"reads and writes"| node_mysql
node_billing -.->|"reads and writes"| node_mysql
node_audit -.->|"reads and writes"| node_mysql
node_dashbackend -.->|"aggregates data"| node_mysql

click node_app "https://github.com/saagarrk/hospital-management-system/blob/main/src/App.jsx"
click node_authctx "https://github.com/saagarrk/hospital-management-system/blob/main/src/context/AuthContext.jsx"
click node_authui "https://github.com/saagarrk/hospital-management-system/tree/main/src/pages/auth"
click node_authclient "https://github.com/saagarrk/hospital-management-system/blob/main/src/services/authService.js"
click node_api "https://github.com/saagarrk/hospital-management-system/blob/main/src/api/axiosClient.js"
click node_dashui "https://github.com/saagarrk/hospital-management-system/blob/main/src/components/modules/DashboardModule.jsx"
click node_dashclient "https://github.com/saagarrk/hospital-management-system/blob/main/src/services/dashboardService.js"
click node_modules "https://github.com/saagarrk/hospital-management-system/tree/main/src/components/modules"
click node_mock "https://github.com/saagarrk/hospital-management-system/blob/main/src/services/mockDataService.js"
click node_authcontroller "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/controller/AuthController.java"
click node_authservice "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/impl/AuthServiceImpl.java"
click node_jwt "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/security/JwtService.java"
click node_authuserdetails "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/security/CustomUserDetailsService.java"
click node_appointments "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/AppointmentService.java"
click node_records "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/MedicalRecordService.java"
click node_inpatient "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_lab "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_prescriptions "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_patients "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_pharmacy "https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java"
click node_billing "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_audit "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_dashbackend "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service"
click node_webapi "https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/controller"

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_api,node_dashui,node_dashclient,node_modules,node_mock,node_user toneBlue
class node_authctx,node_authui,node_authclient,node_authcontroller,node_authservice,node_jwt,node_authuserdetails toneAmber
class node_appointments,node_records,node_inpatient,node_lab,node_prescriptions,node_patients toneMint
class node_pharmacy,node_billing,node_audit,node_dashbackend toneRose
class node_webapi toneIndigo
class node_mysql toneTeal
```

## Components

### Web application

- [SPA routes](https://github.com/saagarrk/hospital-management-system/blob/main/src/App.jsx): `src/App.jsx`
- [HTTP client](https://github.com/saagarrk/hospital-management-system/blob/main/src/api/axiosClient.js): `src/api/axiosClient.js`
- [Role dashboards](https://github.com/saagarrk/hospital-management-system/blob/main/src/components/modules/DashboardModule.jsx): `src/components/modules/DashboardModule.jsx`
- [Dashboard client](https://github.com/saagarrk/hospital-management-system/blob/main/src/services/dashboardService.js): `src/services/dashboardService.js`
- [Hospital modules](https://github.com/saagarrk/hospital-management-system/tree/main/src/components/modules): `src/components/modules`
- [Local rule engine](https://github.com/saagarrk/hospital-management-system/blob/main/src/services/mockDataService.js): `src/services/mockDataService.js`

### Identity and access

- [Auth state](https://github.com/saagarrk/hospital-management-system/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Login and registration](https://github.com/saagarrk/hospital-management-system/tree/main/src/pages/auth): `src/pages/auth`
- [Auth client](https://github.com/saagarrk/hospital-management-system/blob/main/src/services/authService.js): `src/services/authService.js`
- [Auth API](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/controller/AuthController.java): `backend-springboot/src/main/java/com/hospital/management/controller/AuthController.java`
- [Authentication service](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/impl/AuthServiceImpl.java): `backend-springboot/src/main/java/com/hospital/management/service/impl/AuthServiceImpl.java`
- [JWT services](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/security/JwtService.java): `backend-springboot/src/main/java/com/hospital/management/security/JwtService.java`
- [User details lookup](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/security/CustomUserDetailsService.java): `backend-springboot/src/main/java/com/hospital/management/security/CustomUserDetailsService.java`

### Clinical operations

- [Appointment management](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/AppointmentService.java): `backend-springboot/src/main/java/com/hospital/management/service/AppointmentService.java`
- [Medical records](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/service/MedicalRecordService.java): `backend-springboot/src/main/java/com/hospital/management/service/MedicalRecordService.java`
- [Inpatient care](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`
- [Laboratory](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`
- [Prescriptions](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`
- [Patient and doctor records](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`

### Hospital operations

- [Pharmacy inventory](https://github.com/saagarrk/hospital-management-system/blob/main/backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java): `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`
- [Billing and payments](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`
- [Audit logs](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`
- [Dashboard aggregation](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/service): `backend-springboot/src/main/java/com/hospital/management/service`

### Backend platform

- [Spring REST API](https://github.com/saagarrk/hospital-management-system/tree/main/backend-springboot/src/main/java/com/hospital/management/controller): `backend-springboot/src/main/java/com/hospital/management/controller`

### Persistence

- **MySQL database**

### Other components

- **Hospital user**

## Connections

- Hospital user → SPA routes: uses (evidence: `src/App.jsx`)
- SPA routes → Auth state: provides auth (evidence: `src/App.jsx`)
- SPA routes → Login and registration: routes to (evidence: `src/App.jsx`)
- SPA routes → Hospital modules: routes to (evidence: `src/App.jsx`)
- Login and registration → Auth state: submits credentials (evidence: `src/pages/auth/RegisterPage.jsx`)
- Auth state → Auth client: authenticates via (evidence: `src/context/AuthContext.jsx`)
- Auth client → HTTP client: sends requests (evidence: `src/services/authService.js`)
- HTTP client → Auth API: calls REST API
- HTTP client → Spring REST API: calls REST API
- Role dashboards → Dashboard client: loads dashboard (evidence: `src/components/modules/DashboardModule.jsx`)
- Dashboard client → HTTP client: requests metrics (evidence: `src/services/dashboardService.js`)
- Dashboard client → Local rule engine: falls back (evidence: `src/services/dashboardService.js`)
- HTTP client → Spring REST API: sends REST requests
- Auth API → Authentication service: delegates auth
- Authentication service → JWT services: issues tokens (evidence: `backend-springboot/src/main/java/com/hospital/management/service/impl/AuthServiceImpl.java`)
- Authentication service → User details lookup: authenticates user
- Spring REST API → Appointment management: routes requests
- Spring REST API → Medical records: routes requests
- Spring REST API → Inpatient care: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Laboratory: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Prescriptions: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Patient and doctor records: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Pharmacy inventory: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Billing and payments: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Audit logs: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- Spring REST API → Dashboard aggregation: routes requests (evidence: `backend-springboot/src/main/java/com/hospital/management/controller/PharmacyController.java`)
- User details lookup → MySQL database: reads user
- Appointment management → MySQL database: reads and writes
- Medical records → MySQL database: reads and writes
- Inpatient care → MySQL database: reads and writes
- Laboratory → MySQL database: reads and writes
- Prescriptions → MySQL database: reads and writes
- Patient and doctor records → MySQL database: reads and writes
- Pharmacy inventory → MySQL database: reads and writes
- Billing and payments → MySQL database: reads and writes
- Audit logs → MySQL database: reads and writes
- Dashboard aggregation → MySQL database: aggregates data
