How hnjaman/complete-microservice-application works
Main Components
• Frontend: microservice-ui (an Angular-based application running on port 3000 that consumes backend services).
• Service Registry: service-registry (a Spring Boot application implementing Eureka, running on port 8761, which handles service discovery).
• API Gateway: api-gateway (a Spring Boot application that uses Zuul and Ribbon for dynamic routing, load balancing, and fault tolerance via Hystrix, running on port 8000).
• Backend Services: Two main microservices:
• product-service – exposing product endpoints, running on multiple instances (one at port 8081 and another at 8180), and connected to its own H2 database.
• offer-service – exposing offer endpoints, running on port 8082, using its own H2 database.
• Message Broker: RabbitMQ – not part of the source tree but integrated as a common messaging service for asynchronous, event-driven communication between offer-service (producer) and product-service (consumer).
Relationships and Interactions
• The microservice-ui frontend calls the API Gateway (http://localhost:8000) at specific paths (like “/product-service/products” and “/offer-service/offer”) to interact with the backend.
• The API Gateway receives incoming requests from clients and, using routing rules (through Zuul and Ribbon), forwards them to the appropriate backend service instance. It also provides load balancing (round-robin between product-service instances).
• Each backend service (product-service and offer-service) registers itself with the Service Registry (Eureka) for easy discovery by the API Gateway.
• The offer-service pushes event notifications (containing discount information) to RabbitMQ. The product-service subscribes to these events, receiving them asynchronously to update its database.
• Underlying databases (H2 for each microservice) and include the fact that they are independent.
Architectural Patterns and Design Principles
• Emphasis on microservice fundamentals: independent deployability, scalability, and inter-service communication.
• Use of API Gateway design pattern: central entry point, request routing, load balancing, centralized authentication/security.
• Service Discovery (using Eureka) is a critical pattern that allows decoupling of service endpoints.
• Event Driven Architecture (EDA) using RabbitMQ ensures asynchronous, decoupled communication, ensuring eventual consistency between services.
• Resilience patterns are also visible (e.g., Hystrix for circuit breaking) to prevent cascading failures.
Relevant Technologies and Frameworks
• Frontend: Angular (Angular CLI, Node, npm packages).
• Backend: Java, Spring Boot, Maven; specific libraries include Hystrix for circuit breaking in the API Gateway and Ribbon for load balancing.
• Service Registry: Eureka (Spring Cloud Netflix Eureka).
• API Gateway: Zuul (Spring Cloud Netflix Zuul).
• Messaging: RabbitMQ.
• Persistence: H2 databases for product-service and offer-service.
• Testing components and build tools including Maven and configuration files (pom.xml, application.properties/yml) show how each module is set up.