a long URL and receive a shortened URL
after which they no longer work.
In terms of database and storage:
Total size per URL = 20 + 10 + 10 = 40 bytes
If we expect that each request to the URL shortening service would require:
POST /shorten{ "longUrl": "http://example.com/some/very/long/url", "customAlias": "myCustomAlias" // optional
}
{ "shortUrl": "http://short.ly/abc123"}
GET /{shortCode}GET /analytics/{shortCode}{ "shortUrl": "http://short.ly/abc123", "clickCount": 150,
"createdAt": "2023-01-01T00:00:00Z", "lastAccessedAt": "2023-01-15T12:00:00Z"
}
PUT /shorten/{shortCode}{ "longUrl": "http://example.com/new/long/url"}
{ "message": "URL updated successfully"}
DELETE /shorten/{shortCode}Here's a proposed ERD to illustrate the relationships between these entities
short_code and long_url in the URL_MAPPING table for faster lookups.Here's a conceptual diagram to visualize the high-level components and their interactions:
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?