A modern, cloud-native distributed system architecture built with Java 21 and Spring Boot 3.5. This project demonstrates a production-ready microservices foundation featuring Service Discovery, API Gateway Routing, and Inter-service communication using OpenFeign.
The system follows the API Gateway pattern. All external traffic flows through the Gateway, which handles routing to internal services. Services register dynamically with Eureka and communicate synchronously via OpenFeign.
graph TD
Client[External Client] -->|HTTP:8080| Gateway[API Gateway]
subgraph Infrastructure
Eureka[Eureka Discovery Server]
end
subgraph Microservices
Gateway -->|Routes| User[User Service]
Gateway -->|Routes| Product[Product Service]
Gateway -->|Routes| Order[Order Service]
User -.->|Register| Eureka
Product -.->|Register| Eureka
Order -.->|Register| Eureka
Gateway -.->|Fetch Registry| Eureka
Order -->|OpenFeign| Product
end
- Core: Java 21, Spring Boot 3.5.8
- Discovery: Netflix Eureka Server
- Routing: Spring Cloud Gateway (Reactive)
- Communication: OpenFeign (Declarative REST Client)
- Database: H2 In-Memory (Simulating independent DBs per service)
- Tooling: Maven (Multi-Module), Docker, Docker Compose, Lombok
| Service | Port | Description |
|---|---|---|
| Discovery Server | 8761 |
Service Registry (Eureka) |
| API Gateway | 8080 |
Single Entry Point & Routing |
| User Service | 8081 |
User Management |
| Product Service | 8082 |
Product Catalog Inventory |
| Order Service | 8083 |
Order Processing (Calls Product Service) |
- Java 21 SDK
- Maven 3.8+
- Docker (Optional)
This spins up the entire fleet (Registry, Gateway, and all Microservices) in orchestrated containers.
docker-compose up -d --buildYou must start the services in this specific order to ensure registration works immediately (though they are resilient enough to retry).
- Discovery Server:
mvn spring-boot:run -pl discovery-server- Product Service:
mvn spring-boot:run -pl product-service- User Service:
mvn spring-boot:run -pl user-service- Order Service:
mvn spring-boot:run -pl order-service- API Gateway:
mvn spring-boot:run -pl api-gatewayAll requests should be sent to localhost:8080.
POST /api/users- Create UserGET /api/users- List Users
POST /api/products- Create ProductGET /api/products- List ProductsGET /api/products/{id}- Get Product by ID
POST /api/orders- Place Order- Payload:
{ "productId": 1, "quantity": 5 } - Logic: Verifies product existence and price via OpenFeign before saving.
- Payload: