StayEase

๐Ÿจ Hotel Booking Aggregator โ€“ Backend Service

A secure, role-based backend service built using Spring Boot and Gradle with MySQL to manage hotel listings and room bookings for a hotel management aggregator platform. The application exposes RESTful APIs secured with JWT-based authentication and enforces strict role-based authorization and business rules to prevent overbooking and ensure data integrity.

This project follows a clean layered architecture and incorporates production-ready practices such as validation, centralized error handling, logging, and unit testing.


๐Ÿ“Œ 1. Problem Statement

The goal of this project is to design and implement a backend service for a simplified hotel room booking system that:

The system assumes:


๐Ÿงฐ 2. Technology Stack & Rationale

Technology Purpose
Java 17 Backend programming language
Spring Boot (3.3.3) Framework for building RESTful APIs
Spring Security Authentication & authorization
JWT (io.jsonwebtoken:0.11.5) Stateless authentication
MySQL Relational database for persistent storage
Spring Data JPA ORM and database abstraction
BCrypt Secure password hashing
Gradle Build and dependency management
JUnit 5 & Mockito Unit and integration testing
SLF4J / Logback Logging

Why Gradle? Gradle provides efficient build automation, dependency management, and incremental compilation for faster builds, especially in Spring Boot projects.

Why MySQL? MySQL provides strong transactional guarantees and relational integrity, making it suitable for booking systems where consistency and accuracy are critical.


๐Ÿงญ 3. High-Level Design (HLD)

Client (Postman / Frontend)
        โ†“
Controller Layer
        โ†“
Service Layer
        โ†“
Repository Layer
        โ†“
MySQL Database

Layer Responsibilities


๐Ÿ‘ฅ 4. User Roles & Authorization

Role Description
USER Can browse hotels and create bookings
HOTEL_MANAGER Can update hotel details and cancel bookings
ADMIN Can create and delete hotels

Access Control Summary

Action USER HOTEL_MANAGER ADMIN
Register / Login โœ… โœ… โœ…
Browse Hotels โœ… โœ… โœ…
Create Hotel โŒ โŒ โœ…
Update Hotel โŒ โœ… โŒ
Delete Hotel โŒ โŒ โœ…
Create Booking โœ… โŒ โŒ
Cancel Booking โŒ โœ… โŒ

๐ŸŒŸ 5. Key Features

๐Ÿ” User Management

๐Ÿจ Hotel Management

๐Ÿ“… Booking Management

๐Ÿ›ก๏ธ Security

โš ๏ธ Validation & Error Handling

๐Ÿงช Testing


๐Ÿ“ก 6. API Documentation

Base URL

http://localhost:8081

Authentication APIs

Method Endpoint
POST /api/users/register
POST /api/users/login

Hotel APIs

Method Endpoint Access
GET /api/hotels Public
POST /api/hotels ADMIN
PUT /api/hotels/{hotelId} HOTEL_MANAGER
DELETE /api/hotels/{hotelId} ADMIN

Booking APIs

Method Endpoint Access
POST /api/bookings/{hotelId} USER
GET /api/bookings/{bookingId} Authenticated
DELETE /api/bookings/{bookingId} HOTEL_MANAGER

๐Ÿ’ป 7. Local Setup & Running the Application

๐Ÿ“ฆ Prerequisites

๐Ÿ”ง Setup Steps

# Clone the repository
git clone <your-github-repo-url>
cd hotel-booking-aggregator

# Configure database
# Update application.properties or application.yml with MySQL credentials

# Build the project
./gradlew clean build

# Run the application
./gradlew bootRun

๐ŸŒ Access

http://localhost:8081

๐Ÿ“ 8. Logging & Monitoring


๐Ÿš€ 9. Future Enhancements


๐Ÿ“ฌ 10. Contributions & Support

Contributions, issues, and feature requests are welcome. Feel free to open an issue or submit a pull request.


Maintained by: Shushant Rishav