This project is a microservices-based architecture for managing hotel operations. It consists of three main services: UserService, HotelService, and RatingService. The services are designed to handle user management, hotel information, and ratings, respectively, and are integrated using Spring Cloud components for resilience and scalability.
- API Gateway: Centralized routing for all microservices, implemented with Spring Cloud Gateway.
- Service Discovery with Eureka: Dynamic service registration and discovery.
- Resilience4j Integration: Circuit breaker and rate limiter patterns to handle failures and control traffic.
- Feign Client: Simplifies inter-service communication with declarative REST clients.
- Centralized Configuration: Externalized configuration management using Spring Cloud Config Server.
Manages user-related operations, including retrieving and saving user data.
-
Get All Users
- URL:
GET /user/getAll
- Description: Retrieves a list of all users.
- URL:
-
Get User by Username
- URL:
GET /user/username/{username}
- Description: Retrieves a user by their username. Uses Circuit Breaker for resilience.
- URL:
-
Save a New User
- URL:
POST /user/save
- Description: Saves a new user.
- URL:
-
Save Multiple Users (Dummy Data)
- URL:
POST /user/dummydata
- Description: Saves multiple users in a single request.
- URL:
Handles hotel information and operations.
-
Get Hotel by ID
- URL:
GET /hotel/get-hotel/{hotelId}
- Description: Retrieves details of a specific hotel by its ID.
- URL:
-
Get All Hotels
- URL:
GET /hotel/get-all-hotel
- Description: Retrieves a list of all hotels.
- URL:
-
Create a New Hotel
- URL:
POST /hotel/create-hotel
- Description: Creates a new hotel entry.
- URL:
-
Create Multiple Hotels
- URL:
POST /hotel/create-listof-hotel
- Description: Inserts multiple hotels in a single request.
- URL:
Manages ratings and reviews for hotels.
-
Create a Single Rating
- URL:
POST /rating/create-rating
- Description: Creates a new rating for a hotel.
- URL:
-
Create Multiple Ratings
- URL:
POST /rating/create-multiple-rating
- Description: Creates multiple ratings in a single request.
- URL:
-
Get All Ratings
- URL:
GET /rating/get-all-rating
- Description: Retrieves all ratings.
- URL:
-
Get Ratings by User ID
- URL:
GET /rating/get-rating-by-userid/{userName}
- Description: Retrieves all ratings made by a specific user.
- URL:
-
Get Ratings by Hotel ID
- URL:
GET /rating/get-rating-by-hotelid/{hoteID}
- Description: Retrieves all ratings for a specific hotel.
- URL:
- JDK 17 or above
- Maven 3.6+
- MySQL Database
- Config Server
- Eureka Server
-
Clone the Repository
git clone https://github.com/iamkgehlot/HotelMicroservices.git cd HotelMicroservices
-
Set Up the Database Update the
application.properties
orapplication.yml
files for each service with your MySQL database details:spring.datasource.url=jdbc:mysql://localhost:3306/<database_name> spring.datasource.username=<your-username> spring.datasource.password=<your-password>
-
Start the Eureka Server Navigate to the Eureka Server directory and run the application:
mvn spring-boot:run
-
Start the Config Server Ensure that the Config Server is running to provide configuration to all services.
-
Start the Microservices Navigate to each microservice directory (UserService, HotelService, RatingService) and run:
mvn spring-boot:run
-
Run the API Gateway Start the API Gateway to route requests to the appropriate services:
mvn spring-boot:run
Here are some of the notable commits:
-
Added Resilience4j Circuit Breaker Configuration to UserService
- Added resilience features for better fault tolerance.
-
Implemented API Gateway for all routes
- Set up centralized routing for all microservices.
-
Added Feign Client and Eureka Server configuration
- Integrated Feign Client for inter-service communication and Eureka Server for service discovery.
-
Created Rating Service
- Implemented the service for managing hotel ratings.
-
Created Hotel Service
- Developed functionality for managing hotel information.
-
Created User Service
- Built the user management service for handling user data.
Kamlesh Gehlot - iamkgehlot