Sequence Diagramsequenceeventsorders
Event-Driven Order Processing Sequence
Use this Mermaid sequence diagram to document asynchronous order processing with OrderCreated events, message queues, inventory reservation, payment handling, shipping creation, and dead-letter queue recovery.
Use Cases
Document event-driven order fulfillment across inventory, payment, shipping, and DLQ recovery
Explain why the order API publishes events instead of calling downstream services directly
Review stock reservation, payment failure, out-of-stock, and shipment creation paths
Align platform, commerce, and operations teams on asynchronous recovery behavior
How This Workflow Works
| Step | Purpose |
|---|---|
| Publish order event | The order API emits OrderCreated to decouple order entry from inventory, payment, and shipping services. |
| Reserve inventory | Inventory consumes the order event, reserves stock when available, and publishes the next event. |
| Charge payment | Payment consumes the reservation event and either advances fulfillment or triggers stock release. |
| Create shipment | Shipping consumes the completed payment event and emits ShipmentCreated after fulfillment work begins. |
| Handle failures | Out-of-stock or unprocessable events are routed to the DLQ for retry, inspection, or manual recovery. |
How To Customize
Rename Order API, Message Queue, and domain services to match your production service names
Add retry, timeout, idempotency, or poison-message branches before sending events to the DLQ
Replace OrderCreated, StockReserved, and PaymentCompleted with your actual event names
Add observability messages for tracing, metrics, or alerting at each event boundary
Split the payment and shipping participants when multiple providers or fulfillment partners are involved
Edit This Template Visually
Open this template in the editor to work from the rendered diagram and the Mermaid source together. Click a node in supported flowchart and sequence diagrams to locate the matching code, select source lines to find the related shape, or ask AI to rename, expand, restyle, or rewrite the selected part of the workflow.
Mermaid Source
sequenceDiagram
autonumber
box rgba(232, 242, 255, 0.85) Order Entry
participant OrderAPI as Order API
end
box rgba(231, 250, 250, 0.85) Event Backbone
participant Queue as Message Queue
end
box rgba(244, 237, 255, 0.85) Domain Services
participant Inventory as Inventory Service
participant Payment as Payment Service
participant Shipping as Shipping Service
end
box rgba(255, 232, 232, 0.85) Failure Channel
participant DLQ as Dead Letter Queue
end
rect rgba(232, 242, 255, 0.55)
OrderAPI->>Queue: Publish OrderCreated event
end
Note over OrderAPI,Queue: Order API publishes an event instead of calling downstream services directly
rect rgba(233, 249, 239, 0.55)
Queue->>Inventory: Consume OrderCreated
Inventory->>Inventory: Reserve stock
alt Stock available
Inventory-->>Queue: Publish StockReserved
Queue->>Payment: Consume StockReserved
Payment->>Payment: Charge customer
alt Payment success
Payment-->>Queue: Publish PaymentCompleted
Queue->>Shipping: Consume PaymentCompleted
Shipping->>Shipping: Create shipment
Shipping-->>Queue: Publish ShipmentCreated
else Payment failed
Payment-->>Queue: Publish PaymentFailed
Queue->>Inventory: Consume PaymentFailed
Inventory->>Inventory: Release reserved stock
Inventory-->>Queue: Publish StockReleased
end
else Out of stock
Inventory-->>DLQ: Publish OutOfStock
end
end
Note over Queue,DLQ: Failed or unprocessable events can be sent to the DLQ for retry, inspection, or manual recovery