Problem
Design an event notification system that delivers notifications to users across multiple channels (in-app, email, push notifications, SMS) based on events occurring in the system. Users should be able to configure their notification preferences per event type.
Requirements
- Event Ingestion: Accept events from multiple producers (e.g., order placed, payment received, comment added) via an internal API.
- User Preferences: Each user can configure which notification channels they want for each event type (e.g., "order shipped" -> email + push, "new comment" -> in-app only).
- Multi-Channel Delivery: Support in-app notifications (stored for retrieval), email (via SendGrid/SES), push notifications (via FCM/APNs), and SMS (via Twilio).
- Template Rendering: Each notification channel has its own template. Templates support variable interpolation from event data.
- Delivery Tracking: Track delivery status for each notification (sent, delivered, failed, read).
- Batching: Support digest mode where low-priority notifications are batched and sent at intervals (e.g., daily summary email).
Constraints
- The system processes up to 10,000 events per minute.
- Notifications should be delivered within 30 seconds of the triggering event (for real-time channels).
- The system must handle provider failures gracefully (retry, fallback to another provider).
- Users can have up to 50 different event type preferences.
- Template rendering should not block the delivery pipeline.
What to Design
- The event processing pipeline from ingestion to delivery
- The preference storage schema and lookup strategy
- How you handle provider failures and retries
- The batching/digest mechanism
- How you scale each component independently