---
id: finance-system
name: Finance System
version: 1.0.0
summary: |
  Internal BookWorm workflow system that coordinates post-checkout basket
  cleanup and order notifications through Durable Task Scheduler; it does not
  process payments.
scope: internal
owners:
  - commerce-fulfillment-team
services:
  - id: order-orchestration
    version: 1.0.0
flows:
  - id: user-checkout
    version: 1.0.0
relationships:
  - id: order-system
    version: 1.0.0
    label: exchanges checkout and Order lifecycle messages with
  - id: cart-system
    version: 1.0.0
    label: requests basket cleanup and receives deletion outcomes from
  - id: notification-system
    version: 1.0.0
    label: publishes order email commands to
badges:
  - content: Internal
    backgroundColor: gray
    textColor: gray
    icon: LockClosedIcon
---

## System Purpose & Boundary

The Finance System coordinates post-checkout basket cleanup, bounded retry timers, and order lifecycle notification requests within the [[domain|ordering]] domain. It reacts to checkout and order-status events emitted by [[system|order-system]] and orchestrates follow-up actions across [[system|cart-system]] and [[system|notification-system]]. Authorizing or settling payments, exposing customer-facing APIs, and owning authoritative Order status are explicitly out of scope.

:::warning
Despite its name, the Finance System does **not** process payments or own Order truth. [[system|order-system]] remains the sole authority for Order aggregates and business status (`New`, `Completed`, `Cancelled`). Finance orchestration timeouts or cancellations never automatically cancel an Order in Ordering.
:::

## Contained Capabilities

| Service / Agent                  | Role in System                                                                                             | Primary Data Store           | Interaction Style (Sync / Async)    |
| :------------------------------- | :--------------------------------------------------------------------------------------------------------- | :--------------------------- | :---------------------------------- |
| [[service\|order-orchestration]] | Runs one durable saga instance per Order to coordinate basket cleanup retries and lifecycle email commands | Azure Durable Task Scheduler | Async (Kafka triggers & publishers) |

## External Interactions & Trust Boundaries

- **Ordering integration:** Consumes [[event|UserCheckedOutIntegrationEvent]], [[event|OrderStatusChangedToCompleteIntegrationEvent]], and [[event|OrderStatusChangedToCancelIntegrationEvent]] from [[system|order-system]], and reports basket-cleanup outcomes via [[command|DeleteBasketCompleteCommand]] and [[command|DeleteBasketFailedCommand]].
- **Shopping integration:** Issues [[command|PlaceOrderCommand]] to [[system|cart-system]] to clear the submitted basket and consumes [[event|BasketDeletedCompleteIntegrationEvent]] or [[event|BasketDeletedFailedIntegrationEvent]].
- **Notification integration:** Dispatches [[command|PlaceOrderCommand]], [[command|CompleteOrderCommand]], and [[command|CancelOrderCommand]] to [[system|notification-system]] for customer email rendering and SMTP delivery.

<Accordion title="Saga Lifecycle & Retry Trade-offs">
	- **Bounded retries:** Durable timers retry basket cleanup up to 3 attempts on a 30-minute
	interval before marking the orchestration instance cancelled. - **Shared placement command:**
	Because both [[system|cart-system]] and [[system|notification-system]] consume
	[[command|PlaceOrderCommand]], timeout retries can trigger duplicate placement email attempts.
</Accordion>

## System Visualizations

### System Context

<ContextDiagram />

### Component Topology

<NodeGraph />

### Architecture Decisions

<ADRTable />

## Related Documentation

- [[flow|user-checkout]] — End-to-end checkout and post-checkout coordination flow.
- [[flow|order-lifecycle]] — Order status transitions and saga separation.
- [[doc|domains/bookworm/subdomains/ordering/guides/02-understand-order-and-finance-status]] — Lifecycle separation between Order status and Finance orchestration.
