Skip to content
System design
Production experienceIntermediate20 Jun 2026

One event, four channels: notification delivery for a commerce app

How order notifications reach a customer through push, email and SMS without channel logic leaking into every feature.

NotificationsFCMAPNsNovu

Order status is the reason a cross border shopping app gets opened. The parcel is somewhere between a foreign warehouse and a doorstep, and the customer wants to know where.

This is the delivery architecture I built for that on Ali2BD.

The shape of the problem

An order produces a stream of events over days or weeks: placed, paid, purchased abroad, received at warehouse, shipped, cleared at customs, out for delivery, delivered. Each may need to reach the customer, and which channel is right depends on the event and on what that customer actually has enabled.

The naive version puts that decision in the feature that raises the event. Do that four times and channel logic is spread across the codebase, with four places to change when a provider does.

The architecture

The backend emits one event with a payload. It does not know or care which channels exist. Novu owns the workflow: which channels fire for which event type, in what order, with what fallback, and what the message looks like on each.

The value is not that Novu is clever. It is that channel policy lives in one place and changing it does not mean a release.

Device tokens belong to sessions, not devices

This is the detail that gets missed, and it matters more in this market than in most.

Phones are shared. If a device token is registered against the device alone, then after a logout and a new login, the previous customer's order updates arrive on a phone that is now someone else's.

So a token is registered on login and deregistered on logout, bound to the session that created it. A device can hold tokens for several users over time. Only the active session receives.

code
POST /notifications/device-token   { token, platform }   on login
DELETE /notifications/device-token { token }             on logout

Tokens also expire on their own. FCM and APNs both tell you when a token is invalid, and that response is not a transient error to retry. It means delete the row. Retrying an invalid token forever is how a notification service quietly turns into a queue of garbage.

What goes in the payload

As little as possible.

The push carries a short title, a short body and an order reference. It does not carry order contents, amounts or addresses. Two reasons: the payload passes through a third party's infrastructure, and a notification that renders on a lock screen should not disclose what someone bought.

The app fetches the real state when it opens. That is one extra request in exchange for never having customer data sitting in a push provider's logs.

Failure handling

  • Push is best effort and must never block the write that triggered it. The order status update commits, then the event is emitted. A notification failure is not an order failure.
  • Provider errors that are transient get retried with backoff. Errors that mean the token or address is dead do not get retried at all, they get cleaned up.
  • Nothing in the notification path throws into the caller. The helper swallows and logs, because the alternative is a failed push rolling back a legitimate state change.

Trade-offs

A third party in the delivery path. An outage at Novu is an outage in notifications. The alternative is owning retry, backoff, per channel failure semantics, template management and credentials for four providers, and that is a system, not a module.

Best effort delivery. A notification can be lost. That is acceptable precisely because the app shows the true state on open. It would not be acceptable if the notification were the only way to learn something.

What I would add next

Per user channel preferences evaluated at send time rather than at enqueue time. A notification scheduled for tomorrow should respect the preference the customer has tomorrow, not the one they had when the event fired.