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 performance on reads
- High availability
- Low latency
- Horizontal scalability
API Design
POST /urls
Purpose
To create a shortened url
Inputs
url: String
Success response
201 created, when a record is successfuly created
{ url: "ourdomain.com/
Error responses
409 conflict, when a url already exists
400 bad request, when the provided url is not a valid url
500 internal server error
GET /
Purpose
To redirect a user to a real world url
Inputs
N/A
Success response
302 redirect, when a url matches the hash
Error responses
404 not found, when no url matches the hash
500 internal server error
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.
We only need a simple Client, Server, and Database for this application.
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.
Rest API
The api will have a POST endpoint that receives a URL to be shortened from the client. That url will be hashed and stored in a key-value DB like DynamoDB for O(1) lookup with the key being the hash, and the value being the url. Once successfully created, the api will return the shorted url, "
Client
The client can be a simple react SPA. React allows for extensibility in the future of the project if we want to add accounts, auth, saved links, and more.