Checkout and Order Coordination
Checkout creation and asynchronous basket and email coordination.
Runtime Scenario
Checkout converts a mutable basket into an authoritative purchase-time order, then delegates basket cleanup and email delivery to asynchronous coordination. The synchronous portion establishes the order before the customer receives the order identifier.
Purpose & Trigger
The flow creates an order with immutable item and price snapshots while keeping external cleanup outside the ordering transaction. It starts when an authenticated customer submits a checkout request.
Visual References
Checkout and Order Coordination
Loading graph...
Step-by-Step Walkthrough
- Commerce sends the checkout request through API Gateway, including the caller’s idempotency identity.
- Ordering API synchronously reads current basket quantities from Basket API and authoritative book and price data from Catalog API.
- Ordering API records the order and purchase-time snapshots, commits the state, and returns the order identifier. This synchronous response does not mean basket cleanup or email delivery has completed.
- Ordering API publishes a checkout fact asynchronously. Finance starts a workflow correlated by the order identifier.
- Finance publishes basket cleanup and email commands independently. Basket API and Notification consume the commands in separate paths.
- Basket API deletes the basket and reports success or failure asynchronously.
- Notification applies idempotency and submits the email independently of basket cleanup.
- Finance records the basket outcome and reconciles the workflow. A timeout or repeated failure triggers bounded compensation rather than a distributed transaction.
Error Handling & Edge Cases
- Repeated checkout requests use the same idempotency identity and must not create a second order.
- Basket or catalog read failures leave checkout uncommitted and allow a caller retry.
- Kafka retries may duplicate downstream commands; basket deletion and email delivery must remain repeatable safely.
- A missing basket outcome is bounded by a workflow timeout and retry limit.
- Timeout compensation may notify the customer, but it does not by itself change the authoritative order status.
Quality & Consistency Notes
- Checkout latency depends on basket and catalog reads, plus the synchronous order commit; slow email delivery is outside this critical path.
- The order preserves purchase-time prices and remains independent of later catalog changes.
- Basket cleanup, email delivery, and workflow completion are eventually consistent with the committed order.