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:
- First non functional requirement is to design 2 endpoints to GET the short URL and other one is to fetch the converted long to short URL.
- Other Non function requirement is to take care of scaling, if tomorrow we have huge number of shortened URL we need to scale our db to reduce CPU spikes , I/0 operations. Ensure Proper Indexing for faster searches and also enable replication and sharding for the data.
- Cache the frequently used short URL to make sure we reduce network calls to DB and reduce the latency.
- To make sure data is available we need to make sure we can have a simple
API Design
We will need 2 API endpoints
The first endpoint will be the GET endpoint for fetching the URL shortener.
The second endpoint will be the POST endpoint to actually have the logic for the shortening the URL.
We can name the 2 endpoint as:
GET /get-short-url/:
POST /build-URL shortner
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.