Notification system
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2021-12-05
Problem Statement
Designing a Notification System that can send alerts to users via different channels like Email, SMS, Push Notification, and In-App Messages. The system should be extensible, configurable, and handle large-scale user bases efficiently.
✅ Functional Requirements
1.Notification Types
•System should support different notification types: alert, reminder, promotion, update, etc.
•Each notification should contain: id, type, message, recipient(s), timestamp.
2.Delivery Channels
•Must support Email, SMS, Push, and In-App notifications.
•Users should be able to configure their preferred channels.
3.User Preferences
•Each user can enable/disable specific channels.
•System should respect user opt-in/opt-out choices.
4.Event-driven Notification
•Notification is triggered when certain events occur (e.g., payment success, new message, system update).
•Events should be queued and processed asynchronously.
5.Retry & Failure Handling
•Failed notifications should retry a few times before logging as failure.
•Support exponential backoff strategy for retries.
🔐 Constraints & Assumptions
•Focus is on object-oriented class design, not UI.
•Assume user profile and preferences are available via external service.
•Notifications should be delivered at least once.
•System should be extensible for adding new channels.
🧱 Key Components & Classes
1.Event Class → Represents an event that triggers a notification.
2.Notification Class → Encapsulates details of a notification.
3.Channel Interface → Abstract base for channels (Email, SMS, Push, InApp).
4.UserPreferences Class → Stores preferences for notification delivery.
5.NotificationManager Class → Core class to handle event → notification → delivery.
6.EventQueue Class → Handles asynchronous event processing.
7.RetryHandler Class → Manages retries and error handling.
🔄 Expected Workflow
1.An Event occurs (e.g., "Payment Successful").
2.NotificationManager converts it into a Notification object.
3.UserPreferences are checked to determine delivery channels.
4.Notifications are sent via Email/SMS/Push through Channel implementations.
5.If delivery fails → RetryHandler retries sending.
🧪 Expected Deliverables
•Class design / UML diagram with Notification, Event, NotificationManager, and Channels.
•Implementation of polymorphism for different channels.
•Handling of user preferences and retries.
•Test cases for:
•Single-channel notification
•Multi-channel notification
•Retry logic on failure
•User opting out of certain channels
👉 This problem tests OOP principles (polymorphism, interfaces), extensibility, event-driven design, and reliability aspects — making it a solid LLD interview exercise.