Traffic / QPS
Storage
Cache
POST /api/urls
Request:
{
"longUrl" : "string (required)",
"customAlias" : "string (optional)",
"expiresAt" : "datetime (optional)"
}
Response: 201 -> {"shortUrl"}
GET /api/urls/{shortURL}
Response: 302 -> {LongUrl}
DELETE /api/urls/{shortURL}
GET /api/urls/{shortUlr}/stats
PUT /api/urls/
This architecture consists of the following components:
1. The system client itself - the primary user who wants to get a short link to their long URL
2. CDN - to speed up operation
3. Load Balancer - to protect the system from overload and ensure continuous server availability
4. API Gateway - a single entry point, added for routing and system security
5. Rate Limiter - a service that checks whether the short link has expired
6. Shortener Service - a service for creating, editing, and deleting short URLs
7. Redirect Service - a service responsible for redirecting a short URL to the original long URL
8. Shortener Service and Redirect Service - both use Cache to quickly find URLs; if they are not in the cache, they attempt to work with them through the Database
9. ID Generation Service - is used to generate a hash of identifiers for working with short URLs.
10. Analytics Service - an analytics service that tracks clicks on short URLs. The Shortener Service and Redirect Service send data to it
11. Database — the source of truth for all short_code → long_url mappings; absorbs all writes; the cache sits in front of it to serve the read-heavy traffic
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.