A fully backend Quiz Application built with Java Spring Boot following a Microservices Architecture. The application is decomposed into independently deployable services that communicate via REST, are discovered through a Eureka Service Registry, and are accessed through an API Gateway.
Client
β
βΌ
ββββββββββββββββββββββββ
β API Gateway β β Port 8765
β (Spring Cloud GW) β
ββββββββββββ¬ββββββββββββ
β Routes requests
ββββββββ΄βββββββ
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β Quiz β β Question β
β Service β β Service β
β (Port 8090)β β (Port 8080)β
ββββββββ¬βββββββ ββββββββ¬βββββββ
β Feign Client β
ββββββββββββββββββ
β² β²
β β
ββββββββ΄ββββββββ΄βββββββ
β Service Registry β β Port 8761 (Eureka)
βββββββββββββββββββββββ
Microservices-QuizApplication/
βββ GateWay/ # API Gateway (Spring Cloud Gateway)
βββ QuestionService/ # Manages quiz questions (CRUD)
βββ QuizService/ # Manages quizzes, generation, and scoring
βββ Service-registry/ # Eureka Service Discovery Server
| Technology | Purpose |
|---|---|
| Java 17+ | Core language |
| Spring Boot | Microservices framework |
| Spring Cloud Gateway | API Gateway and request routing |
| Spring Cloud Netflix Eureka | Service Discovery & Registration |
| Spring Data JPA | Data persistence / ORM |
| OpenFeign | Inter-service HTTP communication |
| PostgreSQL / MySQL | Relational database |
| Maven | Build tool |
| Postman | API testing |
The Eureka Server acts as the service registry. All other services register themselves here, enabling dynamic service discovery without hardcoded URLs.
- Built with
spring-cloud-starter-netflix-eureka-server - Dashboard available at:
http://localhost:8761
Responsible for all CRUD operations on quiz questions. Each question has a category, difficulty level, and multiple-choice options.
Key Endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /question/allQuestions |
Fetch all questions |
| GET | /question/category/{category} |
Fetch questions by category |
| POST | /question/add |
Add a new question |
| DELETE | /question/delete/{id} |
Delete a question by ID |
| GET | /question/generate |
Generate questions for a quiz |
| POST | /question/getScore |
Calculate score from responses |
Orchestrates quiz creation and scoring by calling the Question Service via Feign Client.
Key Endpoints:
| Method | Endpoint | Description |
|---|---|---|
| POST | /quiz/create |
Create a quiz (category + limit) |
| GET | /quiz/get/{id} |
Get quiz questions by quiz ID |
| POST | /quiz/submit/{id} |
Submit answers and get score |
The single entry point for all client requests. Routes incoming requests to the appropriate microservice based on path predicates.
Route Configuration:
/question-service/** β Question Service
/quiz-service/** β Quiz Service
- Java 17+
- Maven 3.6+
- PostgreSQL or MySQL running locally
- Git
Important: Services must be started in this exact order.
git clone https://github.com/Sathish292004/Microservices-QuizApplication.git
cd Microservices-QuizApplicationIn both QuestionService and QuizService, update src/main/resources/application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/quizdb
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=updatecd Service-registry
mvn spring-boot:runVisit: http://localhost:8761 to confirm Eureka is running.
cd ../QuestionService
mvn spring-boot:runcd ../QuizService
mvn spring-boot:runcd ../GateWay
mvn spring-boot:runAll services should now be registered and visible in the Eureka dashboard.
All requests go through the API Gateway at http://localhost:8765.
POST http://localhost:8765/question-service/question/add
Content-Type: application/json
{
"questionTitle": "What is JVM?",
"option1": "Java Virtual Machine",
"option2": "Java Verified Module",
"option3": "Java Visual Manager",
"option4": "None of the above",
"rightAnswer": "Java Virtual Machine",
"difficultyLevel": "Easy",
"category": "Java"
}POST http://localhost:8765/quiz-service/quiz/create
Content-Type: application/json
{
"category": "Java",
"numQuestions": 5,
"title": "Java Basics Quiz"
}GET http://localhost:8765/quiz-service/quiz/get/{quizId}POST http://localhost:8765/quiz-service/quiz/submit/{quizId}
Content-Type: application/json
[
{ "id": 1, "response": "Java Virtual Machine" },
{ "id": 2, "response": "Compile time" }
]The Quiz Service communicates with the Question Service using OpenFeign, a declarative REST client. Service discovery is handled automatically by Eureka β no hardcoded URLs are needed.
@FeignClient("QUESTION-SERVICE")
public interface QuizInterface {
@GetMapping("/question/generate")
ResponseEntity<List<Integer>> getQuestionsForQuiz(
@RequestParam String categoryName,
@RequestParam Integer numQuestions
);
}- β Microservices Architecture with Spring Boot
- β Service Discovery with Eureka Server
- β API Gateway with Spring Cloud Gateway
- β Declarative REST Client with OpenFeign
- β Inter-service Communication
- β
RESTful API Design with
ResponseEntity - β JPA-based data persistence
- β Separation of concerns across services
Use Postman or cURL to test the APIs. Import the endpoints listed above and ensure all four services are running before making requests.
Sathish Kumar B β @Sathish292004
This project is licensed under an Educational Use Only License. See the LICENSE file for details.
Β© 2026 Sathish Kumar B. All rights reserved.