# harshad-yewale/hospital-management-system architecture

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

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

## Overview

This Spring Boot backend exposes REST APIs for hospital operations, with appointments as a prominent lifecycle workflow: a client submits appointment requests, the controller delegates to the appointment service, and the repository persists or retrieves appointment data. Patient, doctor, department, and insurance operations form parallel domain capabilities. The README documents a controller–service–repository–entity architecture and MySQL storage. Service implementations were not sampled, so detailed business-rule calls and some cross-domain wiring are not asserted.

Main entry points: [`src/main/java/com/harshadcodes/Hospital_Management_System/Exceptions/MyGlobalExceptionHandler.java`](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/Exceptions/MyGlobalExceptionHandler.java) (Global Exception Handler), [`src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DoctorController.java`](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DoctorController.java) (Doctors API), [`src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DepartmentController.java`](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DepartmentController.java) (Departments API), [`src/main/java/com/harshadcodes/Hospital_Management_System/controllers/AppointmentController.java`](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/AppointmentController.java) (Appointments API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_appointments_api["Appointments API"]
  node_patients_api["Patients API"]
  node_doctors_api["Doctors API"]
  node_departments_api["Departments API"]
  node_insurance_api["Insurance API"]
end

subgraph group_domain["Domain Services"]
  node_appointment_service["Appointment Lifecycle"]
  node_patient_service["Patient Management"]
  node_doctor_service["Doctor Management"]
  node_department_service["Department Management"]
  node_insurance_service["Insurance Management"]
end

subgraph group_persistence["Persistence"]
  node_domain_entities["Domain Entities"]
  node_appointment_repo["Appointment Repository"]
  node_patient_repo["Patient Repository"]
  node_doctor_repo["Doctor Repository"]
  node_department_repo["Department Repository"]
  node_insurance_repo["Insurance Repository"]
end

subgraph group_errors["Error Handling"]
  node_exception_handler["Global Exception Handler"]
end

node_client(("API Client"))
node_mysql[("MySQL Database")]

node_client -->|"sends requests"| node_appointments_api
node_client -->|"sends requests"| node_patients_api
node_client -->|"sends requests"| node_doctors_api
node_client -->|"sends requests"| node_departments_api
node_client -->|"sends requests"| node_insurance_api
node_appointments_api -->|"delegates"| node_appointment_service
node_patients_api -->|"delegates"| node_patient_service
node_doctors_api -->|"delegates"| node_doctor_service
node_doctors_api -->|"delegates"| node_department_service
node_departments_api -->|"delegates"| node_department_service
node_departments_api -->|"delegates"| node_doctor_service
node_insurance_api -->|"delegates"| node_insurance_service
node_appointment_service -->|"uses"| node_appointment_repo
node_patient_service -->|"uses"| node_patient_repo
node_doctor_service -->|"uses"| node_doctor_repo
node_department_service -->|"uses"| node_department_repo
node_insurance_service -->|"uses"| node_insurance_repo
node_appointment_repo -->|"reads and writes"| node_mysql
node_patient_repo -->|"reads and writes"| node_mysql
node_doctor_repo -->|"reads and writes"| node_mysql
node_department_repo -->|"reads and writes"| node_mysql
node_insurance_repo -->|"reads and writes"| node_mysql
node_appointments_api -.->|"errors handled by"| node_exception_handler
node_patients_api -.->|"errors handled by"| node_exception_handler
node_doctors_api -.->|"errors handled by"| node_exception_handler
node_departments_api -.->|"errors handled by"| node_exception_handler
node_insurance_api -.->|"errors handled by"| node_exception_handler

click node_appointments_api "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/AppointmentController.java"
click node_patients_api "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/PatientController.java"
click node_doctors_api "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DoctorController.java"
click node_departments_api "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DepartmentController.java"
click node_insurance_api "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/InsuranceController.java"
click node_appointment_service "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/AppointmentServiceImpl.java"
click node_patient_service "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/PatientServiceImpl.java"
click node_doctor_service "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/DoctorServiceImpl.java"
click node_department_service "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/DepartmentServiceImpl.java"
click node_insurance_service "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/InsuranceServiceImpl.java"
click node_domain_entities "https://github.com/harshad-yewale/hospital-management-system/tree/main/src/main/java/com/harshadcodes/Hospital_Management_System/entities"
click node_appointment_repo "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/AppointmentRepository.java"
click node_patient_repo "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/PatientRepository.java"
click node_doctor_repo "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DoctorRepository.java"
click node_department_repo "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DepartmentRepository.java"
click node_insurance_repo "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/InsuranceRepository.java"
click node_exception_handler "https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/Exceptions/MyGlobalExceptionHandler.java"

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_appointments_api,node_patients_api,node_doctors_api,node_departments_api,node_insurance_api,node_client toneBlue
class node_appointment_service,node_patient_service,node_doctor_service,node_department_service,node_insurance_service,node_mysql toneAmber
class node_domain_entities,node_appointment_repo,node_patient_repo,node_doctor_repo,node_department_repo,node_insurance_repo toneMint
class node_exception_handler toneRose
```

## Components

### REST API

- [Appointments API](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/AppointmentController.java): `src/main/java/com/harshadcodes/Hospital_Management_System/controllers/AppointmentController.java`
- [Patients API](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/PatientController.java): `src/main/java/com/harshadcodes/Hospital_Management_System/controllers/PatientController.java`
- [Doctors API](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DoctorController.java): `src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DoctorController.java`
- [Departments API](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DepartmentController.java): `src/main/java/com/harshadcodes/Hospital_Management_System/controllers/DepartmentController.java`
- [Insurance API](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/controllers/InsuranceController.java): `src/main/java/com/harshadcodes/Hospital_Management_System/controllers/InsuranceController.java`

### Domain Services

- [Appointment Lifecycle](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/AppointmentServiceImpl.java): `src/main/java/com/harshadcodes/Hospital_Management_System/services/AppointmentServiceImpl.java`
- [Patient Management](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/PatientServiceImpl.java): `src/main/java/com/harshadcodes/Hospital_Management_System/services/PatientServiceImpl.java`
- [Doctor Management](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/DoctorServiceImpl.java): `src/main/java/com/harshadcodes/Hospital_Management_System/services/DoctorServiceImpl.java`
- [Department Management](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/DepartmentServiceImpl.java): `src/main/java/com/harshadcodes/Hospital_Management_System/services/DepartmentServiceImpl.java`
- [Insurance Management](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/services/InsuranceServiceImpl.java): `src/main/java/com/harshadcodes/Hospital_Management_System/services/InsuranceServiceImpl.java`

### Persistence

- [Domain Entities](https://github.com/harshad-yewale/hospital-management-system/tree/main/src/main/java/com/harshadcodes/Hospital_Management_System/entities): `src/main/java/com/harshadcodes/Hospital_Management_System/entities`
- [Appointment Repository](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/AppointmentRepository.java): `src/main/java/com/harshadcodes/Hospital_Management_System/repositories/AppointmentRepository.java`
- [Patient Repository](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/PatientRepository.java): `src/main/java/com/harshadcodes/Hospital_Management_System/repositories/PatientRepository.java`
- [Doctor Repository](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DoctorRepository.java): `src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DoctorRepository.java`
- [Department Repository](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DepartmentRepository.java): `src/main/java/com/harshadcodes/Hospital_Management_System/repositories/DepartmentRepository.java`
- [Insurance Repository](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/repositories/InsuranceRepository.java): `src/main/java/com/harshadcodes/Hospital_Management_System/repositories/InsuranceRepository.java`

### Error Handling

- [Global Exception Handler](https://github.com/harshad-yewale/hospital-management-system/blob/main/src/main/java/com/harshadcodes/Hospital_Management_System/Exceptions/MyGlobalExceptionHandler.java): `src/main/java/com/harshadcodes/Hospital_Management_System/Exceptions/MyGlobalExceptionHandler.java`

### Other components

- **API Client**
- **MySQL Database**

## Connections

- API Client → Appointments API: sends requests
- API Client → Patients API: sends requests
- API Client → Doctors API: sends requests
- API Client → Departments API: sends requests
- API Client → Insurance API: sends requests
- Appointments API → Appointment Lifecycle: delegates
- Patients API → Patient Management: delegates
- Doctors API → Doctor Management: delegates
- Doctors API → Department Management: delegates
- Departments API → Department Management: delegates
- Departments API → Doctor Management: delegates
- Insurance API → Insurance Management: delegates
- Appointment Lifecycle → Appointment Repository: uses
- Patient Management → Patient Repository: uses
- Doctor Management → Doctor Repository: uses
- Department Management → Department Repository: uses
- Insurance Management → Insurance Repository: uses
- Appointment Repository → MySQL Database: reads and writes
- Patient Repository → MySQL Database: reads and writes
- Doctor Repository → MySQL Database: reads and writes
- Department Repository → MySQL Database: reads and writes
- Insurance Repository → MySQL Database: reads and writes
- Appointments API → Global Exception Handler: errors handled by
- Patients API → Global Exception Handler: errors handled by
- Doctors API → Global Exception Handler: errors handled by
- Departments API → Global Exception Handler: errors handled by
- Insurance API → Global Exception Handler: errors handled by
