Design a Notification Service (Low-Level Design)
Low-level design of a multi-channel notification service: Channels as Strategy built by a Factory, reusable Templates, per-user Preferences, plus Decorator retries and Observer delivery tracking.
🟠Low-Level Design · Case Study · Senior
"Design a notification service" as an LLD question is about the class design of sending one message across many channels — email, SMS, push, in-app — cleanly and extensibly. (The HLD version worries about queues and scale; here we care about the object model.) It's a beautiful multi-pattern problem. Let's design it.
Step 1 — Requirements
- Functional: send a notification to a user over email / SMS / push / in-app; respect per-user channel preferences; render from reusable templates; support new channels without touching callers.
- Non-functional: extensible (add a channel = add a class), reliable (retries), observable (log/track delivery), and decoupled from senders.
Step 2 — The classes
- Notification — recipient, template id, data payload, priority.
- Channel (interface, Strategy) → EmailChannel, SmsChannel, PushChannel, InAppChannel — each knows how to
send(). - ChannelFactory (Factory) — maps a channel type to its implementation.
- NotificationTemplate — a named template with placeholders, filled per notification.
- UserPreferences — which channels a user has opted into.
- NotificationService — the orchestrator that ties it together.
Step 3 — Channels = Strategy, creation = Factory
🟠Each channel is an interchangeable algorithm behind one interface — Strategy — and a Factory hands you the right one so the service never hardcodes concrete channels:
interface Channel { void send(Notification n); } // Strategy
class NotificationService {
void notify(Notification n) {
User u = n.getRecipient();
String body = template.render(n.getTemplateId(), n.getData()); // Template
for (ChannelType t : u.getPreferences().enabledChannels()) { // respect prefs
Channel ch = ChannelFactory.get(t); // Factory
ch.send(n.withBody(body));
}
}
}
Adding a WhatsApp channel = one new class + one factory entry. Callers just say "notify this user" — the service fans out to whatever channels they've enabled.
Step 4 — Preferences, templates & priority
🟠Three details that show product thinking: UserPreferences lets a user mute SMS but keep email; Templates keep copy consistent and localizable (placeholders filled from the payload); a priority field lets urgent notifications (OTP) jump ahead of digests. A user who's opted out of a channel simply isn't in the fan-out loop.
Step 5 — The senior nuances
🔴 Where to take it further:
- Retries & reliability = Decorator: wrap any Channel in a
RetryingChannelthat re-attempts on failure (with backoff) — no change to the channel itself. - Delivery tracking = Observer: emit sent/failed events that loggers, metrics, and audit stores subscribe to.
- Async + queue: for real volume,
notify()enqueues and workers send — the bridge to the HLD design (rate limits, dedupe, provider fallback). - Rate limiting / dedupe: don't spam a user with the same alert twice — cap per user per window.
The interview-ready walkthrough
"A NotificationService takes a Notification and, for each channel in the user's Preferences, gets a Channel from a Factory and sends. Channels are a Strategy (email/SMS/push/in-app) so adding one is a new class. Content comes from reusable Templates. For reliability I'd wrap channels in a Decorator that retries with backoff, and emit delivery events via Observer for logging/metrics. At scale notify() just enqueues and workers do the sending, with dedupe and rate limits." Strategy + Factory + Decorator + Observer, plus the product concerns — that's a senior answer."
What to read next
- Design a Notification System (HLD) — the same problem at scale
- Strategy · Factory Method · Decorator · Observer — the patterns here
- Design Chess — next up, a richer domain model
- ← The complete System Design guide (hub)