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...
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.
Client will make call through LB or API gateway and request will be directed to server. Each server can have its own unique id generator (details in below section), server will push the details using the unique id of each paste and also read from there using that. Cache will be there for faster queries. Since our paste size is max 100KB we will use DB itself for this question. If the paste size was even larger like larger than 1GB, or have multimedia as well, we could have added an S3 connected to the server and CDN connected to the user. For private pastes we can have user sign up as well, those kind of requests will also go through the same flow. For expired pastes, we can have a cron job that will check the DB for expired pastes and delete them.
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.
Client will be the mobile app or the website. It will go through LB or API gateway which will have authentication, rate limiting, etc.
All requests will be routed to the server, like user sign up, creating a paste, getting a paste, etc. User can create a public paste if signed out and private/public paste if signed in. Each server will have its own unique id generator since we can use something like UUID or Twitter snowflake approach and that id can be used to write and read the paste and also used in our URL of the paste.
Cache will be used to store frequently accessed pastes. Since text size is 100KB we can use a key value store like Redis for cache since it can store our data.
For DB, we can use NoSQL DB like Amazon DynamoDB, MongoDB, etc as they can store our paste size limit and also fast for reads, they also have encryption at rest. We can also use SQL DB like PostgreSQL because that can also accommodate 100KB text size and since reads are high but manageable by SQL DB and we only need to search by primary key. And a cron job can access the DB daily or hourly to delete the expired pastes.