How akashbhuiyan/microservice-architecture-java works
Main Components
• Microservice Applications: “accounts”, “cards”, and “loan” – each with similar structures (controllers, services, repositories, DTOs, error handling, mapping, and domain entities).
• Shared Module: “common” – holds common DTOs and entities that are reused between services.
• Infrastructure Services:
• Config Server (“configserver”) – manages external configurations using Spring Cloud Config, with specific configuration files for each microservice and different environments (dev, qa, prod).
• Eureka Server (“eurekaserver”) – manages service registration and discovery.
• Gateway Server (“gatewayserver”) – serves as the API gateway, handling routing, filtering (with request/response trace filters) and security (with components such as the KeycloakRoleConverter and security configurations).
• External Integration and Support:
• MySQL databases – separate instances for each microservice (e.g., accountsdb, loandb, cardsdb).
• RabbitMQ – used with Spring Cloud Bus to enable dynamic refresh of configurations.
• Redis server – used for rate limiting.
• Monitoring tools – Prometheus and Micrometer for application and system metrics collection and visualization in Grafana.
• Keycloak – for authentication and authorization.
Relationships and Data Flows
• All microservices (accounts, cards, loan) register themselves with the Eurekaserver and are routed via the Gatewayserver.
• They source their configuration data from the Configserver, which is refreshed dynamically via RabbitMQ and Spring Cloud Bus.
• Each service communicates with its underlying MySQL database.
• The Gatewayserver also integrates with security (Keycloak) and acts as the entry point for external traffic.
• Monitoring components (Prometheus and Micrometer) collect metrics from the individual microservices, while logging is centralized through Loki, with dashboards in Grafana. Redis, acting as the rate limiter, may be used by the gateway or other service components.
• Docker-compose setups indicate multiple environments (default, prod, qa, observability) that enable deployment orchestration of these components.
Architectural Patterns and Design Principles
• Microservices Pattern: Each service is self-contained with its own API (e.g., controllers, DTOs) and data store.
• API Gateway: Separation of concerns by channeling external requests through the Gatewayserver.
• Service Discovery: Ensured via Eureka.
• Centralized Configuration Management: Using Spring Cloud Config Server.
• Circuit Breakers & Resilience: Actuator endpoints for circuit breaker events indicate built-in resilience.
• Containerization: Dockerfiles for each service and docker-compose ensure consistent deployment.
• Observability: Comprehensive integration of metrics and logging systems (Prometheus, Grafana, Micrometer, Loki, MinIO).
Technology Stack and Frameworks
• Java Spring Boot for microservices.
• Spring Cloud components for configuration, discovery, gateway routing, and dynamic refresh.
• Maven as the build and dependency management tool.
• Docker for containerization.
• External systems such as RabbitMQ, MySQL, Redis, Grafana, Loki, Prometheus, and Keycloak.
• Eureka Server centrally to show service registration/discovery.
• An API gateway (gatewayserver) as the entry point for requests, highlighting its filtering and routing capabilities.
• Integration with external systems: databases (MySQL), message broker (RabbitMQ), rate limiter (Redis), log management (Grafana – Loki – MinIO), and monitoring (Prometheus – Micrometer).
• Optionally, include indications for security integration via Keycloak.