Building Block View Level 3
Level-3 view of Finance workflow coordination.
Architecture
Finance merits a deeper view because its post-checkout workflow must reconcile asynchronous basket deletion, authoritative order completion or cancellation, timeout retries, and compensating actions. Correctness depends on legal terminal-state transitions and safe recovery when a side effect succeeds but its confirmation is delayed.
Structure
The first view captures stable domain and workflow relationships; the second locates those responsibilities within Finance and its external partners.
Loading graph...
Core Elements
| Class / Interface | Role & Invariants | Extension / Modification Point |
|---|---|---|
Order | Workflow-local aggregate for basket, customer contact, total, retry count, and coordination status. Identifiers must be non-empty, the retry limit positive, and terminal states cannot transition again. Ordering remains authoritative for official order status. | Route lifecycle changes through OrderLifecycleDecider; keep Finance coordination status distinct from Ordering’s business status. |
OrderLifecycleDecider / OrderStatus | Enforces legal state transitions, prevents duplicate basket-deletion completion, and bounds retry-driven cancellation. | Add lifecycle actions and terminal-state rules here so every transition follows the same invariant checks. |
OrderOrchestrator | Starts placement, waits for external outcomes, delegates each outcome to a workflow step, and ends on a terminal result or exhausted retry limit. | Change sequencing and timeout policy here; keep orchestration replay-safe and domain rules in the aggregate and decider. |
IOrderWorkflowStep / OrderStepContext | Provides the strategy boundary for handling a winning event or timer with access to the current workflow state and recovery actions. The timeout step is the fallback and must not shadow specific event handlers. | Add a focused step for a new outcome and preserve dispatch precedence, especially the fallback timeout behavior. |
OrderSagaCompensations | Registers recovery actions before forward side effects and executes them in reverse order when coordination fails. A failed compensation is logged without preventing remaining actions. | Pair each new reversible side effect with its recovery action; preserve completion semantics for normal, exhausted-retry, and failure paths. |
Money / CustomerContact | Money rejects negative totals. Notifications are eligible only when both a customer name and email are available. | Keep amount and contact eligibility rules in these value objects rather than scattering them through workflow steps. |
Related Resources
- Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs — Finance ownership and integration boundary.
- User checked outEventv1.0.0User checked outReports that an Order was placed and its checkout details are ready for Finance coordination. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, Basket deletion completedEventv1.0.0Basket deletion completedIndicates that Basket successfully deleted the submitted basket during checkout cleanup. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, Basket deletion failedEventv1.0.0Basket deletion failedIndicates that Basket could not delete the submitted basket during checkout cleanup. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, Order completedEventv1.0.0Order completedReports that an Order transitioned from New to Completed. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, and Order cancelledEventv1.0.0Order cancelledReports that an Order transitioned from New to Cancelled. Ownercommerce-fulfillment-teamSchemaDiagramOpen docs — workflow inputs.
- ADR-005: Keep Finance workflow outcomes separate from Order statusDecision Recordv1.0.0ADR-005: Keep Finance workflow outcomes separate from Order statusFinance reports cleanup outcomes and tracks its own saga lifecycle while Ordering remains authoritative for Order comple...Ownercommerce-fulfillment-teamOpen docs — separates Finance coordination outcomes from authoritative Ordering status.
- Checkout and Order CoordinationCustom DocCheckout and Order CoordinationCheckout creation and asynchronous basket and email coordination.Ownercommerce-fulfillment-teamOpen doc — checkout coordination sequence.