PremiumSeniorArchitect

Design a Frontend Notification System

System design for toasts, badges, and notification center: queue management, auto-dismiss, priority, read/unread, real-time delivery (SSE/WebSocket), filtering, push notifications, and overflow behavior.

Frontend DigestFebruary 20, 20265 min read

Designing a frontend notification system tests queue management, real-time data, accessibility, and cross-cutting UI concerns. Here's a structured approach.

Requirements Clarification

Functional Requirements

  • Toasts: Temporary messages (success, error, info, warning); auto-dismiss; manual dismiss; stack when multiple.
  • Badge: Unread count on nav icon (e.g., bell); updates in real time.
  • Notification Center: Full list of notifications; filter by read/unread, category; mark as read; pagination.
  • Real-time: New notifications arrive via SSE or WebSocket without polling.
  • Push: Optional browser push notifications when tab is backgrounded.

Non-Functional Requirements

  • Max N toasts visible (e.g., 3–5); queue overflow behavior (drop oldest, or show "+N more").
  • Screen reader announcements for important toasts (live region).
  • Performant with hundreds of notifications in the center.

High-Level Architecture

┌─────────────────────────────────────────────────────────────┐
│                    NotificationProvider (Context)             │
├─────────────────────────────────────────────────────────────┤
│  ToastQueue          │  NotificationCenter (state)           │
│  - active toasts     │  - notifications[]                    │
│  - maxVisible: 5     │  - unreadCount                        │
│  - priority queue    │  - filters, pagination                 │
├─────────────────────┴───────────────────────────────────────┤
│  RealTimeConnection (SSE/WebSocket)  │  useToast(), useNotifications()  │
└─────────────────────────────────────────────────────────────┘

Continue reading Design a Frontend Notification System

Sign in or create a free account to read the rest of this article and all premium content.

Sign in to continue reading