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.
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!
RecommendationService: Here are some strategies we use: All these return should be stored in data structure temporily.(eg: HashMaps and Graphs)
itemId, name, category, featuresList
0001,Burberry shirt, men clothes, [Burberry, men shirt]
Then search in ActivityHistoryDatabase for the items which have the most same features products items and return
We use the weight of similar products other user purchased return> Get purchased return > Get wishlist return > get liked return > get search history return. Sort the final recommendation lists by this weight order then return top K.
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?