Skip to content

This project contains a Node.js starter template for a Neo4j movies dataset.

Notifications You must be signed in to change notification settings

lina/neo4j-movies-template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is a movie content browser powered by Neo4j. All movie content is consumed from a Neo4j REST API endpoint built using Neo4j Swagger.

##Tools:

Architecture

  • Front-end web-based dashboard in Node.js and Bootstrap
  • REST API via Neo4j Swagger in Node.js
  • Data import services in Node.js
  • Data storage in a Neo4j graph database

Getting Started

If you haven’t done so already, download or clone this repository and navigate to it using your Terminal (if on a Mac) or command line.

Setting up Node.js

If you’ve never used node, this is a good first step as it verifies you have the correct libraries for running the web application.

  • From the terminal, go to the web directory of the project and run npm install, after node_modules are installed, run node app. The movies website will be started at http://localhost:5000
  • Install Node.js either via homebrew using brew install node or directly from http://nodejs.org/
  • Navigate to the api and web folders and install dependencies running npm install in each.
  • Navigate to the web folder and run node app.js
  • Take a look at http://localhost:5000/
  • If you see some awesome movies there, success! :D

Setting up Neo4j

Installation

So Node.js is set up and you can see the boilerplate Movies application running on http://localhost:5000/, great. Now we want to set up an instance of Neo4j locally so we can look at and modify the data.

  • Download Neo4j here
  • Extract Neo4j to a convenient location and rename the folder to something less cumbersome, like ‘Neo4j’, if you want
  • Navigate to the extracted folder and run ./bin/neo4j start
  • If all goes well, you should see the Neo4j web application running at http://localhost:7474/

Adding the Movie data

Right now your Neo4j Database does not contain the Movie data. Let’s fix that.

  • Navigate to your Neo4j directory
  • If you have Neo4j running, stop it with ./bin/neo4j stop in the Neo4j directory
  • If you want to make sure you killed it good, check by running launchctl list | grep neo and launchctl remove any processes that might be listed
  • If you ls data, you’ll see a file called graph.db.
  • Delete the existing graph.db.
  • Grab the zipped movies graph database file from the databases folder in the web app
  • Unzip it into the data folder
  • Run Neo4j! You should be able to see some nodes at http://localhost:7474/

Setting up Swagger

You can see the demonstration web app is GETing information about movies and people from http://movieapi-neo4j.herokuapp.com. However, we want to be able to run the web application locally or from another server.

Learn more about Swagger.

Putting it all together

First, let's make a change to our local database so we know which database we're looking at.

Run the following query:

MATCH (n:Movie) WHERE n.`title` = 'The Matrix' SET n.rated = 'awesome' RETURN n

Swagger

Open to the api/neo4j/config.js file. You’ll see:

nconf.defaults({
    'neo4j': 'remote',
    'neo4j-local': 'http://localhost:7474',
    'neo4j-remote': 'http://default-environment-txj2pq5mwx.elasticbeanstalk.com/',

...

Replace the above with:

nconf.defaults({
    'neo4j': 'local',
    'neo4j-local': 'http://localhost:7474',
    'neo4j-remote': 'http://default-environment-txj2pq5mwx.elasticbeanstalk.com/',

...

From your parent directory, run node api/app.js to get Swagger started.

Head on over to http://localhost:3000/docs/, GET The Matrix you can do a search by title, for instance, and verify that this movie is now rated awesome.

The Frontend

Make sure whaveter database you're pointing at (whether a local one on port 7474 or a remote database) are running, and you've started your Swagger API with node api/app.js.

Again run node web/app.js in the neo4j-movies-template directory, and .\bin\neo4j start from your Neo4j directory, if it isn’t already running.

Verify that The Matrix is indeed rated awesome, and have fun.

About

This project contains a Node.js starter template for a Neo4j movies dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 63.8%
  • CSS 17.6%
  • HTML 13.9%
  • Ruby 3.3%
  • Shell 1.4%