# sagarhn1/hospitalmanagementsystem architecture

> Architecture diagram of the GitHub repository sagarhn1/hospitalmanagementsystem, 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/sagarhn1/hospitalmanagementsystem
- Repository: https://github.com/sagarhn1/hospitalmanagementsystem

## Overview

This is a hospital-management application: users authenticate, then manage appointments and clinical records, prescriptions, billing and payments, departments, notifications, and user profiles. The sampled backend shows REST controllers delegating to services, which apply domain logic and use repositories; authentication also issues JWT and refresh tokens. The frontend modules are present, but their runtime wiring and API calls were not shown, and the README is empty. Dashed links mark unverified frontend-to-backend routing; other edges are supported by the sampled source or SOURCE INDEX.

Main entry points: [`src/main/java/com/hms/repository`](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/repository) (Data repositories), [`frontend/js/api.js`](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/api.js) (API client), [`src/main/java/com/hms/controller/AuthController.java`](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/AuthController.java) (Auth endpoints), [`src/main/java/com/hms/service/AuthService.java`](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/AuthService.java) (Authentication service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Web interface<br/>[app.js]"]
  node_webapi["API client<br/>[api.js]"]
  node_authui["Sign-in UI<br/>[auth.js]"]
  node_appointmentui["Appointment UI<br/>[appointments.js]"]
  node_dashboardui["Dashboard UI<br/>[dashboard.js]"]
  node_billui["Billing UI<br/>[bills.js]"]
  node_userui["User management UI<br/>[users.js]"]
  node_departmentui["Department UI<br/>[departments.js]"]
  node_notificationui["Notification UI<br/>[notifications.js]"]
end

subgraph group_access["Access and security"]
  node_authcontroller["Auth endpoints"]
  node_authservice["Authentication service<br/>[AuthService.java]"]
  node_jwtfilter["JWT filter"]
  node_jwtutil["JWT utilities<br/>[JwtUtil.java]"]
  node_tokenservice["Token service<br/>[TokenService.java]"]
end

subgraph group_care["Clinical operations"]
  node_appointmentctrl["Appointment endpoints"]
  node_appointmentservice["Appointment service"]
  node_recordctrl["Medical record endpoints"]
  node_recordservice["Medical record service"]
  node_prescriptionctrl["Prescription endpoints"]
  node_prescriptionservice["Prescription service"]
end

subgraph group_admin["Administration and finance"]
  node_billingctrl["Bill endpoints"]
  node_billingservice["Bill service<br/>[BillService.java]"]
  node_departmentservice["Department service"]
  node_paymentservice["Payment service"]
  node_notificationctrl["Notification endpoints"]
  node_notificationservice["Notification service"]
  node_emailservice["Email delivery<br/>[EmailService.java]"]
  node_controllers["Other endpoints"]
  node_services["Other domain services"]
end

subgraph group_persistence["Persistence"]
  node_repos["Data repositories"]
  node_entities[("Domain records")]
  node_dtos["API data models"]
end

node_people(("Hospital users"))

node_people -.->|"uses"| node_web
node_web -.->|"uses"| node_webapi
node_webapi -.->|"requests"| node_authcontroller
node_webapi -.->|"requests"| node_appointmentctrl
node_webapi -.->|"requests"| node_billingctrl
node_webapi -.->|"requests"| node_notificationctrl
node_authcontroller -->|"delegates"| node_authservice
node_authservice -->|"generates tokens"| node_jwtutil
node_authservice -->|"creates refresh token"| node_tokenservice
node_authservice -->|"reads and saves users"| node_repos
node_jwtfilter -->|"validates tokens"| node_jwtutil
node_jwtfilter -->|"checks blacklist"| node_repos
node_authcontroller -->|"handles refresh tokens"| node_tokenservice
node_authcontroller -->|"creates access token"| node_jwtutil
node_appointmentctrl -->|"delegates"| node_appointmentservice
node_appointmentservice -->|"queries and saves"| node_repos
node_recordctrl -->|"delegates"| node_recordservice
node_recordservice -->|"queries and saves"| node_repos
node_prescriptionctrl -->|"delegates"| node_prescriptionservice
node_billingctrl -->|"delegates"| node_billingservice
node_billingservice -->|"queries and saves"| node_repos
node_notificationctrl -->|"delegates"| node_notificationservice
node_notificationservice -->|"queries and saves"| node_repos
node_notificationservice -->|"sends email"| node_emailservice
node_repos -->|"persists"| node_entities
node_appointmentctrl -->|"exchanges DTOs"| node_dtos
node_billingctrl -->|"exchanges DTOs"| node_dtos

click node_web "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/app.js"
click node_webapi "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/api.js"
click node_authui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/auth.js"
click node_appointmentui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/appointments.js"
click node_dashboardui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/dashboard.js"
click node_billui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/bills.js"
click node_userui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/users.js"
click node_departmentui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/departments.js"
click node_notificationui "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/notifications.js"
click node_authcontroller "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/AuthController.java"
click node_authservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/AuthService.java"
click node_jwtfilter "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/security/JwtAuthenticationFilter.java"
click node_jwtutil "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/security/JwtUtil.java"
click node_tokenservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/TokenService.java"
click node_appointmentctrl "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/AppointmentController.java"
click node_appointmentservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/AppointmentService.java"
click node_recordctrl "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/MedicalRecordController.java"
click node_recordservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/MedicalRecordService.java"
click node_prescriptionctrl "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/PrescriptionController.java"
click node_prescriptionservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/PrescriptionService.java"
click node_billingctrl "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/BillController.java"
click node_billingservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/BillService.java"
click node_departmentservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/DepartmentService.java"
click node_paymentservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/PaymentService.java"
click node_notificationctrl "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/NotificationController.java"
click node_notificationservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/NotificationService.java"
click node_emailservice "https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/EmailService.java"
click node_controllers "https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/controller"
click node_services "https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/service"
click node_repos "https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/repository"
click node_entities "https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/entity"
click node_dtos "https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/dto"

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_web,node_webapi,node_authui,node_appointmentui,node_dashboardui,node_billui,node_userui,node_departmentui,node_notificationui,node_people toneBlue
class node_authcontroller,node_authservice,node_jwtfilter,node_jwtutil,node_tokenservice toneAmber
class node_appointmentctrl,node_appointmentservice,node_recordctrl,node_recordservice,node_prescriptionctrl,node_prescriptionservice toneMint
class node_billingctrl,node_billingservice,node_departmentservice,node_paymentservice,node_notificationctrl,node_notificationservice,node_emailservice,node_controllers,node_services toneRose
class node_repos,node_entities,node_dtos toneIndigo
```

## Components

### Web client

- [Web interface](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [API client](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/api.js): `frontend/js/api.js`
- [Sign-in UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/auth.js): `frontend/js/auth.js`
- [Appointment UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/appointments.js): `frontend/js/appointments.js`
- [Dashboard UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/dashboard.js): `frontend/js/dashboard.js`
- [Billing UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/bills.js): `frontend/js/bills.js`
- [User management UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/users.js): `frontend/js/users.js`
- [Department UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/departments.js): `frontend/js/departments.js`
- [Notification UI](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/frontend/js/notifications.js): `frontend/js/notifications.js`

### Access and security

- [Auth endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/AuthController.java): `src/main/java/com/hms/controller/AuthController.java`
- [Authentication service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/AuthService.java): `src/main/java/com/hms/service/AuthService.java`
- [JWT filter](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/security/JwtAuthenticationFilter.java): `src/main/java/com/hms/security/JwtAuthenticationFilter.java`
- [JWT utilities](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/security/JwtUtil.java): `src/main/java/com/hms/security/JwtUtil.java`
- [Token service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/TokenService.java): `src/main/java/com/hms/service/TokenService.java`

### Clinical operations

- [Appointment endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/AppointmentController.java): `src/main/java/com/hms/controller/AppointmentController.java`
- [Appointment service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/AppointmentService.java): `src/main/java/com/hms/service/AppointmentService.java`
- [Medical record endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/MedicalRecordController.java): `src/main/java/com/hms/controller/MedicalRecordController.java`
- [Medical record service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/MedicalRecordService.java): `src/main/java/com/hms/service/MedicalRecordService.java`
- [Prescription endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/PrescriptionController.java): `src/main/java/com/hms/controller/PrescriptionController.java`
- [Prescription service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/PrescriptionService.java): `src/main/java/com/hms/service/PrescriptionService.java`

### Administration and finance

- [Bill endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/BillController.java): `src/main/java/com/hms/controller/BillController.java`
- [Bill service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/BillService.java): `src/main/java/com/hms/service/BillService.java`
- [Department service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/DepartmentService.java): `src/main/java/com/hms/service/DepartmentService.java`
- [Payment service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/PaymentService.java): `src/main/java/com/hms/service/PaymentService.java`
- [Notification endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/controller/NotificationController.java): `src/main/java/com/hms/controller/NotificationController.java`
- [Notification service](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/NotificationService.java): `src/main/java/com/hms/service/NotificationService.java`
- [Email delivery](https://github.com/sagarhn1/hospitalmanagementsystem/blob/main/src/main/java/com/hms/service/EmailService.java): `src/main/java/com/hms/service/EmailService.java`
- [Other endpoints](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/controller): `src/main/java/com/hms/controller`
- [Other domain services](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/service): `src/main/java/com/hms/service`

### Persistence

- [Data repositories](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/repository): `src/main/java/com/hms/repository`
- [Domain records](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/entity): `src/main/java/com/hms/entity`
- [API data models](https://github.com/sagarhn1/hospitalmanagementsystem/tree/main/src/main/java/com/hms/dto): `src/main/java/com/hms/dto`

### Other components

- **Hospital users**

## Connections

- Hospital users → Web interface: uses
- Web interface → API client: uses
- API client → Auth endpoints: requests
- API client → Appointment endpoints: requests
- API client → Bill endpoints: requests
- API client → Notification endpoints: requests
- Auth endpoints → Authentication service: delegates (evidence: `src/main/java/com/hms/controller/AuthController.java`)
- Authentication service → JWT utilities: generates tokens (evidence: `src/main/java/com/hms/service/AuthService.java`)
- Authentication service → Token service: creates refresh token (evidence: `src/main/java/com/hms/service/AuthService.java`)
- Authentication service → Data repositories: reads and saves users (evidence: `src/main/java/com/hms/service/AuthService.java`)
- JWT filter → JWT utilities: validates tokens (evidence: `src/main/java/com/hms/security/JwtAuthenticationFilter.java`)
- JWT filter → Data repositories: checks blacklist (evidence: `src/main/java/com/hms/security/JwtAuthenticationFilter.java`)
- Auth endpoints → Token service: handles refresh tokens (evidence: `src/main/java/com/hms/controller/AuthController.java`)
- Auth endpoints → JWT utilities: creates access token (evidence: `src/main/java/com/hms/controller/AuthController.java`)
- Appointment endpoints → Appointment service: delegates (evidence: `src/main/java/com/hms/controller/AppointmentController.java`)
- Appointment service → Data repositories: queries and saves (evidence: `src/main/java/com/hms/service/AppointmentService.java`)
- Medical record endpoints → Medical record service: delegates (evidence: `src/main/java/com/hms/controller/MedicalRecordController.java`)
- Medical record service → Data repositories: queries and saves (evidence: `src/main/java/com/hms/service/MedicalRecordService.java`)
- Prescription endpoints → Prescription service: delegates (evidence: `src/main/java/com/hms/controller/PrescriptionController.java`)
- Bill endpoints → Bill service: delegates (evidence: `src/main/java/com/hms/controller/BillController.java`)
- Bill service → Data repositories: queries and saves (evidence: `src/main/java/com/hms/service/BillService.java`)
- Notification endpoints → Notification service: delegates (evidence: `src/main/java/com/hms/controller/NotificationController.java`)
- Notification service → Data repositories: queries and saves (evidence: `src/main/java/com/hms/service/NotificationService.java`)
- Notification service → Email delivery: sends email (evidence: `src/main/java/com/hms/service/NotificationService.java`)
- Data repositories → Domain records: persists (evidence: `src/main/java/com/hms/repository/AppointmentRepository.java`)
- Appointment endpoints → API data models: exchanges DTOs (evidence: `src/main/java/com/hms/controller/AppointmentController.java`)
- Bill endpoints → API data models: exchanges DTOs (evidence: `src/main/java/com/hms/controller/BillController.java`)
