How imrajeevnayan/hospital-management-springboot works
Purpose and entry point
This is a server-rendered Hospital Management System for patient registration, appointment workflows, doctor views, and administration. The Spring Boot application starts at src/main/java/com/hms/hospital/HospitalApplication.java; browser requests are rendered as Thymeleaf HTML rather than through a separate frontend application.
Web and role-oriented UI boundary
MVC controllers define the application-facing request boundary and route users into role-specific pages:
• Administration: src/main/java/com/hms/hospital/controller/AdminController.java
• Patient/account and booking: src/main/java/com/hms/hospital/controller/PatientController.java, src/main/java/com/hms/hospital/controller/AppointmentController.java
• Doctor scheduling views: src/main/java/com/hms/hospital/controller/DoctorController.java
Their views are organized by role/feature under src/main/resources/templates/admin, src/main/resources/templates/patient, src/main/resources/templates/doctor, and src/main/resources/templates/appointment.
Authentication and authorization
Spring Security is centralized in src/main/java/com/hms/hospital/config/SecurityConfig.java. User identity, credentials, and assigned role are persisted through src/main/java/com/hms/hospital/entity/User.java and src/main/java/com/hms/hospital/entity/Role.java, with lookup/storage via src/main/java/com/hms/hospital/repository/UserRepository.java. This forms the boundary protecting administrative, doctor, and patient request paths.
Core domain model
The persistent business model centers on users, patient profiles, and appointments:
• src/main/java/com/hms/hospital/entity/User.java
• src/main/java/com/hms/hospital/entity/Patient.java
• src/main/java/com/hms/hospital/entity/Appointment.java
Appointments connect scheduling behavior to patient-facing booking/history and doctor/admin dashboards. The tree contains no separate Doctor entity or repository, so doctor identity/scheduling appears to be represented through users and controller-level flows.
Application service and persistence flow
The primary layered flow is controller → service → Spring Data repository → relational database. src/main/java/com/hms/hospital/service/PatientService.java encapsulates patient-oriented business operations, while repositories provide persistence access:
• src/main/java/com/hms/hospital/repository/PatientRepository.java
• src/main/java/com/hms/hospital/repository/AppointmentRepository.java
• src/main/java/com/hms/hospital/repository/UserRepository.java
This isolates web concerns from JPA-backed storage, although the available tree shows a dedicated service only for patient logic.
Runtime, configuration, and delivery
The runtime is a Maven/Spring Boot Java application, defined by pom.xml and configured through src/main/resources/application.properties. The README identifies PostgreSQL as the production database and Spring Security/Thymeleaf as material framework dependencies. Container deployment is supported by Dockerfile and docker-compose.yml, with Compose intended to run the application alongside its database service.
Main control flows
Unauthenticated users enter through src/main/java/com/hms/hospital/controller/HomeController.java and the login/registration templates (src/main/resources/templates/login.html, src/main/resources/templates/register.html). After authentication, role policy routes access to patient, doctor, or admin dashboards. Patient actions create/read appointment data; doctor and admin pages consume the same appointment/user records for scheduling and oversight. Database access remains behind repositories, and rendered HTML is the outbound response boundary.
Components 16
Web & UI
Server-rendered request boundary and role-specific views.
- Role MVC controllers · Admin, patient, appointment, and doctor request flows.
- HomeController
src/main/java/com/hms/hospital/controller/HomeController.java - Thymeleaf views · Role and feature templates render browser responses.
Application Core
Security, patient logic, and persistent domain.
- SecurityConfig · Protects role-specific request paths.
src/main/java/com/hms/hospital/config/SecurityConfig.java - PatientService · Encapsulates patient-oriented business operations.
src/main/java/com/hms/hospital/service/PatientService.java - User & Role · Credentials and assigned roles define access.
src/main/java/com/hms/hospital/entity/User.java - Patient
src/main/java/com/hms/hospital/entity/Patient.java - Appointment · Shared by booking, doctor scheduling, and administration.
src/main/java/com/hms/hospital/entity/Appointment.java
Persistence
Spring Data access to PostgreSQL.
- UserRepository
src/main/java/com/hms/hospital/repository/UserRepository.java - PatientRepository
src/main/java/com/hms/hospital/repository/PatientRepository.java - AppointmentRepository
src/main/java/com/hms/hospital/repository/AppointmentRepository.java - PostgreSQL
Runtime & Delivery
Spring Boot build, configuration, and containers.
- HospitalApplication
src/main/java/com/hms/hospital/HospitalApplication.java - Maven build
pom.xml - Application properties
src/main/resources/application.properties - Docker Compose · Runs the application with its database service.
docker-compose.yml
Connections 18
- Maven build → HospitalApplication: builds
- Application properties → HospitalApplication: configures
- Docker Compose → HospitalApplication: runs
- Docker Compose → PostgreSQL: runs
- HomeController → Thymeleaf views: renders
- Role MVC controllers → Thymeleaf views: renders
- SecurityConfig → HomeController: secures login flow
- SecurityConfig → Role MVC controllers: authorizes roles
- SecurityConfig → UserRepository: loads identities
- UserRepository → User & Role: persists
- Role MVC controllers → PatientService: patient operations
- PatientService → PatientRepository: manages profiles
- Role MVC controllers → AppointmentRepository: booking & scheduling
- PatientRepository → Patient: persists
- AppointmentRepository → Appointment: persists
- UserRepository → PostgreSQL: stores
- PatientRepository → PostgreSQL: stores
- AppointmentRepository → PostgreSQL: stores