Overview
The Real-time Notification System is a multi-channel delivery engine that handles the full lifecycle of user notifications: creation, routing, delivery, and tracking across email, push, in-app, and WebSocket channels. It is designed for applications where users need to be notified promptly and reliably, with full control over which channels they receive messages on.
Built with Node.js, TypeScript, Redis, and React, the system separates notification logic from your core application code. You dispatch a notification event, and the system handles channel routing, template rendering, delivery, and tracking. Users manage their own preferences through a drop-in React component.
Architecture
The notification system follows an event-driven pipeline:
- Event Dispatch -- Your application code calls a single
notify() function with a notification type, recipient, and data payload. The dispatcher validates the payload against a registered schema and enqueues the notification for processing.
- Preference Resolution -- The routing engine loads the recipient's channel preferences and filters out channels the user has opted out of. If the user has muted a specific notification type, the event is silently dropped with an audit record.
- Template Rendering -- Each channel has its own template engine. Email uses React Email for rich HTML rendering, push notifications use a structured payload format, and in-app notifications render from a shared template with support for markdown and action buttons.
- Channel Delivery -- Delivery adapters handle the specifics of each channel. Email is sent via a pluggable provider (SendGrid, Postmark, AWS SES). Push notifications go through Firebase Cloud Messaging or APNs. In-app notifications are persisted to PostgreSQL and pushed to connected clients via WebSocket. Each adapter handles retries independently.
- WebSocket Gateway -- A Redis-backed pub/sub layer powers real-time delivery to connected browser clients. The React hook
useNotifications() manages the WebSocket connection, displays toast notifications, and maintains a notification inbox with read/unread state.
- Delivery Tracking -- Every notification delivery attempt is logged with timestamps, channel, status (sent, delivered, failed, bounced), and error details. This gives you a complete audit trail and the data needed to debug delivery issues.
Key Features
- Multi-Channel Delivery -- Send notifications via email, push, in-app, and WebSocket from a single API call. Each channel has independent retry and failure handling.
- User Preferences -- A complete preference management system lets users control which notification types they receive on which channels. Includes a drop-in React component.
- Real-time WebSocket -- In-app notifications are pushed instantly via WebSocket. The React hook handles connection lifecycle, reconnection, and state management.
- Template System -- React Email templates for rich HTML emails, structured payload schemas for push, and markdown-capable in-app templates. All templates are type-safe.
- Delivery Tracking -- Full audit trail for every notification: dispatched, routed, rendered, sent, delivered, failed. Query delivery status per user or per notification type.
- Batching & Digest -- Configure notification batching to prevent overwhelming users. Daily or weekly digest emails aggregate notifications into a single summary.
- Rate Limiting -- Per-user and per-channel rate limits prevent notification spam. Configurable burst limits and cooldown periods.
What's Included
- Full TypeScript source code for the notification engine
- React components: notification inbox, toast system, preference manager
- React hook (
useNotifications) for WebSocket integration
- Email templates built with React Email (welcome, digest, transactional)
- Delivery provider adapters for SendGrid, Postmark, and AWS SES
- Push notification support for FCM and APNs
- Database schema and migration files (Prisma)
- Redis pub/sub configuration for horizontal scaling
- Comprehensive test suite with mock delivery adapters
- API documentation and integration guide
Who Is This For?
This system is for teams building applications where user engagement depends on timely, reliable notifications. Whether you are building a collaboration tool, marketplace, social platform, or any application with real-time activity feeds, this gives you a complete notification infrastructure that would take months to build from scratch.
It is particularly valuable if you need multi-channel delivery with user preferences -- a feature that users expect but is surprisingly complex to implement correctly, especially when handling edge cases like channel fallbacks, batching, and delivery tracking.