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:
- List the key non-functional requirements (eg low latency, scalability, reliability, etc.)...
Capacity Estimation
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
API Design
Shorter should have 2 endpoints for
shortenUrl(url) - returns shortened url to the user, and stores in DB - POST.
getUrl(shortUrl) GET - fetches url and redirects to the user.
High-Level Design
we have cdn for finding closes server,
load balancer for redirecting user to closes API
2 microservices shortner service and redirect service.
Shortner stores most recent ursl into redis and dynamo db.
for sake of latency we fetch newly created urls from redis cache.
Database Design
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Detailed Component Design
shortener service when gets url generates short hash for it and stores to nosql db with key being short hash and value being actual url.
redirect service when recieves short url fetches it via db query with short url as a key and throws redirect request with the long url value.