In the previous blog we looked at notifications through a diagram. This post goes through every box in it and what it does in a real implementation. It's the reference design: the full picture of a centralized, event-driven notification system that delivers to iOS, Android and email, with authentication, rate limiting, personalization, retries and analytics.
The core system emits events. A dedicated notification service decides if, when, how and through which channel a notification gets delivered.
The numbers in the headings match the figure (Fig 1.1, 1.2 and so on). The last section compares the design with the service the other posts in this series describe, because a few pieces of the diagram aren't built there yet.
1. Event producers (Service N), Fig 1.1
Service N stands for any upstream service in the ecosystem. Some examples:
- Order service
- Payment service
- Cart service
- User service
- Marketing automation service
These services never send notifications themselves. They emit a structured event instead:
{
eventType: "ORDER_PLACED",
userId: "123",
payload: {...}
}
That keeps business logic and notification delivery apart.
2. Notification servers (API layer), Fig 1.2
The notification servers are the entry point. Their job is to keep the system safe before any notification logic runs:
- Authentication: check that the request or event comes from a trusted service, so nobody can trigger notifications without permission.
- Rate limiting: protect downstream systems from overload, enforce per-user or per-service limits and stop spam.
3. Cache and database, Fig 1.10 and 1.8
The notification server pulls the data it needs from a cache first. The cache holds user preferences, device tokens and counts of recently sent notifications, so lookups stay fast.
The database stores user notification settings, device information (iOS token, Android token, email address) and channel preferences (push, email, SMS). The cache is there for latency. The database is the source of truth.
4. Notification decision logic
With the request validated and the data loaded, the system decides:
- Is the user eligible for a notification?
- Which channel should be used?
- Should it be sent now or deferred?
- Is it suppressed by a rate limit?
Only eligible notifications go any further.
5. Notification templates, Fig 1.6
Templates define the shape of a message, not how it's delivered. They hold the static layout, placeholders for dynamic data and any channel-specific formatting (a push body is not an email body). For example:
Title: "Order Update"
Body: "Hi {{name}}, your order {{orderId}} has been shipped."
Templates keep messages consistent, make localization possible and keep content out of the logic.
6. Workers (asynchronous processing), Fig 1.3
Workers do the actual delivery, not the API servers. That gives you non-blocking request handling, retry support and horizontal scaling. A worker pulls prepared notification jobs, calls the external provider (APNS, FCM, SMTP), retries on transient failures and records success or failure. A failure here stays isolated from the upstream services.
7. Platform gateways, Fig 1.4
The diagram shows APNS explicitly, for iOS. There are equivalents for Android (FCM), email (SMTP) and SMS (provider APIs). The notification system never talks to a device directly. It always goes through an official platform gateway.
8. Device delivery, Fig 1.5
For iOS, APNS delivers the notification to the device using its device token. At that point the notification is shown, and the user may open or click it. The figure only shows APNS, but Android uses FCM and email uses SMTP in the same position.
9. Notification logs, Fig 1.7
Every notification attempt is logged: notification ID, user ID, channel, timestamp and delivery status. Those logs matter for auditing, debugging, compliance and customer support. They also let the product team see whether notifications actually reached devices.
10. Analytics service, Fig 1.9
Analytics runs in parallel with delivery. It tracks pending notifications, successful sends, delivery failures and clicks from the device. Click tracking closes the loop:
Notification sent → User action → Analytics
That data feeds campaign performance, personalization and later targeting decisions. Mostly it tells the product team how people engage with notifications, which helps them decide what to try next.
11. Retry and failure handling, Fig 1.12
When a delivery attempt fails, the worker retries according to a retry policy, the error goes to analytics and the failure doesn't block the rest of the system. Retries raise the chance that a notification reaches the user at all.
How this maps to the real service
Parts 3 to 8 of this series describe a service built from this design. A few pieces differ, and it's better to say so plainly.
- Producers and intake (1, 2): Other services publish events to Kafka, one topic and one listener per event type (Part 3). There's no rate limiter at intake. Load is contained by capped concurrency and circuit breakers (Part 7). A separate REST API serves the timeline, preferences and template management.
- Cache, database and decision logic (3, 4): The in-app timeline and its unread counters live in DynamoDB (Part 4). Delivery details such as device tokens and email addresses travel inside the event, so nothing is looked up at send time. Today the event itself decides which channels are used. User preferences aren't checked before sending (Part 3).
- Templates (5): Email templates live in Brevo, and the service only maps an email type to a template ID, so a redesigned template goes live without a deployment (Part 6).
- Workers (6): There's no separate worker fleet. The Kafka listeners are the workers, with capped async executors for work off the main path (Parts 3 and 7).
- Gateways and delivery (7, 8): Push goes through Firebase Cloud Messaging for both iOS and Android (Part 5). Email goes through the Brevo API and SMS through Twilio (Part 6).
- Logs (9): Each stored notification carries a delivery status of pending, sent, failed or skipped, plus a delivery metric per channel (Part 8).
- Analytics (10): Not in this service. There's no click or open tracking, and measuring engagement would need the client apps to report events (Part 8).
- Retries (11): The design calls for them, but the service doesn't retry failed sends automatically yet. External channels are at-least-once, so adding retries needs the same care about duplicates (Parts 4 and 7).
So the diagram is the destination, and the other posts show how far the real service has got.

Top comments (0)