List functional requirements for the system (Ask the chat bot for hints if stuck.)...
User Registration
Product Registration
Product lookup and purchase
List non-functional requirements for the system...
Available/Durable - 99.9%
Consistent - Product amount, availability should be consistent
Scalability - Should be able to handle peak traffic during black friday
Performance - Page load time < 1s, searching should have low latency < 500ms
Security - JWT, Ratelimiting for product look up, PCI for payment, Cleaning for SQL injection
Reliability - Information should be accurate, product amount
Monitoring
Idempotent - When creating a product it should remain unique
Estimate the scale of the system you are going to design...
50m users
20% DAU - 10 million - reads
100 rps
1 % post a product everyday - 5 million DAU - Posting
5 million / 100 k = 50 wps
2kb product description - 10 gb daily
10gb / 100k = 100kb/s
Define what APIs are expected from the system...
User registration
Product Creation
Product list/ recommendations / search
Purchase
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
User / Authentication
RDMS - Postgres
username
id
pwd
Product Table - Postgres
id
name
added_by
price
available
amount
description_id
ProductDescription Table - NoSQL - MongoDb
product_id:
{
description
color
size
weight
}
Purchases Table - PostGres
product_id
amount
total_price
purchaser_id
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Using NoSQL , ES will lead to overengineering, possible lag and duplicate creations. Can be fixed by using kafka and outbox
Read replicas
Try to discuss as many failure scenarios/bottlenecks as possible.
High traffic on a single product can lead to hot shards for that product
Postgres Down can lead to mongo db and es not being updated either
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?