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...
There will be 4 APIs we need to support:
Upload of pasted text:
User_id is a unique identifier of a user, used as a path parameter.
POST v1/upload_text/{user_id}
{
post_id: UUID,
text: String,
createdAt: Timestamp,
textType: Enum, (code or text),
ttl: String
}
Generation of unique sharable URLs:
POST v1/generate_url/{user_id}
{
post_id: UUID
}
Retrieval of text blob using the URL:
GET v1/retrieve_text/{user_id}
{
url: String
}
Deletion of a post:
DELETE v1/delete_post/{user_id}
{
post_id: UUID
}
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.
First, we need to define the data model for storing the pasted text:
table pasted_text_table {
post_id: UUID, [partition key]
pasted_text: jsonb,
user_id: UUID, [clustering column]
created_at: Timestamp,
ttl: string,
text_type: string (whether the stored text is a text or code snippet)
}
table pasted_text_url {
post_id: UUID,[partition key]
user_id: UUID, [clustering column]
sharable_url: String
}
For data storage, we will use cassandra, which is a good use case since we need heavy write throughput and high availability.
For all the requests, we first go through a load balancer, which routes traffic to different servers using consistent hashing. The request then goes to an API gateway, which does authentication, and rate_limiting by user_id, IP address etc.
Now let me walk through the 4 flows:
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.