Requirements
Functional Requirements:
- Create a short URL for a given long URL.
- Return the long URL associated with a given short URL.
Non-Functional Requirements:
- High availability: The system should be operational and accessible at all times
- Low-redirect latency: The redirects should happen as quickly as possible
- Horizontal scalability: The system must be to scale horizontally by adding more servers
API Design
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...
- Create a short URL => POST method : /api/shorten-url
- Body:
{
"longUrl": "xxx"
}
- Response:
{
"shortenUrl": "yyy"
}
- Redirect to long url when user enters a shortened link => GET method : /{shorten-url}
- Response:
Status Code: 301
Redirect URL: A long URL
High-Level Design
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.
Detailed Component Design
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Shorten-URL-Service: