Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

ADR-001: Consume order notification commands through Kafka

Notification consumes Finance order commands through Wolverine and Kafka, keeping email processing outside the business operation's synchronous path.

November 1, 2026AcceptedIntegration

1. Context & Problem

Finance coordinates critical order milestones—placement, cancellation, and completion. Sending customer emails requires formatting content and contacting external mail providers, both of which can be slow or temporarily fail. If Finance waited for email delivery to finish before confirming an order action, mail slowdowns or outages could delay or break core order workflows.

At the same time, the Notification capability needs recipient and order details to prepare those emails without taking ownership of Finance’s business rules or order state. BookWorm needed an asynchronous intake boundary that keeps order workflows fast and authoritative while still giving Notification everything required to send order communications.

2. Business Value

  • Faster, more reliable order checkout and updates: Order placement, cancellation, and completion are never blocked by email rendering or external mail-provider availability.
  • Clear domain ownership: Finance remains the single source of truth for order status, while Notification focuses exclusively on formatting and delivering messages.
  • Graceful handling of missing addresses: Requests without a recipient email address are safely skipped rather than failing the order or creating noisy errors.
  • Decoupled evolution: Finance does not depend on Notification’s internal delivery mechanisms or expose synchronous email endpoints.

3. How It Works

  1. Asynchronous command publishing: When an order is placed, cancelled, or completed, Finance emits an order notification command onto the messaging platform containing the recipient and order details.
  2. Intake and formatting: The Notification capability picks up each command independently from Finance’s workflow, maps the order status to the appropriate message, and checks the recipient address.
    • If the recipient address is blank, Notification intentionally skips sending an email.
    • If a recipient is present, Notification formats the order email and hands it off to its internal durable outbox sender.
  3. Independent failure boundaries:
    • Failures during formatting or initial saving are handled by the messaging retry infrastructure.
    • Failures when handing off to the external mail provider leave work in Notification’s own maintenance path for later follow-up.
  4. No reverse notification to Finance: Notification does not send a delivery-result message back to Finance. Order completion never waits on or changes based on email submission.

4. Trade-offs & Lessons Learned

  • Independent operational dependencies: Because intake is asynchronous, health of the message broker, Notification’s database, and the Notification consumer directly affects email timeliness—even when Finance is healthy.
  • No exactly-once or cross-topic ordering guarantee: Partitioning commands by order does not guarantee ordering across separate command types, and repeated commands (such as Finance retrying placement during basket cleanup) or ambiguous consumer retries can produce duplicate email records and deliveries.
  • Blank-recipient skipping is narrow: Skipping blank addresses prevents unnecessary failures, but it is not a full email validation guarantee or proof of delivery.
  • Monitoring requires inspecting Notification directly: Operators and business stakeholders cannot infer email success from Finance publishing a command or from basic service health checks; they must check Notification’s processing and outbox state.
  • Alternatives rejected:
    • Synchronous sending from Finance: Rejected because it would tie order workflows to mail-provider latency and force Finance to own email templates and delivery state.
    • Exposing a business email-submission web endpoint: Rejected because it would couple callers to request-response lifecycles instead of the current message-consumer contract.
    • Publishing delivery outcomes as order facts: Rejected because whether an email was submitted does not change the business reality of an order.

5. Technical Reference

  • Recording Note: Status accepted (2026-11-01). The date reflects when this current architecture was recorded, not when the implementation was first introduced.
  • Service & Contract: Notification APIServicev1.0.0Notification APIInternal background worker that consumes order commands from Kafka, renders MJML email templates, and submits mail over ...SubscribesPlaceOrderCommand, CancelOrderCommand +1APIsAsyncAPIOwnerplatform-engineering-teamDiagramRepositoryOpen docs exposes only service-default HTTP endpoints (no business email-submission or delivery-status HTTP endpoints); its business contract is the AsyncAPI receive operations.
  • Consumed Commands: Place orderCommandv1.0.0Place orderShared Finance order-placement command consumed by Notification to render and submit a new-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs, Send order cancelled notificationCommandv1.0.0Send order cancelled notificationShared Finance cancellation command consumed by Notification to render and submit a canceled-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs, and Send order completed notificationCommandv1.0.0Send order completed notificationShared Finance completion command consumed by Notification to render and submit a completed-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs consumed via Wolverine on separate environment-scoped Kafka topics, partitioned by OrderId.
  • Rendering & Outbox Hand-off: Maps order status, skips blank recipient addresses, renders the Orders/OrderEmail template, and invokes the application email outbox sender.
  • Infrastructure Persistence: Wolverine uses PostgreSQL envelope persistence and EF Core transaction integration when the database connection is configured. These infrastructure envelopes are separate from the application email outbox and do not provide command-level deduplication.
  • Failure Propagation: Rendering, initial persistence, and sender failures propagate to messaging failure handling; SMTP failures leave work for Notification’s scheduled maintenance path. No application-level result event is published.