Design Recommendation API | Akamai Interview

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-10-09Added By Anonymous
Source: Link

Company: Akamai
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

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

So, I mentioned following tables:

  • Product
  • ProductOrder
  • UserActivity
  • Order
  • User

Now, using the above tables, we will write logic to determine the list of products which could be recommended to the customer. This recommendation could be saved to a distributed cache. The cache will help faster access and a smooth experience for the user.

Now, how and when does the cache need to be updated? This could be done based on an event, when the user is browsing and/or purchases some product. One of the microservices performs recommendation calculation and syncs to cache (in the background, Kafka could be used alongside). Since we would have memory constraints also on the cache, so we will maintain a rule to retain recommendation data for maybe 7-10 days; if a user's recommendation hasn't been updated, it can be moved out of the cache.

API :

getRecommendation(RecommendationRequest req)

RecommendationRequest :
{
userid :
preference :
//some other info, if required later
}
RecommendationResponse : It is a list of products.

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

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

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

Comments