This repository demonstrates the implementation of microservices using Spring Boot. The project is divided into two independent services: QuizService and QuestionService, each with its own database and functionality, connected through microservices architecture.
Microservices architecture breaks down complex applications into smaller, independent services. This enhances scalability and maintainability. Below are the key principles and advantages of microservices:
- Self-Contained Services: Applications are divided into self-contained services, each focusing on a specific function, simplifying development and maintenance.
- Business Feature Focus: Each microservice handles a specific business feature, such as user authentication or product management, enabling specialized development.
- API-Based Communication: Services interact via APIs, ensuring standardized information exchange and integration.
- Technology Diversity: Different technologies can be used for each service, allowing teams to select the best tools for their needs.
- Independent Updates: Microservices can be updated independently, reducing risks during changes and enhancing system resilience.
- Database: PostgreSQL
- Table:
Quiz - Handles all operations related to quizzes.
- Database: PostgreSQL
- Table:
Question - Manages all operations related to questions.
The application demonstrates inter-microservice communication between QuizService and QuestionService. When a user fetches quiz data from QuizService, related questions are included in the response.
- Protocol: HTTP/HTTPS
- Communication Type: RESTful APIs
- Tool Used: OpenFeign
OpenFeign is used to simplify communication between services, enabling seamless data exchange and integration.
- Fetch quizzes with associated questions in a single API call.
- Independent services with their own databases for modularity and scalability.
- Demonstrates the power of microservices architecture using Spring Boot.
- Java 17 or higher
- PostgreSQL
- Maven or Gradle
- Spring Boot 3.x
- Clone the repository.
- Set up PostgreSQL databases for QuizService and QuestionService.
- Configure database connection properties in the respective
application.propertiesorapplication.ymlfiles. - Build and run each service using:
or
mvn spring-boot:rungradle bootRun - Use APIs to interact with the services.
- GET /quizzes: Fetch all quizzes (includes related questions via microservices communication).
- POST /quizzes: Create a new quiz.
- GET /questions: Fetch all questions.
- POST /questions: Create a new question.
- Spring Boot: For creating microservices.
- PostgreSQL: As the database for both services.
- OpenFeign: For inter-service communication.
- RESTful APIs: For service interaction.
- Scalability: Independent scaling of QuizService and QuestionService.
- Maintainability: Easier debugging and updates due to modular design.
- Resilience: Changes in one service do not affect others.
This project is licensed under the MIT License. See the LICENSE file for details.
- OpenFeign documentation for simplifying inter-microservice communication.
- Spring Boot community for providing robust tools for building scalable applications.