Requirements


Functional Requirements:


  • Create a short URL for a given long URL.
  • Return the long URL associated with a given short URL.
  • Redirect to original URL when user clicks on short URL.



Non-Functional Requirements:


  • Low latency
  • scalable
  • highly available


API Design

POST /api/v1/{longUrl}

Response with 201

{

"shortUrl": "tinyUrl/abc123",

"createdAt": "timestamp"

"expiresAt": "timestamp"

}


with Authentication - API key and rate limiting.

Every API Key gets 100 urls for a free tier.


Redirect:

GET /shortUrl

Return and redirect to original URL with 302 found response when found without authentication, otherwise return 404.


Rate limiting is key for protection against abuse.


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.


client interacts API Gateway using CDN for calling shortening service and stores in dynamo db.



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.

Identify the collision risk and tradeoff