Collect user purchase history
Page Views Tracking
Click Tracking
Like or dislike for each product
Tracking products user click like and dislike
Track search history
Track user wishlist
Compare other users has purchased and like most common products. Recommend their other purchases to each other.
Scalability: plenty of data of user activities increasing in each user everyday. Database management should be scalable.
Maintainable: Multiple tables mapping are complex. Data table Sharding and decoupling must be important to data engineers narrow down the scope.
Estimate the scale of the system you are going to design...
Supporting func:
purchased[] getPurchaseHistory(userId)
void addClickedItem(userId, itemId)
itemId[] getClickedItems(userId)
void addLikeOrDislike(userId, itemId, attitude)
Map
void addSearchHistory(userId, keyword)
itemId[] getSearchHistory(userId)
void addWishList(userId)
wishlist[] getWishList(userId)
userId[] getTopKUserPurchasedMostCommonItem(userId)
ItemId[] getTopKPurchasedItemsByTopKCommonUsers(userId:[])
RESTful API
// Combine all these API above in this API and ranking the different algorithm's by weight
GET /getRecommendations(userId, topK)
return itemId[]
// add new user activity in log, action is for action type eg: search, clicked, like/dislike, etc, keyword use for search action, attitude for like/dislike
POST /logUserActivity(userId, action, itemId, keyword, attitude)
// get user activity profiles
GET /userActivityProfile(userId)
Here are tables: the key end with "At" means the timestamp action took
Purchased:
[userId, itemId, purchasedAt]
Attitude:
[userId, itemId, attitude, createdAt]
Clicked:
[userId, itemId, clickedAt]
Search:
[userId, keyword, searchAt]
WishList:
[userId, itemId, wishAt]
Recommendation //list all recommended items for each user
[userId, itemId:[], confidence]
*Please check my Sequence diagram!
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?