List the key functional requirements for the system (Ask the AI for hints if stuck)...
Given a short Url redirect to original long url
Given a long url generate short url n redirect
Generating alias
List the key non-functional requirements (performance, scalability, reliability, etc.)...
Scale: how many URLs created/day, how many redirects/day
redirect should be fast
reads more less writes sort of 100:1 ratio
should redirects basically never go down
a stored short URL should never get lost
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
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...
Write flow (create short URL): Client → Load Balancer → App Server → ID Generator (get next unique number) → base62-encode it → store {short_code: long_url} in DynamoDB → return the short URL to the client
Read flow (redirect): Client → Load Balancer → App Server → check Redis cache for short_code → if hit, return long_url immediately (302 redirect) → if miss, query DynamoDB, populate cache, then return the redirect
POST /api/v1/shorten
Request: { "long_url": "..." }
Response (201): { "short_url": "...", "short_code": "..." }
GET /{short_code}
Response: 302 redirect → Location:
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.
when ever a user makes a request at client app/browser i place a loadbalancer which will efficently distributes the loads among the application server can be horizontal scabable depending on the traffic and then Id generator service api call wil be made n depending read call or write call the process will take place for example if reads I place a cache of elasticcache (redis) bcoz we need quicker reads than writing no joins are required and needs ot be fast if not in cache the database will be accessed n brought into the cache similarly for writes the write api call will call id generator n stores writes the new short url against orginal one using Base62 endoing which works using new code generator using increment 1 concept and stores into dynamo db bcoz these are key value pairs n again we dont need much of joins and all n writes can take time as its more reass than write system we can add additional CDN in front just incase of far away region issue
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...
Dynamo DB for all reads/writes I will use elastic cache redis for hot links read which will improve the reads
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Load Balancer
2. Application Servers
3. ID Generator Service
4. Cache Layer (Redis/ElastiCache)
5. Database (DynamoDB)
6. CDN (CloudFront) — optional/enhancement layer