Design Recommendation API | Akamai Interview
3977

Design an API for eCom site, which will recommend product to the logged-in user. Frankly speaking, I wasn't very clear where to start in this case. So, started with data modeling as recommendation should be dependent on some factor like last order, recent browsing.

So, I mentioned following tables

Product
ProductOrder
UserActivity
Order
User

Now, using above tables, we will write logic to determine the list of product, which could be recommended to the Customer. This recomendation could be saved to distributed cache. The cache will help faster access and smooth experience to the user.

Now, how and when cache needs to be updated ?
This could done based on event, when user is browsing and/or purchase some product. One of the microservice performs recommendation calculation and sync to cache (in background, Kafka could be used along side). Since, we would have memory contraints also on cache, so we will maintain rule to retain recommendation date for may be 7-10 days, if user recommendation hasn't updated can be move out of the cache.

API :

getRecommendation(RecommendationRequest req)

RecommendationRequest :
{
userid :
preference :
//some other info, if required later
}

RecommendationResponse : It is be list of products.

I have also mentioned about classes and API flow (controller, service etc). Later started asking very low level of techinal details. Like write DB connectivity code and other (Seriously !!,)

This was quite long discussion which went for more than an hour only on design discussion. Later he asked DS/Algo question. At one moment I was little tired as entried discussion went for 2 hours continuously.

I probably might have missed something in my solution. So, any thought/input ?

Comments (4)