Skip to content

venugopalkadamba/Movie-Recommendation-System-ML-React-Flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Movie Recomendation System with Sentiment Analysis

About

KVG Movie Zone is an AI based web application in which you can search for any Hollywood Movie. This application will provide all the information related to that movie, does sentiment analysis on the movie reviews and the most interesting part, this application will provide you the top 10 movie recommendations based on your search.

ReactJS was used for frontend which was deployed using firebase hosting and a Flask API was deployed using Docker container on Heroku to serve the machine learning models to the Frontend.

This application uses Content Based Movie Recommendation to recommend movies to the user.TMDB API was used to retrieve all the information related to the movie and its cast. Web Scraping was done on IMDB website to get the reviews related to the searched movie. Sentiments analysis is done using a machine learning model trained on a sample of IMDB Dataset.

Deployed Web Application Link: https://kvg-movie-zone.web.app/
Deployed Flask API Link: https://kvgmrs-api.herokuapp.com/

Demo

demo

Architecture

architecture

How to generate TMDB API Key?

  1. Login to you your tmdb account: https://www.themoviedb.org/ or create one if you dont have.
  2. Then open https://www.themoviedb.org/settings/api link and create your api key by filing all the necessary information.
  3. IMPORTANT: After generating the TMDB API KEY, replace "ENTER YOUR TMDB_API_KEY" with your generated key in the API and FRONTEND code.

TMDB API End Points

  1. BASE URL: https://api.themoviedb.org/3
  2. FOR MOVIE DATA: https://api.themoviedb.org/3/movie/{tmdb_movie_id}?api_key={TMDB_API_KEY}
  3. FOR MOVIE CAST DATA: https://api.themoviedb.org/3/movie/{tmdb_movie_id}/credits?api_key={TMDB_API_KEY} NOTE: Please do refer the documentation at the BASE URL for better understanding.

Flask API end points

  1. To get recommendations: https://kvgmrs-api.herokuapp.com/recommend_movie
Data to be sent in POST request:
{
    movie_name:"The Avengers",
    number_of_recommendations:"10"
}

Data Returned by the API in JSON format:
{
    input_movie:{
        movie_id:TMDB_MOVIE_ID
    },
    recommendations:[
        {
            rank:1,
            movie_id:TMDB_MOVIE_ID
        },
        {
            rank:2,
            movie_id:TMDB_MOVIE_ID
        },
        .
        .
        .
    ]
}
  1. To get Movie Reviews with Sentiments: https://kvgmrs-api.herokuapp.com/movie_reviews_sentiment
Data to be sent in POST request:
{
    movie_imdb_id:"MOVIE_IMDB_ID"
}

Data Returned by the API in JSON format:
[
    {
        id: 1,
        content: "THE REVIEW",
        sentiment: "SENTIMENT FOR THE REVIEW"
    },
    {
        id: 2,
        content: "THE REVIEW",
        sentiment: "SENTIMENT FOR THE REVIEW"
    },
    .
    .
    .
    10
]

NOTE: The error messages are returned in the following format:

{
    error:"Content of ERROR Message"
}

Steps to run the React Project

  1. Clone or download the repository in your local machine.
  2. Open command prompt in the following folder FRONTEND/kvg-mrs
  3. Install all the npm packages
npm install
  1. Since the Flask API is already deployed on Heroku no need to run the Flask API in your local machine to start the React frontend. You can start the react application using the following command:
npm start

Steps to run the Flask API

  1. Clone or download the repository and open command prompt in API folder.
  2. Create a virtual environemt
mkvirtualenv environment_name
  1. Install all the dependencies
pip install -r requirements.txt
  1. Run the app.py file
python app.py

The API will be running at http://127.0.0.1:5000/

NOTE: You can run the Flask API and the React Frontend in parallel and can use for development by replacing the baseURL,present in FRONTEND/kvg-mrs/src/api/recommenderapi.js, with the Flask API running link.

Steps to Dockerize and Deploy the Flask API on Heroku

  1. Clone or download the repository and open command prompt in API folder.
  2. Create your docker account at https://hub.docker.com
  3. Download the docker desktop based on you windows version from the official website of Dockers and login to the docker desktop.
  4. Start the Docker desktop in you machine.
  5. The Dockerfile for dockerinzing this Flask API is already present in the API folder.
  6. Open command prompt in API folder and run the below mentioned commands:
  7. Building the Image:
docker build -t ENTER_YOUR_OWN_TAG_NAME .

It will take some time for the execution of the above command. After execution of the above command you can see the docker image details using the following command:

docker images
  1. Install Heroku CLI in your local machine.
  2. Login to your account using follwing command:
heroku login
  1. Run the following commands for deplyment. Logging into heroku container:
heroku container:login
  1. Create a app in heroku:
heroku create YOUR_APP_NAME
  1. Pushing the docker image into heroku:
heroku container:push web --app YOUR_APP_NAME
  1. Releasing the web app:
heroku container:release web --app YOUR_APP_NAME

That's it, you can see your API running at https://YOUR_APP_NAME.herokuapp.com/

Steps to Dockerize and run the Flask API in local machine

  1. Clone or download the repository and open command prompt in API folder.
  2. Create your docker account at https://hub.docker.com
  3. Download the docker desktop based on you windows version from the official website of Dockers and login to the docker desktop.
  4. Start the Docker desktop in you machine.
  5. Replace the code present in Dockerfile with the code present in localhost_docker_code.txt.
  6. Open command prompt in API folder and run the below mentioned commands:
  7. Building the Image:
docker build -t ENTER_YOUR_OWN_TAG_NAME .
  1. Run the docker container:
docker run -d -p 5000:5000 PREVIOUSLY_ENTERED_TAG_NAME

After execution of the above command you can notice the Flask API running at http://localhost:5000

Tech Stack Used

Referred Article Links

For Movie Recommendation System

  1. Article 1
  2. Article 2

For Deployment Using Dockers

  1. Article 1
  2. Article 2
  3. Article 3
  4. Article 4
  5. Article 5

Dataset Links

  1. IMDB 5000 Dataset
  2. movies_metadata.csv and credits.csv from Movies Dataset
  3. Remaining Datasets are generated using MovieRecommendationDatasetPreparation.ipynb in MovieRecommendationCodes folder
  4. IMDB 50k Movie Reviews Dataset
Please do ⭐ this repo if you liked my work

About

A Flask, React and Machine Learning based web application for movie recommendation and sentiment analysis on movie reviews.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published