Freecine Video Recommendation Engine | System Design

Problem Statement

Design and implement the core logic for a video recommendation engine used in Freecine.
8fc07d86-16f6-4767-9c97-4e4cd498135c.png

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

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

  • 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)

FrequencyBased

RelevanceBased

RecommendationEngine (Facade class)

Entity Fields

  • VideoNode

  • children

  • isEndOfVideo

  • viewCount

  • videoTitle

entityType

  • language

Methods

  • insertVideo(String videoTitle)

  • findVideo(String videoTitle)

  • getRecommendations(String prefix/query)

  • deleteVideo()

VideoEntry

  • videoTitle

  • entryType

  • language

  • viewCount

RecommendationEngine

  • VideoNode

  • RankStrategy

  • currentLanguage

  • contextHistory

Methods

  • addVideo()

  • recommend()

  • recordView()

  • initializeLanguage()

Comments (1)