Here are the key non-functional requirements we should consider:
Estimate the scale of the system you are going to design...
Copy
POST /api/v1/status
json
Copy
{
"userId": "user123",
"status": "online|idle|offline|invisible",
"deviceId": "device456",
"timestamp": 1649276349000
}
json
Copy
{
"success": true,
"userId": "user123",
"statusUpdated": "online",
"timestamp": 1649276350000
}
Copy
GET /api/v1/status/{userId}
json
Copy
{
"userId": "user123",
"status": "online",
"lastActiveTimestamp": 1649276349000,
"devices": [
{
"deviceId": "device456",
"status": "online",
"lastActiveTimestamp": 1649276349000
}
]
}
Copy
GET /api/v1/status/batch
json
Copy
{
"userIds": ["user123", "user456", "user789"]
}
json
Copy
{
"users": [
{
"userId": "user123",
"status": "online",
"lastActiveTimestamp": 1649276349000
},
{
"userId": "user456",
"status": "idle",
"lastActiveTimestamp": 1649275349000
},
{
"userId": "user789",
"status": "offline",
"lastActiveTimestamp": 1649176349000
}
]
}
Copy
WebSocket /api/v1/presence/connect
status_update: When status of a monitored user changesheartbeat: Periodic ping to maintain connectionactivity: Client sends activity signals to reset idle timerCopy
POST /api/v1/subscriptions
json
Copy
{
"subscribeTo": ["user456", "user789"],
"notificationMethod": "websocket|webhook"
}
json
Copy
{
"success": true,
"subscriptionId": "sub123",
"subscribedTo": ["user456", "user789"]
}
Copy
DELETE /api/v1/subscriptions/{subscriptionId}
Copy
PUT /api/v1/privacy/status
json
Copy
{
"visibility": "everyone|contacts|specific|none",
"specificUsers": ["user123", "user456"],
"excludedUsers": ["user789"]
}
json
Copy
{
"success": true,
"privacySettings": {
"visibility": "specific",
"specificUsers": ["user123", "user456"],
"excludedUsers": ["user789"]
}
}
Copy
PUT /api/v1/admin/config/timeouts
json
Copy
{
"idleTimeout": 300, // seconds
"offlineTimeout": 1800, // seconds
"heartbeatInterval": 30 // seconds
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
Here's how this architecture works:
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?