Room Reservation API is a Spring Boot RESTful application for managing room bookings.
It allows viewing available rooms, creating and canceling bookings, and checking room availability.
Key features include:
- CRUD operations for rooms with filtering, pagination, and sorting.
- Booking management with validation to prevent overlapping bookings.
- Availability checks for rooms in a specified time range.
- DTO-based API responses for clean and safe data transfer.
- Global exception handling with meaningful HTTP status codes.
Programming Languages: Java, SQL
Frameworks & Libraries: Spring Boot, Spring Data JPA, Hibernate, Jakarta Validation
Databases: MySQL
Web Development: REST API
Other Tools & Technologies: Git, Maven
- Create, update, and delete rooms.
- Filter rooms by availability, location, or name.
- Pagination and sorting by id, name, capacity, or location.
- Create bookings with validation to prevent overlaps.
- Cancel bookings safely.
- Check room availability for a given time period.
- Transactional operations with Serializable isolation to prevent concurrency issues.
| Method | Path | Description | Parameters / Body |
|---|---|---|---|
| GET | /rooms |
Get list of rooms | page, size, sortBy, order, available, location, name |
| POST | /rooms |
Create a room | JSON RoomDTO |
| PUT | /rooms/{id} |
Update a room | JSON RoomDTO |
| DELETE | /rooms/{id} |
Delete a room | |
| GET | /bookings |
Get bookings with pagination | user, page, size |
| POST | /bookings |
Create a booking | JSON BookingDTO (roomId, user, startTime, endTime) |
| PUT | /bookings/{id}/cancel |
Cancel a booking | |
| GET | /bookings/{id}/availability |
Check room availability for a period | startTime, endTime |
- DTOs (RoomDTO, BookingDTO): Ensure clean API responses without exposing internal models.
- Validation: Input validation via
@Validand Jakarta Validation annotations. - Error Handling: Global
@ControllerAdvicehandles exceptions with proper HTTP status codes (400, 404, 409). - Repository Layer: Spring Data JPA repositories with custom queries for filtering and checking overlaps.
- Concurrency Control: Serializable transactions for safe booking creation and cancellation.
-
Get available rooms with pagination and filtering:
GET /rooms?page=0&size=5&sortBy=capacity&order=asc&available=true&location=1st%20Floor -
Check availability for a room: GET /bookings/12/availability?startTime=2025-08-01T10:00&endTime=2025-08-01T12:00
-
Create a booking: POST /bookings { "roomId": 12, "user": "Marko", "startTime": "2025-08-01T10:00", "endTime": "2025-08-01T12:00" }
-
Cancel a booking: PUT /bookings/5/cancel
- Strong backend architecture with layered design (Controller β Service β Repository).
- Transactional safety with concurrency handling to prevent double bookings.
- Clean API design using DTOs and pagination/sorting for large datasets.
- Professional error handling with descriptive messages.
- Demonstrates full Java backend skillset: Spring Boot, JPA, validation, REST, exception handling.