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:
- A list of users
- A list of movies
- Similarity between movie 1 and movie 2
- Partial users' preferences for the movies
Recommend a set of movies that the user would enjoy.
- Install docker and docker-compose if not already installed
brew install docker && brew install docker-compose
- run
./gradlew clean build -x test
to skip tests - optionally run
./gradlew clean build
, update test.properties with correct username/password to local database - run docker
docker-compose up
On Startup, the application runs these 2 scripts under: src/main/resources/META-INF/data/sql
:
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"
}