List the key functional requirements for the system (Ask the AI for hints if stuck)...
tinyurl.com/aB3xK9) and return the short link.List the key non-functional requirements (performance, scalability, reliability, etc.)...
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...
Body: { "longUrl": "url", "customAlias": "optional", "expiry":"optional"}
201 Created -> {"shortUrl":"tinyUrl/ajk134B", "shortCode":"ajk134B"}
301/302 -> Location: https://original-long-url...
404 -> Not found
410 Gone -> expired
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.
Database choice: DynamoDB or Postgres + Citus for sharding across read replicas.
Consistency: Creation needs strong consistency. Reads accept eventual consistency. On DynamoDB is easily done with ConsistentRead=True. On postgres + Citus we need different connection on Redirect/Shortener service.
DynamoDB pay per request/ Postgres per infrasctructure.
Redis absorbs the DB access so it makes DynamoDB viable.
PARTITION BY hash(shortCode)
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
attribute_not_exists / ON CONFLICT DO NOTHING) + retry on conflict.short_code → long_url in Redis, in front of the DB.