Welcome to the Microservice Application! This project demonstrates a microservice architecture using five distinct services, all orchestrated through a central API Gateway. The services are registered dynamically using Netflix Eureka, ensuring seamless communication and scalability.
This microservice application is designed to demonstrate how various services can interact with each other through a centralized API Gateway. Each service operates independently, allowing for isolated development and deployment. The services are:
- Service Registry - Registers all the services using Netflix Eureka.
- API Gateway - Centralized entry point for all requests, routing them to the appropriate service.
- User Service - Manages CRUD operations for users.
- Hotel Service - Manages CRUD operations for hotels.
- Rating Service - Manages CRUD operations for ratings.
With this setup, users can perform CRUD operations across all services via a single API Gateway, eliminating the need to interact with each service individually.
- Role: Registers and keeps track of all services.
- Technology: Netflix Eureka
- Role: Centralized routing for all service requests.
- Technology: Spring Cloud Gateway
- Role: Handles CRUD operations for user data.
- Endpoints:
**GET micro/users**
**POST micro/users**
**PUT micro/users/{id}**
**DELETE micro/users/{id}**
- Role: Manages CRUD operations for hotel data.
- Endpoints:
**GET micro/hotels**
**POST micro/hotels**
**PUT micro/hotels/{id}**
**DELETE micro/hotels/{id}**
- Role: Manages CRUD operations for rating data.
- Endpoints:
**GET micro/ratings**
**POST micro/ratings**
**PUT micro/ratings/{id}**
**DELETE micro/ratings/{id}**
- JDK 17 or higher
- Maven
- MySQL
- PostgreSQL
- MongoDB
-
Clone the repository:
git clone https://github.com/yourusername/microservice-application.git cd microservice-application
-
Start the Service Registry:
cd serviceRegistry mvn spring-boot:run
-
Start the API Gateway:
cd APIGateway mvn spring-boot:run
-
Start the User Service:
cd userService mvn spring-boot:run
-
Start the Hotel Service:
cd HotelService mvn spring-boot:run
-
Start the Rating Service:
cd RatingService mvn spring-boot:run
Each service will register itself with the Service Registry and be accessible through the API Gateway and also can access them individually.
Once all services are up and running, you can interact with the application through the API Gateway:
- API Gateway URL:
http://localhost:9001
You can use tools like Postman or curl to make requests to the API Gateway, which will then route them to the appropriate service.
-
Create User:
POST /micro/users/ { "name": "Prabhu", "email": "prabhu@mail.com", "phone": "8849337894" }
-
Get User:
GET /micro/users/{userId}/
-
Get All Users:
GET /micro/users/
-
Create Hotel:
POST /micro/hotels/ { "name": "Prabhu Hotel Services", "location": "Mumbai, Maharashtra", "about": "good hotel" }
-
Get Hotel:
GET /micro/hotels/{hotelId}/
-
Get All Hotels:
GET /micro/hotels/
-
Create Rating:
POST /micro/ratings { "userId": "2b4755e0-be7a-4817-a33a-b5e53d76b40d", "hotelId": "62b499f4-d588-4717-82ac-3a6ea38b0b6a", "rating": 4, "feedback": "good hotel, service is good at a decent price." }
-
Get All Ratings:
GET /micro/ratings/
-
Get Ratings of User:
GET micro/ratings/users/{userId}/
-
Get Ratings of Hotel:
GET micro/ratings/hotels/{hotelId}/
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.