← Back to work
Backend · Feb 2025

MediConnect

Production-ready healthcare management API. Spring Boot 3.x + Java 17, with Spring Security, JWT and role-based access control. Thread-safe appointment scheduling via optimistic locking (@Version) and transactions eliminates race conditions under concurrent load.

Java 17Spring BootSpring SecurityPostgreSQLJWT
View source
Engineering decisions

Thread-safe appointment scheduling

Appointment slots are a classic double-booking race condition under concurrent requests. Each appointment row carries a @Version column; Spring Data JPA's optimistic locking rejects a write if the row changed since it was read, so a losing request gets a clean conflict instead of silently overwriting another patient's booking. Wrapped in @Transactional boundaries so a partial write never lands.

JWT auth with role-based access

Spring Security filters validate a JWT on every request and resolve it to a role (patient, doctor, admin) before it reaches a controller. Endpoints are locked down by role at the security-config level rather than scattered checks in business logic, so adding a new role doesn't mean auditing every service method.

Thin controllers, service-layer business logic

Controllers only handle request/response mapping and validation. Scheduling rules, conflict handling and access checks all live in the service layer, which keeps the HTTP layer swappable and the business rules unit-testable without spinning up a servlet container.