This article outlines architectural decisions for building a robust email notification system in a SaaS application, particularly for healthtech. It emphasizes delivery reliability, provider neutrality, and a clear failure boundary. Key aspects include using a notification adapter, an outbox pattern, and a delivery-event poller to ensure reliable message delivery and state tracking independent of the email service provider.
Read original on Dev.to #architectureBuilding a reliable email notification system, especially in critical domains like healthtech, requires careful architectural planning beyond simply calling an email API. The core challenge is ensuring that messages are not just sent, but reliably delivered and their delivery status tracked, even if the underlying provider changes or fails. This article presents a robust architecture for achieving this goal.
The recommended architecture focuses on provider neutrality and a clear separation of concerns. It includes a provider-neutral notification adapter to abstract the email service provider (ESP) specifics, an outbox pattern for durable storage of notifications before sending, and a delivery-event poller to track the status of sent emails. This ensures that the application's internal state reflects actual delivery outcomes rather than just send attempts.
Email State Machine
A simplified state machine for email delivery helps manage complexity: `queued` → `submitted` → `delivered`, `bounced`, or `suppressed`. This minimal set of states controls data volume and reduces cardinality, as raw provider payloads can be verbose.