RoomMaster is a conference room booking system built with a Dockerized Spring Boot application, JWT, and PostgreSQL database. It features a robust API for managing room bookings, maintenance schedules, and user authentication.
- Autogenerate Sample Data: Automatically generates conference rooms Amaze, Beauty, Inspire, and Strive and assign maintenance timings (9:00-9:15 AM, 1:00-1:15 PM, 5:00-5:15 PM) for them for an instant run.
- Same-Day Bookings: Allows bookings only for the current server day.
- Overlapping Bookings Handling: Rejects bookings that overlap with existing ones.
- Maintenance Time Checks: Prevents bookings during room maintenance periods.
- Validation Checks: Ensures valid time inputs and adheres to room capacity.
- Transaction Management: Ensures consistency in managing maintenance times.
- Dockerized Setup: Plug-and-play installation with Docker and Docker Compose.
- Great Coverage and Unit Tested: The application includes extensive unit tests, ensuring high code quality and reliable functionality.
- Edge Cases Handled:
- Race Conditions: Implemented pessimistic locking to prevent race conditions.
- Overlapping Bookings: Checks for existing bookings before confirming a new one.
- Overlapping with Maintenance Times: Cross-references booking times with maintenance schedules.
- Invalid Time Inputs: Ensures bookings are made in 15-minute intervals with valid start and end times.
- Booking on the Boundary of Maintenance Time: Prevents overlaps with maintenance times.
- Booking Across Midnight: Restricts bookings to within the same day.
- Last-Minute Bookings: Enforces a minimum lead time of 15 minutes for bookings.
- Deletion of Maintenance Times: Checks for existing bookings before allowing deletion.
- Multiple Admins Managing Maintenance Times: Implements transaction management for consistency.
- User Cancels Booking Last Minute: Implements a cancellation policy preventing last-minute cancellations.
- Handling Maximum Capacity: Enforces room capacity limits.
- Long-Running Bookings: Prevents long-running bookings from overlapping with maintenance times or blocking other users.
- Limit API access to prevent backend overload.
- Allow users to access only their bookings instead of admin/manager access.
- Use the UserDetailsService in a manually instantiated DaoAuthenticationProvide to address the AuthenticationProvider bean warning.
- Address the warnings that occur only on the first run for DB constrains.
- Hide certain user details in responses.
- Create a sample frontend with OpenAPI docs.
- Align standard timezone for consistent bookings across timezones so it won't conflict with frontend timezone.
- Make the application more containerized for microservices architecture.
- Create different profiles like dev and Amazon profile for deployment on Amazon and other providers.
- Booking other users' rooms with another user's bearer token.
- Public registration allows setting role as ADMIN or MANAGER.
- Double creation of room/maintenance times with the same name, capacity, and times not in 15-minute intervals.
- endTime can be set before startTime in room maintenance times, leading to invalid time intervals.
- Need to use other dependency packages to resolve security vulnerabilities for the old dependency packages.
- Docker: Install Docker by following the instructions for your OS below.
- Docker Compose: Install Docker Compose as part of Docker Desktop on Windows and Mac, or manually on Linux.
- Windows and Mac:
- Download and install Docker Desktop from the Docker website.
- Download and install Docker Desktop from the Docker website.
- Linux (Debian):
- Add Docker's official GPG key & add it to sources:
sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update
- Install Docker using the package manager:
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Install Docker Compose v2.29.1:
curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- Add Docker's official GPG key & add it to sources:
-
Clone the repository:
git clone https://github.com/AhmadAddas/RoomMaster-Backend.git cd RoomMaster-Backend -
Ensure the
.envfile is insrc/main/resources/.envis unmodified and correctly set up with the appropriate environment variables (Sample is provided for convenience). -
Build and run the Docker containers:
docker-compose up --build
-
The application will be available at
http://localhost:8081.
This section provides examples of how to interact with the RoomMaster API using Postman or any other HTTP client.
Endpoint: POST /api/v1/auth/register
Example Request:
{
"firstname": "Joe",
"lastname": "Doe",
"email": "joe@roommaster.ae",
"password": "password",
"role": "ADMIN"
}Endpoint: POST /api/v1/auth/authenticate
Example Request:
{
"email": "joe@roommaster.ae",
"password": "password"
}Endpoint: PATCH /api/v1/users
Headers:
Authorization: Bearer {{auth-token}}
Example Request:
{
"currentPassword": "password",
"newPassword": "newPassword",
"confirmationPassword": "newPassword"
}Endpoint: GET /api/v1/users
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: GET /api/v1/users/{userID}
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: GET /api/v1/rooms/
Endpoint: GET /api/v1/rooms/{roomID}
Endpoint: POST /api/v1/rooms
Headers:
Authorization: Bearer {{auth-token}}
Example Request:
{
"name": "Conference Room A",
"capacity": 20
}Endpoint: DELETE /api/v1/rooms/{roomID}
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: POST /api/v1/bookings
Headers:
Authorization: Bearer {{auth-token}}
Example Request:
{
"roomId": 1,
"userId": 1,
"startTime": "2024-08-28T10:00:00",
"endTime": "2024-08-28T12:00:00",
"numberOfPeople": 5
}Endpoint: GET /api/v1/bookings/{bookingID}
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: GET /api/v1/bookings
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: GET /api/v1/bookings/user/{userID}
Headers:
Authorization: Bearer {{auth-token}}
Endpoint: GET /api/v1/bookings/available-rooms
Query Parameters with example data:
startTime=2024-08-28T16:00:00endTime=2024-08-28T16:15:00
Example Request:
GET http://localhost:8081/api/v1/bookings/available-rooms?startTime=2024-08-28T16:00:00&endTime=2024-08-28T16:15:00
Endpoint: GET /api/v1/maintenance-times/room/{roomID}
Endpoint: POST /api/v1/maintenance-times/add
Headers:
Authorization: Bearer {{auth-token}}
Query Parameters with example data:
room=1startTime=18:00endTime=18:15
Example Request:
POST http://localhost:8081/api/v1/maintenance-times/add?room=1&startTime=18:00&endTime=18:15
Endpoint: DELETE /api/v1/maintenance-times/remove/{maintenanceTimeID}
Headers:
Authorization: Bearer {{auth-token}}
Query the Demo Hidden Endpoint from Public (ADMIN OR MANAGER OR USER)
Endpoint: GET /api/v1/demo-controller
Headers:
Authorization: Bearer {{auth-token}}
- Open the
RESTfulApiTest.httpfile in IntelliJ IDEA Ultimate. - Right-click on the file and select "Run" to execute the HTTP requests.
- Note that it might fail due to time differences as booking cannot be in the past.
- The backend uses port
8081&5430by default to avoid conflict with existing Spring Boot application & PostgreSQL service in host machine. - A sample
.envfile is provided for plug-and-play installation.
This project is licensed under the Apache License v2 - see the LICENSE file for details.
For any inquiries or issues, please make a PR request.