An open API service indexing awesome lists of open source software.

https://github.com/sayammishra3/h_b_m_s_-project

A Java 8 Spring Boot-based Hotel Booking System with microservices architecture, JWT authentication, AWS S3 integration, Apache Kafka, Hibernate, and MySQL β€” built for scalable, secure backend development.
https://github.com/sayammishra3/h_b_m_s_-project

agile-methodologies apache-kafka api-gateway aws-s3 data-transfer-object er-diagram event-driven-architecture exception-handling hibernate-jpa java java-8 jwt-authentication maven microservices mysql postman rest-api spring-boot spring-security validation

Last synced: 3 months ago
JSON representation

A Java 8 Spring Boot-based Hotel Booking System with microservices architecture, JWT authentication, AWS S3 integration, Apache Kafka, Hibernate, and MySQL β€” built for scalable, secure backend development.

Awesome Lists containing this project

README

          

βœ… Summary for Project:-

πŸ“Œ Project Title := Hotel Booking Management System:,

πŸ“ Description:_
⏩ Hotel Booking Management System is a Java-based web application developed using Spring Boot and microservices architecture. It includes separate services for user authentication, room management, and bookings, with secure RESTful communication via an API Gateway. Features include JWT-based login, role-based access, AWS S3 image upload, and MySQL integration.

---

πŸ”§ Tech Stack:

βœ… Backend Language: Java 8
βœ… Framework: Spring Boot 2.4.x (Microservices Architecture)
βœ… Architecture: Microservices with RESTful APIs
βœ… Security: Spring Security with JWT Token
βœ… Service Discovery: Netflix Eureka
βœ… Inter-Service Communication: OpenFeign Clients
βœ… Persistence: Hibernate + Spring Data JPA
βœ… Database: MySQL 8.x
βœ… View Layer (if used): JSP + JSTL (tomcat-embed-jasper)
βœ… File Storage: AWS S3 (for image uploads)
βœ… API Support: @RestController-based endpoints
βœ… Validation: Hibernate Validator (@Valid, Bean Validation - JSR 380)
βœ… API Gateway: Spring Cloud Gateway
βœ… Logging: SLF4J / Logback
βœ… Build Tool: Maven
βœ… IDE: STS
βœ… Dev Tools: Spring Boot DevTools (for hot reload)

---

πŸ’‘ Key Features:

βœ… Microservices-based modular architecture.
βœ… Role-Based Login (Admin, Receptionist) with JWT security.
βœ… Room Booking (Create, Update, Delete, View).
βœ… Customer Details Management with proper validations.
βœ… Invoice Generation with auto bill calculation.
βœ… Room Availability & Status Tracking.
βœ… Add / View / Remove Hotel Staff (Employee Management).
βœ… AWS S3 integration for image upload (e.g., hotel images, customer docs).
βœ… REST APIs for frontend/mobile use (@RestController-based).
βœ… JSP-based front-end UI using Bootstrap + JSTL (where applicable).
βœ… Global Exception Handling using @ControllerAdvice.
βœ… Validation on all forms using @Valid (Hibernate Validator).
βœ… Logging & Error Tracking via SLF4J and Logback.
βœ… Seamless service communication via OpenFeign clients.
βœ… Service registration & discovery via Netflix Eureka.
βœ… Centralized routing and security with Spring Cloud Gateway.

---

## πŸ” Business Flow – Hotel Booking Management System:-
This section explains how the business process works from a user and hotel staff perspective.

### πŸ‘₯ Actors Involved:
- **Customer** – User who wants to book a hotel room.
- **Receptionist / Hotel Staff** – Handles room bookings and manages customer records.
- **Admin** – Manages rooms, staff, and has full control of the system.

### πŸ“ˆ Business Flow Steps:-

1. **Customer Enquiry / Walk-in / Online Access**
- Customer checks available rooms either online or at the hotel counter.

2. **Room Search & Selection**
- Staff or customer filters rooms based on room type, availability, and date range.

3. **Customer Details Entry**
- Staff adds customer name, contact info, ID proof, check-in/check-out dates.

4. **Room Booking**
- Booking entry is created in the system.
- Room status is marked as β€œBooked”.
- Confirmation is generated (can be printed or viewed in UI).

5. **Invoice Generation**
- After check-out, the system calculates billing details (duration, price per night, taxes).
- Invoice is generated and stored against customer record.

6. **Room Status Update**
- After checkout, room is marked as β€œAvailable” again.

7. **Admin Operations**
- Add/edit/delete rooms.
- Manage hotel staff accounts.
- Monitor all bookings and customers.
- Download reports or check logs.

### πŸ” Access Control (Role-Based):
| Role | Allowed Modules |
|--------------|-------------------------------------------|
| Admin | All modules (rooms, staff, booking, logs) |
| Receptionist | Bookings, Customer, Invoice |
| Customer | View availability (if public) |

πŸ’‘ This flow ensures:-
- Efficient tracking of room usage
- No double-booking issues
- Full control via Admin panel
- Accurate billing & customer history

---

## βœ…βš™οΈ Technical Flow – Hotel Booking Management System:-

This section explains how the application works behind the scenes β€” from the moment a request hits the system to how data is processed and stored.

### 🧭 Request Lifecycle:-
Client (Browser / Postman) -> Spring MVC Controller (@Controller / @RestController) -> Service Layer (@Service) -> Data Access Layer (Repository / DAO) -> Database (MySQL)

