List the key functional requirements for the system (Ask the AI for hints if stuck)...
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...
POST /shorten
Accepts URI string as body or query string parameter
Returns shortened URI string
GET /{shortened_uri}
Accepts shortened URI as path
Returns redirect to the original URI stored under received shortened URI key
DELETE /forget
Accepts shortened URI previously created on this server
Returns status code denoting whether the operation was successful
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.
Basically simple SRP module server with basic CRUD is enough. Client -> Server - Database. API gate that stores reference tables of existing information about given shortened URIs at API gateway level is responsible for redirecting requests according to where the information about received URI is stored (for redirects): either to distributed cache layer or to a shard directly. Table is updated upon receiving responses from shards responsible for any give modifying operation (CREATE, DELETE). Cache eviction policy is first of all also dependent on DELETE operation as well as time based: TTL shall be reset to e.g. 1 day each time the link is hit. Misses result in routing to the shard responsible for that link and caching upon successful response if necessary. Caching might be considered priority for potential premium users while not concerning freemium ones.
CREATE:
Client sends POST request to server with original URI to receive its shortened version
Server accepts original URI
Server derives short URI key from original URI
Server stores original URI value under shortened derived URI key
READ:
Client sends GET request represented by shortened URI previously returned from the server
Server accepts shortened URI and returns redirect to the original URI stored under shortened URI key in database
DELETE:
Client sends DELETE request w shortened URI
Server removes both shortened URI and its corresponding original URI from its registry
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...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.