List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
get product - product_id
purchase - cart_id
search - query term
recommendations - infer user from headers
order status - order_id
update order status - order_id, status
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...
Since strong consistency is a requirement for orders and products - we will choose an SQL database which offers ACID guarantees. We should stick to one type since we have relationships between users, orders, and products that SQL databases handle well with efficient queries.
Query patterns
Products - id, description, price,
Orders - id, cart_id, status
Users - id, name
product counts - product_id, click_count, purchase_count
One concern is working with 100 million products with heavy read requests as users click on products, we will need to shard the products table. Range based sharding is better for a table that will grow (no re-hashing and moving data around nightmare)
Replication will be important for data durability - though since we're sharding already, let's keep it simple and keep all writes and reads to the master node.
Add a Redis cache for Products, it will take read pressure off of the table,
Read from cache first, else get from DB. Use a LRU eviction policy, the most popular products will stay in the cache.
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...
Client
LB
Web servers
search service, recommendation service, payment service, Auth server
Data Layer
recommendation service -> orders (query by
Offline
products db <- worker -> index search cluster.
product recommendations cache <- worker -> product_counts
-> ML model
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...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?