This project is an Enterprise Reference Architecture designed to demonstrate fault-tolerance, dynamic service discovery, and inter-service communication in distributed cloud systems. Built with Spring Boot 3.1.5 and Java 21 LTS, it models a high-availability distributed E-Commerce backend featuring product catalog management, dynamic edge routing, and resilient order processing.
Architected following Domain-Driven Design (DDD), Twelve-Factor App, and Clean Code principles, this repository serves as a production-grade blueprint for scalable microservice environments.
flowchart TD
subgraph ClientLayer [" Client & Edge Layer "]
Client[🌐 Client / Postman / Frontend]
end
subgraph Discovery [" Service Registry "]
Eureka["🔍 Eureka Server\n(Port 8761)\n• Netflix Eureka Discovery"]
end
subgraph GatewayLayer [" Edge Routing & Security "]
Gateway["🛡️ Spring Cloud Gateway\n(Port 8700)\n• Dynamic Routing & Bearer Auth"]
end
subgraph CoreServices [" Core Domain Microservices "]
ProductService["📦 Product Service\n(Port 8100)\n• Catalog Management\n• Spring Data JPA & H2"]
OrderService["🛒 Order Service\n(Port 8200)\n• Order Processing & Simulation\n• OpenFeign + Resilience4j Circuit Breaker"]
end
Client -->|HTTP / REST| Gateway
Gateway <-->|Service Discovery| Eureka
ProductService <-->|Heartbeat Register| Eureka
OrderService <-->|Heartbeat Register| Eureka
Gateway -->|Route /api/products| ProductService
Gateway -->|Route /api/orders| OrderService
OrderService -->|OpenFeign + Fallback| ProductService
- Dynamic Service Discovery: Service registration and heartbeat monitoring with Netflix Eureka.
- Edge Routing & API Gateway: Centralized entry point with Spring Cloud Gateway and security filters.
- Resilient Inter-Service Communication: Declarative REST client calling via Spring Cloud OpenFeign.
- Circuit Breaker & Fallback Handling: Automated fault tolerance and degradation using Resilience4j.
- Relational Persistence: Isolated domain databases backed by Spring Data JPA and H2 Database.
- Containerization Ready: Multi-stage lightweight Docker images powered by
eclipse-temurin:21-jre-alpine.
| Domain | Technologies & Libraries |
|---|---|
| Language & Runtime | Java 21 LTS (OpenJDK Temurin) |
| Framework Core | Spring Boot 3.1.5, Spring Framework 6 |
| Cloud Ecosystem | Spring Cloud 2022.0.4 (Eureka, Gateway, OpenFeign) |
| Fault Tolerance | Resilience4j (Circuit Breaker & Fallbacks) |
| Persistence & Database | Spring Data JPA, Hibernate, H2 Database |
| Containerization & Tooling | Docker, Docker Compose, Apache Maven |
- Java 21 JDK
- Apache Maven 3.8+
- Docker & Docker Compose (Optional)
Run the entire cluster in isolated containers:
docker-compose up --build -d# Build and run all microservices concurrently
.\start-all-services.ps1Run each service in separate terminal sessions in the following sequence:
# 1. Start Eureka Server (Service Discovery)
cd eureka-server && mvn spring-boot:run
# 2. Start API Gateway
cd api-gateway && mvn spring-boot:run
# 3. Start Product Service
cd product-service && mvn spring-boot:run
# 4. Start Order Service
cd order-service && mvn spring-boot:runGET /api/products- Retrieve all productsPOST /api/products- Create a new product
POST /api/products
Content-Type: application/json
{
"nome": "Dell XPS 15 Laptop",
"preco": 2499.99,
"descricao": "High performance workstation with 32GB RAM"
}POST /api/orders- Process an order (fetches product info via Feign & calculates total)
POST /api/orders
Content-Type: application/json
{
"productId": 1,
"customerId": 101,
"quantity": 2
}If product-service is unreachable or experiencing latency:
- Resilience4j intercepts the Feign call.
- The Circuit Breaker transitions into
OPENstatus. - The fallback method
createOrderFallback()automatically responds, marking the order status asFAILED_FALLBACKand returning gracefully without cascading system failure.
Felipe da Silva Spínola
Cloud & Software Architecture Specialist
- GitHub: @Fesisp
- License: MIT License