Frontend School

Groww Real-time Notification System (Frontend)

System Design
medium

Groww Real-time Notification System (Frontend)

Medium
Frontend System Design
Real-time
Notifications
WebSockets
Fan-out
Client-side Architecture

Overview

Groww users rely on timely updates for their investments, including real-time stock price movements, order status changes, and personalized news alerts. This problem focuses on designing the frontend client-side system responsible for efficiently receiving, processing, and displaying these critical real-time notifications to ensure an engaging and informed user experience.

What you need to do / Task

  1. Design the client-side architecture for establishing and maintaining real-time connections to a backend notification service.
  2. Outline mechanisms for efficient client-side filtering, prioritization, and aggregation of diverse incoming notification events.
  3. Propose how notifications are rendered, managed, and interacted with within the user interface (UI).
  4. Discuss client-side scalability, performance, and resilience considerations for handling a high volume of updates.

Scenario

A Groww user with an active portfolio, multiple securities on their watchlist, and pending orders needs to receive immediate, relevant alerts. These could include a specific stock hitting a target price, an order transitioning from 'pending' to 'executed', or breaking news affecting one of their holdings. The system must deliver these updates reliably and without overwhelming the user or degrading the performance of the Groww web application, regardless of the user's current screen.

Constraints

Constraints & assumptions

  • Target Environment: Groww's web application, running in a modern browser environment.
  • High Event Volume: The backend notification service is capable of fanning out thousands of messages per second. The client-side system must efficiently consume and process a potentially high volume of relevant messages.
  • Low Latency: Notifications should appear near-instantaneously upon arrival from the backend.
  • Reliability: Critical notifications should not be lost due to transient network issues or client-side errors.
  • User Experience: Notifications should be non-intrusive, customizable, and performant, without causing UI jank or excessive resource consumption.
  • Backend Push Service: Assume a robust, WebSocket-based backend service exists that efficiently pushes relevant events to authenticated clients. The focus is purely on the client-side consumption and presentation.
  • User Authentication: Handled by existing Groww authentication systems.

Out of scope

  • The detailed design of the backend fan-out architecture (e.g., message brokers, pub/sub systems).
  • Notification delivery channels beyond the in-app web experience (e.g., SMS, email, mobile OS push notifications).
  • Deep dives into backend database schemas for notification storage.

What interviewers evaluate

  • Understanding of real-time client-server communication protocols (e.g., WebSockets) and their client-side lifecycle.
  • Ability to design a robust and scalable client-side architecture for event reception, processing, and state management.
  • Proposing effective strategies for client-side filtering, aggregation, and UI presentation to optimize user experience and performance.
  • Consideration of error handling, resilience, and resource efficiency within a frontend application context.

Requirements

1.

Design client-side connection management for real-time updates (e.g., WebSockets), including reconnection logic.

2.

Propose a robust mechanism for parsing, validating, and categorizing diverse incoming notification messages on the client.

3.

Detail client-side filtering, prioritization, and aggregation logic to display only contextually relevant notifications.

4.

Describe UI components and state management for rendering notifications (e.g., toasts, notification center, badge counts) and handling user interactions.

5.

Explain strategies to ensure UI performance and prevent blocking the main thread, even with high notification volume.

6.

Outline error handling and resilience mechanisms for client-side notification processing and connection stability.

7.

Discuss how to manage notification lifecycle states on the client (e.g., read/unread, dismissal, persistence across sessions).

Design Brief

Groww aims to provide its users with a seamless and real-time investment experience. A critical component of this is the in-app notification system, which keeps users informed about vital market movements, portfolio updates, and transaction statuses.

Your task is to design the frontend client-side architecture for this real-time notification system. The system should be capable of:

  1. Establishing and maintaining real-time connections: How does the frontend client connect to a backend notification service and ensure the connection's stability and resilience against network interruptions? Consider reconnection strategies and authentication.
  2. Efficiently receiving and processing diverse event types: Users will receive various types of notifications (e.g., 'StockPriceUpdate', 'OrderStatusChange', 'NewsAlert', 'PortfolioPerformanceAlert'). How does the client-side parse, validate, and categorize these incoming messages efficiently?
  3. Client-side Fan-out & Filtering: The backend might push a high volume of generic events that are fanned out to many clients. How does the frontend intelligently filter, prioritize, and potentially aggregate these events to display only what's immediately relevant to the user's current view (e.g., only updates for a specific stock when on its detail page) or global preferences, without overwhelming the user or degrading UI performance?
  4. UI Presentation and Management:
    • How are notifications displayed (e.g., transient toast messages, a persistent notification center, badge counts on icons)?
    • How does the system manage the state of notifications (e.g., marking as read/unread, dismissing individual notifications, clearing all)?
    • How does it ensure that displaying a high volume of notifications doesn't block the main UI thread or cause rendering jank?
  5. Scalability and Performance (Client-side): Discuss how your design handles an increasing number of concurrent notifications and users without impacting the client-side application's performance, memory footprint, or responsiveness.
  6. Error Handling and Resilience: What mechanisms are in place on the client side to handle connection drops, malformed messages, backend service unavailability, or rate limiting? How does the system ensure message integrity and prevent data loss from the client's perspective?

You should consider typical web application frameworks (e.g., React, Vue, Angular) and relevant browser APIs. Focus on the architectural components, data flow, state management, and interaction patterns within the frontend application.

Loading editor...