Skip to content

jpaulynice/movie-recommendation-api

Repository files navigation

Movie Recommendation Engine

Build Status Coverage Status

A simple movie recommendation engine based on Apache Mahout machine learning library. This is a Jersey REST API with persistence using Spring Data/Hibernate/JPA. Although it's a simple application, it is a real recommendation engine with data stored in a MySQL database.

The idea is simple. Given:

  1. A list of users
  2. A list of movies
  3. Similarity between movie 1 and movie 2
  4. Partial users' preferences for the movies

Recommend a set of movies that the user would enjoy.

Setup

  1. Install docker and docker-compose if not already installed brew install docker && brew install docker-compose
  2. run ./gradlew clean build -x test to skip tests
  3. optionally run ./gradlew clean build, update test.properties with correct username/password to local database
  4. run dockerdocker-compose up

On Startup, the application runs these 2 scripts under: src/main/resources/META-INF/data/sql :

  1. recreate tables
  2. populate data

Database schema:

REST API Example:

GET http://localhost:8080/movies/api/v1/users/2/recommendations?limit=2

API Response:

[
  {
    "genre": "DRAMA",
    "id": 4,
    "imdb_id": "tt0120338",
    "name": "titanic",
    "img": "http://ia.media-imdb.com/images/M/MV5BMjExNzM0NDM0N15BMl5BanBnXkFtZTcwMzkxOTUwNw@@._V1_SX300.jpg"
  },
  {
    "genre": "FAMILY",
    "id": 5,
    "imdb_id": "tt0317219",
    "name": "cars",
    "img": "http://ia.media-imdb.com/images/M/MV5BMTg5NzY0MzA2MV5BMl5BanBnXkFtZTYwNDc3NTc2._V1_SX300.jpg"
  }
]

Try an invalid user with id 9000:

GET http://localhost:8080/movies/api/v1/users/9000/recommendations?limit=2

Response:

{
    "status": 404,
    "info": "No user found with id: 9000",
    "requestId": "880a6889-3969-43dc-9de1-4692d69ff807"
}

Releases

No releases published

Packages

No packages published

Languages