Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
our api should be like this :-
payload :-
{
"user_id": "user-789",
"preferences": [
{ "category": "marketing", "enabled": false },
{ "category": "transactional", "enabled": true },
{ "category": "reminders", "enabled": true }
],
"quiet_hours": { "start": "22:00", "end": "08:00" }
}
Here we will track user action using below paramters - userId, deviceId, action, timeStamp.
json payload will be :-
{
"notification_id": "uuid-12345",
"user_id": "user-789",
"device_id": "device-xyz",
"action": "CLICKED", // Options: DELIVERED, CLICKED, DISMISSED
"timestamp": "2026-05-05T11:42:12Z",
"metadata": {
"platform": "ios",
"campaign_id": "summer_sale_2026"
}
}
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Our components will be :-
Will go in detail design :-
Scheduler Prioritization:-
Not all notifications are equal. A "security alert" (OTP) is more important than a "20% off coupon". we should implement priority queuing.
High Priority: Transactional alerts(OTP, Payment success). These bypass the main queue and are processed by dedicated "express workers"
Medium Priority: Time-sensitive alerts (Friend requests, messaging).
Low Priority: Marketing campaigns and newsletters. these are processed only where the high / meidum queues are near empty.
Weight Fair Queuing: workers are allocated in ratio(ex:- 70% of workers listen to hight priority queue, 30% to Low-priority) to ensure low-priority tasks never completely "starve"
Tracking Service(User action) :-
The tracking service provides a public endpoint (ex- POST /v1/track) that the mobile app calls when a notification is clicked. It captured click_event, delivery_receipt, dismisal_event. why it is separated ? By making this separate service, we ensure that a massive surge in clicks(ex- during a breaking news alert) doesnt slow down sending workers.
Database Schema:
Since we were using a Relational DB we have table like this
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Our components will be :-
Will go in detail design :-
The Message Queue (Reliability) :-
The Redis Cache(Peformance)
The Workers (The Executioners)
Database Schema:
Since we were using a Relational DB we have table like this
Asynchronous Engagement Processing :-
The tracking API is a "fire and forget" entry point to ensure the users app feels fast.
The Ingestion Flow : when a user clicks a notification, the app sends a request to the Tracking Service. This service does not write directly to the main db.
The Buffer: The tracking service acts as a producer for a dedicated analytics topic. This decouples the "recording" of the event from the "processing". why this matters :-if a breaking news alert causes 10 million clicks in 60 seconds, our DB wont lockup beacuse of kafka "buffers" the load.