Loading repository data…
Loading repository data…
hacisimsek / repository
A sample microservice project using Spring Boot 3.2.12 and Java 17, implementing an orchestration-based Saga Pattern. Includes Order, Payment, Inventory, Notification, and Orchestrator services. Supports ACID via @transactional and Docker Compose for container orchestration.
A professional implementation of an e-commerce system using microservice architecture with Saga pattern for distributed transaction management.
Created by: hacisimsek
Last Updated: 2025-05-26 18:40:03
This project implements a robust e-commerce system using a microservices architecture. The system handles order processing, inventory management, payment processing, shipping logistics, and customer notifications while maintaining data consistency across distributed services through the Saga pattern.
The architecture follows the microservices pattern with the following components:
graph TD
Client[Client Applications] --> ApiGateway[API Gateway]
ApiGateway --> OrderService[Order Service]
ApiGateway --> InventoryService[Inventory Service]
ApiGateway --> PaymentService[Payment Service]
ApiGateway --> ShippingService[Shipping Service]
ApiGateway --> NotificationService[Notification Service]
OrderService -- Events --> Kafka[Kafka]
InventoryService -- Events --> Kafka
PaymentService -- Events --> Kafka
ShippingService -- Events --> Kafka
NotificationService -- Events --> Kafka
Kafka -- Events --> OrderService
Kafka -- Events --> InventoryService
Kafka -- Events --> PaymentService
Kafka -- Events --> ShippingService
Kafka -- Events --> NotificationService
OrderService --> OrderDB[(PostgreSQL)]
InventoryService --> InventoryDB[(MongoDB)]
PaymentService --> PaymentDB[(PostgreSQL)]
ShippingService --> ShippingDB[(PostgreSQL)]
NotificationService --> NotificationDB[(MongoDB)]
NotificationService --> Redis[(Redis)]
ServiceRegistry[Service Registry] --> OrderService
ServiceRegistry --> InventoryService
ServiceRegistry --> PaymentService
ServiceRegistry --> ShippingService
ServiceRegistry --> NotificationService
Order Service:
Inventory Service:
Payment Service:
Shipping Service:
Notification Service:
Infrastructure Services:
This project implements the Saga pattern using a choreography-based approach:
Order Creation:
Inventory Reservation:
Payment Processing:
Shipping Creation:
Order Completion:
If any step fails, the system executes compensation transactions to maintain consistency:
ecommerce-microservices/
├── pom.xml # Parent POM
├── common-library/ # Shared code between services
├── service-registry/ # Eureka Service Discovery
├── api-gateway/ # Spring Cloud Gateway
├── order-service/ # Order management
├── inventory-service/ # Inventory management
├── payment-service/ # Payment processing
├── notification-service/ # Notification handling
├── shipping-service/ # Shipping management
└── docker-compose.yml # Docker composition for all services
git clone https://github.com/hacisimsek/ecommerce-microservices.git
cd ecommerce-microservices
mvn clean package -DskipTests
docker-compose up -d
# Access Eureka dashboard
http://localhost:8761
# Check API Gateway
http://localhost:8080/actuator/health
POST /api/orders
Content-Type: application/json
{
"customerId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"items": [
{
"productId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"productName": "Smartphone",
"quantity": 1,
"price": 799.99
}
]
}
GET /api/orders/{orderId}
GET /api/orders/customer/{customerId}
POST /api/inventory
Content-Type: application/json
{
"name": "Smartphone",
"description": "Latest smartphone model",
"quantity": 100
}
GET /api/inventory/check?productId={productId}&quantity={quantity}
GET /api/payments/order/{orderId}
GET /api/shipping/order/{orderId}
GET /api/notifications/customer/{customerId}
mvn test
mvn verify -P integration-test
Use Postman or curl to test the full order processing flow:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)© 2025 hacisimsek. All rights reserved.