Skip to content

Repository files navigation

🏛️ Enterprise Microservices Architecture - E-Commerce Platform

Spring Boot Java Spring Cloud Docker Resilience4j License


📌 Overview

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.


📐 System Architecture

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
Loading

✨ Key Features

  • 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.

🛠️ Tech Stack

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

⚡ Getting Started

Prerequisites

  • Java 21 JDK
  • Apache Maven 3.8+
  • Docker & Docker Compose (Optional)

Option 1: Docker Compose Execution (Recommended)

Run the entire cluster in isolated containers:

docker-compose up --build -d

Option 2: Automated Local Launch (PowerShell)

# Build and run all microservices concurrently
.\start-all-services.ps1

Option 3: Manual Execution

Run 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:run

🧪 Usage & API Endpoints

1. Eureka Server Dashboard

2. Product Service (http://localhost:8100)

  • GET /api/products - Retrieve all products
  • POST /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"
}

3. Order Service (http://localhost:8200)

  • 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
}

🛡️ Circuit Breaker & Resiliency Behavior

If product-service is unreachable or experiencing latency:

  1. Resilience4j intercepts the Feign call.
  2. The Circuit Breaker transitions into OPEN status.
  3. The fallback method createOrderFallback() automatically responds, marking the order status as FAILED_FALLBACK and returning gracefully without cascading system failure.

👤 Author

Felipe da Silva Spínola
Cloud & Software Architecture Specialist

  • GitHub: @Fesisp
  • License: MIT License

About

Enterprise-grade microservices architecture built with Spring Boot 3.1, Java 21 LTS, Spring Cloud Gateway, Eureka Discovery, OpenFeign, and Resilience4j Circuit Breaker.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages