Responsibility: Manage product catalog.
-
ProductCreated
- Payload:
{ "productId": "123", "name": "Product Name", "price": 100.0, "quantity": 50 }
- Subscribers:
- Inventory Service: To create inventory for the new product.
- Payload:
-
ProductUpdated
- Payload:
{ "productId": "123", "price": 120.0, "quantity": 30 }
- Subscribers:
- Cart Service: To update product prices in the cart.
- Inventory Service: To sync inventory details.
- Payload:
-
ProductDeleted
- Payload:
{ "productId": "123" }
- Subscribers:
- Cart Service: To remove the product from any active carts.
- Inventory Service: To remove inventory for the product.
- Payload:
Responsibility: Manage customer orders.
-
OrderCreated
- Payload:
{ "orderId": "456", "userId": "789", "items": [ { "productId": "123", "quantity": 2, "price": 100.0 }, { "productId": "124", "quantity": 1, "price": 200.0 } ], "totalAmount": 400.0, "status": "PENDING" }
- Subscribers:
- Inventory Service: To reserve stock for the ordered items.
- Payment Service: To initiate payment for the order.
- Payload:
-
OrderCancelled
- Payload:
{ "orderId": "456", "reason": "Customer request" }
- Subscribers:
- Inventory Service: To release reserved stock.
- Payment Service: To process payment refunds if applicable.
- Payload:
-
OrderCompleted
- Payload:
{ "orderId": "456", "paymentId": "987", "status": "COMPLETED" }
- Subscribers:
- Inventory Service: To deduct stock permanently for completed orders.
- Payload:
Responsibility: Manage user carts.
-
CartItemAdded
- Payload:
{ "userId": "789", "productId": "123", "quantity": 2 }
- Subscribers:
- Inventory Service: Optionally reserve stock for items in the cart (soft reservation).
- Payload:
-
CartCheckedOut
- Payload:
{ "userId": "789", "cartId": "567", "items": [ { "productId": "123", "quantity": 2 }, { "productId": "124", "quantity": 1 } ] }
- Subscribers:
- Order Service: To create an order from the cart contents.
- Payload:
Responsibility: Handle payments for orders.
-
PaymentInitiated
- Payload:
{ "paymentId": "987", "orderId": "456", "userId": "789", "amount": 400.0, "status": "PENDING" }
- Subscribers:
- Order Service: To update order status to "Awaiting Payment".
- Payload:
-
PaymentCompleted
- Payload:
{ "paymentId": "987", "orderId": "456", "status": "COMPLETED" }
- Subscribers:
- Order Service: To mark the order as "Confirmed".
- Inventory Service: To confirm stock deduction for the order.
- Payload:
-
PaymentFailed
- Payload:
{ "paymentId": "987", "orderId": "456", "reason": "Insufficient funds" }
- Subscribers:
- Order Service: To update the order status to "Payment Failed".
- Inventory Service: To release reserved stock.
- Payload:
Responsibility: Manage product stock.
-
StockReserved
- Payload:
{ "orderId": "456", "items": [ { "productId": "123", "quantity": 2 }, { "productId": "124", "quantity": 1 } ] }
- Subscribers:
- Order Service: To confirm that stock is reserved for the order.
- Payload:
-
StockReleased
- Payload:
{ "orderId": "456", "items": [ { "productId": "123", "quantity": 2 } ] }
- Subscribers:
- Order Service: To handle order cancellations or payment failures.
- Payload:
-
StockDeducted
- Payload:
{ "orderId": "456", "items": [ { "productId": "123", "quantity": 2 }, { "productId": "124", "quantity": 1 } ] }
- Subscribers:
- Order Service: To finalize the order status as "Completed".
- Payload:
-
StockUpdated
- Payload:
{ "productId": "123", "quantity": 100 }
- Subscribers:
- Catalog Service: To reflect updated stock levels in product listings.
- Payload:
- Cart Service:
- Publishes
CartCheckedOut
.
- Publishes
- Order Service:
- Receives
CartCheckedOut
and publishesOrderCreated
.
- Receives
- Inventory Service:
- Receives
OrderCreated
and publishesStockReserved
.
- Receives
- Payment Service:
- Receives
OrderCreated
and processes payment. - Publishes
PaymentCompleted
orPaymentFailed
.
- Receives
- Order Service:
- Receives
PaymentCompleted
and publishesOrderCompleted
.
- Receives
graph TD
%% Catalog Service
CatalogService[Catalog Service]
CartService[Cart Service]
OrderService[Order Service]
PaymentService[Payment Service]
InventoryService[Inventory Service]
%% Catalog Service Events
CatalogService -- ProductCreated --> InventoryService
CatalogService -- ProductUpdated --> InventoryService & CartService
CatalogService -- ProductDeleted --> InventoryService & CartService
%% Cart Service Events
CartService -- CartItemAdded --> InventoryService
CartService -- CartCheckedOut --> OrderService
%% Order Service Events
OrderService -- OrderCreated --> InventoryService & PaymentService
OrderService -- OrderCancelled --> InventoryService & PaymentService
OrderService -- OrderCompleted --> InventoryService
%% Payment Service Events
PaymentService -- PaymentInitiated --> OrderService
PaymentService -- PaymentCompleted --> OrderService & InventoryService
PaymentService -- PaymentFailed --> OrderService & InventoryService
%% Inventory Service Events
InventoryService -- StockReserved --> OrderService
InventoryService -- StockReleased --> OrderService
InventoryService -- StockDeducted --> OrderService
InventoryService -- StockUpdated --> CatalogService