Building an IMDB clone with Python (Flask) and Neo4j

Learning by example with Neo4j
Instructor:
Neo4j Developer Relations
1,339 students enrolled
English [Auto]
Get started with Neo4j, Flask, and React

You’re a Python developer interested in Neo4j and want to build a web app, microservice, or mobile app. You’ve already read up on Neo4j, played around with some datasets, and learned enough Cypher to get started.

Now you’re looking for a demo app or template to start putting those skills into practice.

This course provides an overview on everything that you need to build a Neo4j application. The Flask framework is used as the back-end, and React as front-end. To keep concepts simple, the application is an IMDB clone with basic account authentication and movie recommendation functionality.

Introduction - IMDB Clone with Flask and Neo4j

1
Introduction

This course provides an overview on everything that you need to build a Neo4j application with the Python programming language. The Flask framework is used as the back-end, and React as front-end.

To keep concepts simple, the application is an IMDB clone with basic account authentication and movie recommendation functionality.

In order to get started, you should have Python 3 installed on your system and have cloned the Neo4j Movie Template.

2
Python App Walkthrough

So you’re a Python developer interested in Neo4j and want to build a web app, microservice, or mobile app.

You’ve already read up on Neo4j, played around with some datasets, and learned enough Cypher to get started.

Now you’re looking for a demo app or template to start putting those skills into practice.

If you haven't already, clone the Neo4j Movie Template onto your machine.

This tutorial post will walk you through rating a movie on a sample movie rating application, from the initial setup to viewing the list of movies you’ve rated.

This lecture video will walk briefly walk you through the various features of the movie app.

This project uses a classic Neo4j dataset: the movie database. It includes Movie, Actor, Director, and Genre nodes, connected by relationships.

Additionally, users can create accounts, log in, and add their ratings to movies.

The Flask portion of the application interfaces with the database and presents data to the React.js front-end via a RESTful API. You can find the flask API in the /flask-api directory in the repo.

The front-end, built in React.js, consumes the data provided by the Flask API and presents it through some views to the end user, including:

  • Home page

  • Movie detail page

  • Actor and Director detail page

  • User detail page

  • Sign-up and Login pages

You can find the front-end code in the web directory.

From using Neo4j Sandbox to running the Flask API

1
Connecting the Database and Flask

To get the project running, clone the repo and follow along with the instructions in the video.

First, Start the Database!

Your app will need a database, and the easiest way to access a database that's already full of data is by connecting directly to the “Recommendations” database in Neo4j Sandbox.

Log in to Neo4j Sandbox by visiting https://sandbox.neo4j.com/, either using social authentication or your email and password.

After logging in to Neo4j Sandbox, tap “New Project” and select “Recommendations,” then tap the blue “Launch Project” button to start the database you will be connecting to.

In order to connect to the database from the environment from which you’ll be running the app (presumably your local machine), you’ll need credentials. You can find those under the “Connection details” and/or the “Connect via drivers” tab:

Note the section that looks like this - you’ll need to copy+paste the credentials in the driver section to connect to the database from your local machine.

Then, in your text editor, open and/or create flask-api/.env and enter the appropriate information into the variables: DATABASE_USERNAME, DATABASE_PASSWORD, and DATABASE_URL. Then save the file.

To start the Flask API, run:

  • cd flask-api

  • pip3 install -r requirements.txt

  • export FLASK_APP=app.py

  • flask run

Verify that the endpoints are running as expected by taking a look at the docs at: http://localhost:5000/docs

2
Endpoint by Endpoint

The React Frontend

1
The Frontend

With the database and backend running, open a new terminal tab or window and move to the project’s /web subdirectory.

Run nvm use to ensure you’re using the node version specified for this project.

If you don’t have the recommended version of node installed, follow the prompt to install the recommended version.

After verifying you are using the recommended user, run:

  • npm install

  • cp src/config/settings.example.js src/config/settings.js

  • npm start

Navigate to view the app at http://localhost:3000/

Click on a movie poster to see its corresponding movie detail page.

Click on a cast or crew member to see that person’s profile, which includes biographical information, related people, and more movies the person has acted in, directed, written, or produced.

Deployment

1
Deploying the Database to Aura

In order to deploy the app, the database has to be deployed for real.

Download Dump File

Create an account on Aura

Upload the dump and start the database


2
Deploying the App to Heroku

After deploying the database, you will have to deploy the API and user interface portions of this app.

You will have to create two apps on Heroku: one for the backend and one for the front-end.

Starting with the backend, create a new app on Heroku.

On your local machine, add the Heroku repo as a remote.

On Heroku > Settings > Config Vars, add the credentials to connect to the database hosted Neo4j Aura (or the sandbox if you haven't migrated to Aura).


Then, create another Heroku app for the front-end.

Add another git remote pointed to the Heroku app dedicated to the front-end app.

Under Heroku > Settings > Config Vars, add the environment variables for the REACT_APP_API_BASE_URL and REACT_APP_PROXY_URL fields.

Under Heroku > Settings > Buildpacks, add mars/create-react-app to load dependencies.

Check out the Makefile in the root directory of the project.

It contains the commands needed to deploy the project.

You can run deploy-api to deploy the Flask API and deploy-web to run deployment on the React site.

You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!

Be the first to add a review.

Please, login to leave a review
a91ad269bc6d0700752de860cd2119ec
30-Day Money-Back Guarantee

Includes

1 hours on-demand video
Full lifetime access
Access on mobile and TV
Don't Miss Any Course Join Our Telegram Channel Join Channel
+ +