Freecine Video Recommendation Engine | System Design
Summary
I had a system design interview focused on building a video recommendation engine for Freecine, where I needed to outline the core logic, ranking strategies, and data structures.
Full Experience
During my system design interview, I was given the task to design and implement the core logic for a video recommendation engine, specifically for Freecine. The challenge was to create a system that could suggest videos based on user interactions, watch history, popularity, and individual preferences. I focused on defining how recommendations would be ranked, either by view frequency or relevance to user interests, utilizing a strategy pattern for flexible ranking logic. I also had to detail the key entities like VideoNode, Context, VideoEntry, and various RankStrategy types, along with their fields and methods, to ensure the engine could manage videos, fetch recommendations, and update usage statistics effectively.
Interview Questions (1)
Problem Statement
Design and implement the core logic for a video recommendation engine used in Freecine. The engine should suggest videos as the user interacts with the platform, based on previous watch history, popularity, and user preferences.
Given a search query or recently watched video, the engine should return top recommended titles (e.g., related movies, trending series, or popular APK content).
Recommendations should be ranked either by frequency of views or relevance to user interests. We will use the strategy pattern to allow ranking logic based on different strategies.
Implementation Considerations
- User Context: Each user has a history of watched videos, genres, and languages.
- Recommendation Engine: Fetches related videos from the library.
- Ranking Strategies: Based on frequency (most watched) or relevance (genre + language match).
- Updating Usage: Each time a video is played, its view count should be updated in the system.
Entities to Consider
- VideoNode: Data structure to store videos & traverse by category/genre.
- Context: Language (e.g., English, Portuguese, Spanish) + genre (Action, Anime, Drama).
- VideoEntry: Metadata and details about each video.
- EntityType (Enum): MOVIE, SERIES, ANIME, DOCUMENTARY, LIVE.
- RankStrategy:
rankVideos(List availableVideos, String query)(e.g., FrequencyBased, RelevanceBased). - RecommendationEngine (Facade class).
Entity Fields & Methods
- VideoNode
childrenisEndOfVideoviewCountvideoTitleentityTypelanguage- Methods:
insertVideo(String videoTitle),findVideo(String videoTitle),getRecommendations(String prefix/query),deleteVideo()
- VideoEntry
videoTitleentryTypelanguageviewCount
- RecommendationEngine
VideoNodeRankStrategycurrentLanguagecontextHistory- Methods:
addVideo(),recommend(),recordView(),initializeLanguage()