1) User can register themselves for Grocery delivery application
2) Once register they can login to the application
3) Based on delivery location it will list the grocery stores and farmers
4) Users can select the item and purchase .
5) Grocer stores and farmers can register themselves and update there products and quantities.
1) Low latency and high performance
2) Highly available
3)
1M users registered for grocery stores.
10k Grocery stores and Farmers registered for a location
Storage for the inventory based on location --
Number of products and size - 5MB
Total inventory storage - 5MB *10000 = 5 GB
Storage for order --
25% * 1 M users *10 kB does order daily = 2.5 GB daily
we will have multiple APIs
1) User registration
POST /api/v1/register
request username,email_id,location
Response 201 created
2) user shopping
GET /api/user/search/{loc} -- default search when users loges in
GET /api/user/search/{search_term}
Return list of product based on location
User table : (Relation DB)
user_id : uuid
user_name:string
email:string
address:string
product table (No sql DB)
product_id: uuid
prod_desc
inventory table (relation DB)
inventory_id:UUID
product_id
Qunatity
location
order table (relation table)
order_id:uuid
user_id
product_id
There is two flows first for users who does order of the product and second one is for the stores/farmers who sells the products.
1) User first register to grocery stores and loges in with the credential and search for the product add to the cart and place the order.
2)In the second Grocery stores OR farmers can register and sell there product by listing there products and quantities.
1) User search product display uses indexes to provide the results based on users search ..Index get updated when there is new product OR we remove any products.
2) Product inventory can be fetched from the distributed cache in real time way where if there is any change in inventory through CDC it updates the cache so that we can have updated values .
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?