A scalable quiz application built using Spring Boot microservices architecture, featuring service discovery with Eureka Server and persistent storage with MySQL.
The application is composed of the following microservices:
- Quiz Service: Manages quiz creation, retrieval, and lifecycle
- Question Service: Handles question bank operations and quiz question management
- Eureka Server: Enables service discovery and registration
- API Gateway (Optional): Provides a unified entry point for client applications
┌─────────────┐ ┌──────────────┐
│ │ │ │
│ API Gateway │─────┤ Eureka Server│
│ │ │ │
└─────────────┘ └──────────────┘
│ │
│ ┌──────┴───────┐
│ │ │
├────────────┤ Quiz Service │
│ │ │
│ └──────────────┘
│ ┌──────────────┐
│ │ Question │
└────────────┤ Service │
│ │
└──────────────┘
- Framework: Spring Boot 3.x
- Build Tool: Maven
- Database: MySQL 8.x
- Service Discovery: Netflix Eureka
- API Gateway: Spring Cloud Gateway
- Java Version: 17 or higher
- JDK 17+
- Maven 3.6+
- MySQL 8.x
- Docker (optional, for containerization)
git clone https://github.com/uchamod/springboot_quiz_application_with-_microservices.git
cd quiz-application
CREATE DATABASE quiz_service;
CREATE DATABASE question_service;
Each service has its own application.properties
file. Update database credentials and other configurations as needed.
Example for Quiz Service:
spring.application.name=quiz-service
server.port=8081
spring.datasource.url=jdbc:mysql://localhost:3306/quiz_service
spring.datasource.username=your_username
spring.datasource.password=your_password
Start the services in the following order:
- Eureka Server
cd eureka-server
mvn spring-boot:run
- Question Service
cd question-service
mvn spring-boot:run
- Quiz Service
cd quiz-service
mvn spring-boot:run
- API Gateway (Optional)
cd api-gateway
mvn spring-boot:run
GET /api/quizzes - List all quizzes
POST /api/quizzes - Create a new quiz
GET /api/quizzes/{id} - Get quiz by ID
PUT /api/quizzes/{id} - Update quiz
DELETE /api/quizzes/{id} - Delete quiz
GET /api/questions - List all questions
POST /api/questions - Add new question
GET /api/questions/{id} - Get question by ID
PUT /api/questions/{id} - Update question
DELETE /api/questions/{id} - Delete question
Build and run services using Docker:
# Build Docker images
docker-compose build
# Run services
docker-compose up
Run unit tests:
mvn test
Run integration tests:
mvn verify
Access service health and metrics:
- Eureka Dashboard: http://localhost:8761
- Quiz Service Actuator: http://localhost:8081/actuator
- Question Service Actuator: http://localhost:8082/actuator
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
quiz-application/
├── eureka-server/
├── quiz-service/
│ ├── src/
│ ├── Dockerfile
│ └── pom.xml
├── question-service/
│ ├── src/
│ ├── Dockerfile
│ └── pom.xml
├── api-gateway/
│ ├── src/
│ ├── Dockerfile
│ └── pom.xml
├── docker-compose.yml
└── README.md
Common issues and solutions:
-
Service Registration Failed
- Verify Eureka Server is running
- Check service configuration properties
- Ensure correct network connectivity
-
Database Connection Issues
- Verify MySQL is running
- Check database credentials
- Confirm database exists and is accessible
This project is licensed under the MIT License - see the LICENSE file for details.
- Spring Boot and Spring Cloud teams
- Netflix Eureka
- MySQL community
For more information or support, please open an issue in the repository.