Accept a request, then send it on each channel
The API calls no provider on the caller’s path: it records the key, queues the request and replies. Each channel’s workers call their providers through an adapter, so a channel can use more than one provider, and a slow email provider backs up only the email queue.
- The orders service calls
POST /v1/with a key, the category, the user and the values.notifications - The API records the key, writes to the accepted queue and replies
202with the notification id. - The router finds the user’s devices, addresses and settings, and renders each channel.
- It puts one job on each channel’s queue; workers send through that channel’s providers and write the status.
Diagram as text
Components: Orders service (Service); Notification API (API gateway); Accepted queue (Queue); Router (Service); Settings and devices (Cache); Push queue (Queue); Email queue (Queue); SMS queue (Queue); In-app queue (Queue); Push workers (Worker); Email workers (Worker); SMS workers (Worker); In-app workers (Worker); APNs and FCM (External API); Email providers (External API); SMS providers (External API); Inbox store (NoSQL DB). Connections: Orders service → Notification API (POST); Notification API → Accepted queue (write, then 202); Accepted queue → Router; Router → Settings and devices (look up); Router → Push queue; Router → Email queue; Router → SMS queue (a job per channel); Router → In-app queue; Push queue → Push workers; Email queue → Email workers; SMS queue → SMS workers; In-app queue → In-app workers; Push workers → APNs and FCM; Email workers → Email providers; SMS workers → SMS providers; In-app workers → Inbox store.
Read:Learn: High-level architectureLearn: Producer-consumer / work queue
Check yourself
The email provider starts taking two seconds per message. What happens to a login code sent by SMS at that moment?
Show answerHide answer
Nothing: it goes on the SMS queue and SMS workers send it. Only the email queue backs up.