A comprehensive hotel management system built with Spring Boot and Jakarta EE, featuring room management, booking capabilities, and cloud storage integration.
- Room Management: Create, update, delete, and view hotel rooms
- Booking System: Handle room reservations and availability tracking
- Image Storage: AWS S3 integration for room photos
- User Management: Multi-user support with personalized room views
- Advanced Search: Filter rooms by type, price, and availability dates
- RESTful API: Clean REST endpoints for all operations
- Backend: Spring Boot 3.x with Spring MVC
- Database: Spring Data JPA with Jakarta Persistence
- Cloud Storage: AWS S3 for image management
- Code Simplification: Lombok for reduced boilerplate
- Java Version: JDK 21
- Build Tool: Maven
- Architecture: Service-Repository pattern
hotel-management-system/
βββ src/main/java/com/LIVTech/hotel_management_system/
β βββ controller/ # REST controllers
β βββ service/ # Business logic layer
β β βββ impl/ # Service implementations
β βββ repository/ # Data access layer
β βββ entity/ # JPA entities
β βββ dto/ # Data transfer objects
β βββ config/ # Configuration classes
βββ src/main/resources/
β βββ application.yml # Application configuration
β βββ static/ # Static resources
βββ pom.xml # Maven dependencies
- Java 21 or higher
- Maven 3.6+
- AWS Account (for S3 storage)
- Database (H2/MySQL/PostgreSQL)
- Clone the repository
git clone https://github.com/yourusername/hotel-management-system.git
cd hotel-management-system- Configure application properties
# src/main/resources/application.yml
spring:
datasource:
url: jdbc:h2:mem:hoteldb
username: sa
password: password
jpa:
hibernate:
ddl-auto: update
aws:
s3:
bucket-name: your-hotel-images-bucket
region: us-east-1- Set up AWS credentials
# Option 1: Environment variables
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
# Option 2: AWS credentials file (~/.aws/credentials)
[default]
aws_access_key_id = your-access-key
aws_secret_access_key = your-secret-key- Build and run
mvn clean install
mvn spring-boot:runOr using Maven wrapper:
./mvnw clean install
./mvnw spring-boot:run| Method | Endpoint | Description |
|---|---|---|
GET |
/api/rooms |
Get all rooms |
POST |
/api/rooms |
Create new room (with optional photo upload) |
GET |
/api/rooms/{id} |
Get room by ID |
PUT |
/api/rooms/{id} |
Update room (with optional photo upload) |
DELETE |
/api/rooms/{id} |
Delete room |
GET |
/api/rooms/types |
Get all room types |
GET |
/api/rooms/available |
Get all available rooms |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/rooms/user/{userId} |
Get rooms by user |
GET |
/api/rooms/user/{userId}/price/{maxPrice} |
Filter by user and max price |
GET |
/api/rooms/available/{checkIn}/{checkOut}/{roomType} |
Search available rooms by date range and type |
Create Room with Photo:
curl -X POST "http://localhost:8080/api/rooms" \
-H "Content-Type: multipart/form-data" \
-F "room={\"roomType\":\"Deluxe\",\"roomDescription\":\"Spacious room with city view\",\"roomPrice\":150.00};type=application/json" \
-F "photo=@room-image.jpg"Search Available Rooms:
curl -X GET "http://localhost:8080/api/rooms/available/2024-12-01/2024-12-05/Deluxe"The RoomServiceImpl provides comprehensive room management:
-
β Smart Image Handling:
- Upload new photos to S3
- Preserve existing photos when no new upload
- Handle both creation and updates seamlessly
-
π Advanced Search Capabilities:
- Filter by user preferences
- Price range filtering
- Date-based availability checking
- Room type categorization
-
π‘οΈ Robust Operations:
- Transactional updates for data consistency
- Input validation and error handling
- Partial updates for room modifications
// Core CRUD operations
getAllRooms() // Fetch all rooms
createNewRoom(room, photo) // Create with optional photo
updateRoom(id, room, photo) // Update with optional photo
deleteRoom(id) // Remove room
getRoomById(id) // Find specific room
// Advanced queries
getAllRoomsByUser(user) // User-specific rooms
getAllRoomsByUserAndPrice(user, maxPrice) // Price filtering
getAvailableRoomByDateAndRoomType(start, end, type) // Availability search
getAllAvailableRooms() // All available rooms
getAllRoomTypes() // Room type enumerationH2 (Development):
spring:
datasource:
url: jdbc:h2:mem:hoteldb
username: sa
password: password
h2:
console:
enabled: true
path: /h2-consoleMySQL (Production):
spring:
datasource:
url: jdbc:mysql://localhost:3306/hotel_management
username: ${DB_USERNAME:admin}
password: ${DB_PASSWORD:password}
driver-class-name: com.mysql.cj.jdbc.Driveraws:
s3:
bucket-name: ${AWS_S3_BUCKET_NAME:hotel-images-bucket}
region: ${AWS_REGION:us-east-1}Development (application-dev.yml):
spring:
jpa:
show-sql: true
hibernate:
ddl-auto: create-drop
logging:
level:
com.LIVTech.hotel_management_system: DEBUGProduction (application-prod.yml):
spring:
jpa:
hibernate:
ddl-auto: validate
logging:
level:
root: WARN
com.LIVTech.hotel_management_system: INFODockerfile:
FROM openjdk:21-jdk-slim
WORKDIR /app
COPY target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]Docker Compose:
version: '3.8'
services:
hotel-app:
build: .
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=prod
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
depends_on:
- db
db:
image: mysql:8.0
environment:
MYSQL_DATABASE: hotel_management
MYSQL_USER: admin
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- "3306:3306"Run tests:
mvn testRun with coverage:
mvn clean test jacoco:reportKey dependencies in pom.xml:
<dependencies>
<!-- Spring Boot Starters -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Jakarta EE -->
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- AWS S3 -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
</dependencies>βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Controller ββββββ Service ββββββ Repository β
β Layer β β Layer β β Layer β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β REST API β β Business Logic β β Database β
β Endpoints β β Transactions β β Operations β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
β
βΌ
ββββββββββββββββββββ
β AWS S3 β
β Image Storage β
ββββββββββββββββββββ
Create .github/workflows/ci.yml:
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- name: Run tests
run: mvn clean testWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature- Commit your changes
git commit -m 'Add some amazing feature'- Push to the branch
git push origin feature/amazing-feature- Open a Pull Request
- Follow Java naming conventions
- Use Lombok annotations to reduce boilerplate
- Write meaningful commit messages
- Add unit tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Bug Reports: Create an issue
- Feature Requests: Request a feature
- Questions: Start a discussion
LIVTech Solutions
- GitHub: @Elijah Mottey
- Email: elijahmottey5@gmail.com
- Spring Boot team for the excellent framework
- AWS for reliable cloud infrastructure
- Lombok project for reducing boilerplate code
- Jakarta EE for enterprise standards
- Open source community for inspiration
β If this project helped you, please consider giving it a star!
Built with β€οΈ using Spring Boot, Jakarta EE, and modern Java technologies