How hieu-pt/fully-completed-microservices-java-springboot works
Project Type and Purpose
• This is a Java/Spring-Boot based set of microservices implementing a typical e-commerce backend.
• Uses Spring Cloud Config Server for centralized configuration, Eureka for service discovery, Spring Cloud Gateway for API routing, Kafka for asynchronous messaging, Zipkin for tracing, and individual databases per service.
Key Architectural Components
a. Spring Cloud Config Server
• Centralized configuration store; all microservices fetch their application.yml from here at startup (and refresh if needed).
b. Eureka Discovery Service
• Service registry; all microservices (Customer, Product, Order, Payment, Notification, Gateway) register here.
c. API Gateway (Spring Cloud Gateway)
• Single entry point for all client requests; handles routing, load-balancing, circuit-breaking, distributed tracing headers.
d. Business Microservices
• Customer Service (manages customer CRUD)
• Product Service (manages product catalog; uses its own relational DB and Flyway migrations)
• Order Service (manages orders; calls Customer, Product, and Payment via REST; produces order events to Kafka)
• Payment Service (processes payments; produces payment events to Kafka; may call external payment provider)
• Notification Service (consumes Kafka topics for orders and payments; sends emails or notifications)
e. Messaging Infrastructure
• Apache Kafka cluster with topics for order-confirmation and payment-confirmation.
f. Distributed Tracing
g. Data Stores
• One database per microservice (e.g., PostgreSQL/MySQL) so that each service owns its data.
High-Level Relationships and Data Flow
• Client/UI → API Gateway → (discovered via Eureka) → respective microservice
• Each microservice retrieves configuration from Config Server.
• When Order Service completes an order, it publishes an OrderConfirmation event to Kafka.
• When Payment Service processes a payment, it publishes a PaymentConfirmation event to Kafka.
• Notification Service subscribes to Kafka topics, processes events, and sends emails (via SMTP) or pushes notifications.
• All inter-service calls are traced: spans emitted to Zipkin.
Important Architectural Patterns
• Service Discovery Pattern (Eureka)
• API Gateway Pattern (Spring Cloud Gateway + Circuit Breaker)
• Centralized Configuration Pattern (Config Server)
• Event-Driven Architecture (Kafka topics)
• Database per Service Pattern
• Distributed Tracing Pattern (Zipkin)