### πŸ” Component Breakdown:
#### 1️⃣ Controller Layer (`@RestController` or `@Controller`):-
- Handles incoming HTTP requests.
- Maps URLs to Java methods using `@GetMapping`, `@PostMapping`, etc.
- Calls service layer methods.
- Returns views (for JSP) or JSON response (for REST).

``java
@GetMapping("/rooms")
public List getAllRooms() {
return roomService.getAllRooms();
}

#### 2️⃣ Service Layer (@Service):-
Contains business logic.
Handles validations, calculations, and transformations.
Interacts with repository (DAO) to access DB.
Ensures separation of concerns.

''java
public List getAllRooms() {
return roomRepository.findAll();
}

#### 3️⃣ Repository Layer (@Repository):-
Interfaces extending Spring Data JPA’s JpaRepository.
Handles CRUD operations with zero SQL code.
Automatically translates method names into SQL queries.

''java
public interface RoomRepository extends JpaRepository {
List findByStatus(String status);
}

#### 4️⃣ Database Layer (MySQL):-
Stores all persistent data (rooms, bookings, customers, users, etc.).
Schema usually created using JPA annotations or schema.sql.

#### πŸ” Data Flow Example: Room Booking:-
User submits booking form from frontend (/bookings)
Controller receives request and passes it to service layer
Service performs validations, updates room status, and saves booking
Repository saves data to MySQL
Response is returned to the user (confirmation page or API response)

#### 🧰 Tools Involved:-
Layer Technology Used
Controller Spring MVC (@Controller, @RestController)
Service Spring Framework (@Service)
Repository Spring Data JPA (@Repository)
View (Web) JSP + JSTL
Persistence Hibernate + JPA
Database MySQL

πŸ’‘ This structure follows MVC + Service + DAO pattern, ensuring scalability, readability, and separation of concerns.

---

πŸš€ Access Points:-

βœ… Web App: `http://localhost:8080`
βœ… REST API (Sample): `http://localhost:8080/bookings`

---

🌐 API Examples:

| Method | Endpoint | Description |
|--------|--------------------|---------------------------|
| GET | `/rooms` | Get all rooms |
| GET | `/bookings` | View all bookings |
| POST | `/bookings` | Create a new booking |
| DELETE | `/bookings/{id}` | Delete booking by ID |
| PUT | `/rooms/{id}` | Update room status |

---

πŸ“ Folder Structure Highlights:

Hotel_Management_System_Project/
β”œβ”€β”€ src/main/java/
β”‚ β”œβ”€β”€ controller/ # Handles web/API requests
β”‚ β”œβ”€β”€ model/ # Entity classes
β”‚ β”œβ”€β”€ repository/ # JPA repositories
β”‚ └── service/ # Business logic
β”œβ”€β”€ src/main/webapp/
β”‚ └── WEB-INF/jsp/ # JSP view templates
β”œβ”€β”€ src/main/resources/
β”‚ β”œβ”€β”€ application.properties
β”‚ └── static/ # Static assets (if any)
β”œβ”€β”€ pom.xml # Maven project dependencies
β”œβ”€β”€ .project/.classpath # Eclipse config

---

🧩 Basic Swagger Configuration:-

@Configuration
@EnableOpenApi
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.OAS_30)
.select()
.apis(RequestHandlerSelectors.basePackage("com.example.hotel"))
.paths(PathSelectors.any())
.build();
}
}

✍️ Usage in Controller:-

@RestController
@RequestMapping("/bookings")
@Api(value = "Booking Controller", tags = "Bookings")
public class BookingController {
@ApiOperation(value = "Get all bookings", response = List.class)
@GetMapping
public List getAllBookings() {
return bookingService.getAllBookings();
}
}

---

πŸ“˜ Swagger UI Integration (API Testing):-

## πŸ“˜ Swagger UI – API Documentation
This project supports API documentation using **Swagger**.
βœ… Swagger UI helps test, document, and visualize all REST endpoints in the system.
### πŸ”— Access URL:- http://localhost:8080/swagger-ui/

### πŸ”§ Maven Dependency (Add in `pom.xml`) ⏩``xml

io.springfox
springfox-boot-starter
3.0.0

---

🧬 ER Diagram (Entity Relationship):-

## 🧬 Entity Relationship Diagram:-
The following is a simplified ER Diagram for the Hotel Management System.

```text
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Customer │─────▢│ Booking │◀─────▢│ Room β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β–²
β”‚ β”‚
β–Ό β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Invoice β”‚ β”‚ Staff β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

---

πŸ“Œ Bonus:

πŸ’ Suitable for showcasing Java Full-Stack Web Development
πŸ’ Demonstrates real-world usage of Spring MVC + JSP + Hibernate
πŸ’ Easy to deploy on any Apache Tomcat-compatible server

---

⏩ Ensure that your local MySQL server is running and the hotel_db database exists before running the app.
⏩ Use a tool like Postman to test REST endpoints separately if required.

---

πŸ“’β€ΌοΈ Some Important Notes:

⏩ After cloning or downloading the project, make sure to update your `application.properties` file with the correct MySQL credentials:

```properties
spring.datasource.url=jdbc:mysql://localhost:3306/hotel_db
spring.datasource.username=your_username
spring.datasource.password=your_password