This project demonstrates building a robust microservices architecture using Spring Boot. It includes multiple microservices for handling different functionalities such as a Question Service and a Quiz Service, with service discovery, API gateway, and load balancing mechanisms implemented using Eureka and Spring Cloud tools.
Each microservice is designed to interact seamlessly through RESTful APIs and Feign Clients, making the system scalable and maintainable.
- Introduction
- Microservices
- Service Discovery with Eureka
- Inter-service Communication
- Load Balancing and API Gateway
- Getting Started
- Technologies Used
- How to Run
This project is structured to showcase the fundamental concepts of microservices development using Spring Boot and Spring Cloud. Each service is developed and deployed independently but can communicate with other services within the ecosystem. We will explore various concepts such as service discovery, load balancing, API gateway, and inter-service communication.
The Question Service manages questions and related operations like adding, updating, and retrieving questions. This service acts as the primary database for the questions used in quizzes.
The Quiz Service handles the logic for generating quizzes based on categories and retrieving the quiz data for user interactions. It communicates with the Question Service to fetch question data.
We use Eureka Server for service discovery. Each microservice registers itself to the Eureka server, which maintains a registry of all active services. This enables efficient communication between services and supports dynamic scaling.
Services interact with each other using OpenFeign, which simplifies HTTP-based communication. The Quiz Service uses Feign to make REST calls to the Question Service for fetching the required data.
Spring Cloud LoadBalancer is integrated to distribute the load between instances of the Question and Quiz services. This helps achieve fault tolerance and efficient resource utilization.
Spring Cloud Gateway serves as a single entry point for clients. It routes requests to the appropriate microservice based on the defined rules and handles cross-cutting concerns such as authentication, logging, and rate limiting.
- Java 17+
- Spring Boot 3.0+
- Maven 3.8+
The project is divided into multiple modules:
- question-service: Manages question data and exposes endpoints for CRUD operations.
- quiz-service: Manages quiz creation and interacts with the question service.
- eureka-server: Acts as a service registry for microservices.
- api-gateway: Handles routing and entry point for microservices.
- Spring Boot for building standalone applications
- Spring Cloud Eureka for service discovery
- Spring Cloud OpenFeign for inter-service communication
- Spring Cloud Gateway for API gateway
- Spring Cloud LoadBalancer for client-side load balancing
- PostgreSQL as the database for question and quiz data
-
Clone the repository:
git clone https://github.com/prajwal018/Quizlet-Application.git cd Quizlet-Application
-
Build and Run the Eureka Server:
cd eureka-server mvn clean install mvn spring-boot:run
-
Build and Run the Question Service:
cd ../question-service mvn clean install mvn spring-boot:run
-
Build and Run the Quiz Service:
cd ../quiz-service mvn clean install mvn spring-boot:run
-
Build and Run the API Gateway:
cd ../api-gateway mvn clean install mvn spring-boot:run
-
Access Services:
- Eureka Server:
http://localhost:8765
- Question Service:
http://localhost:8081
- Quiz Service:
http://localhost:8082
- API Gateway:
http://localhost:8080
- Eureka Server:
- Prajwal Kuchewar - Project Developer and Architect
Feel free to reach out with any questions or feedback!