Git Product home page Git Product logo

harunaydin99 / neo4j-movies-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neo4j-examples/neo4j-movies-template

1.0 0.0 0.0 25.75 MB

A Neo4j movies React application with backends in Python/Flask and Node/Express.

Home Page: https://neo4j.com/developer/python-movie-app/

JavaScript 89.17% CSS 3.79% HTML 0.21% Python 0.66% Shell 0.02% Makefile 0.01% Pug 0.06% Handlebars 0.01% SCSS 6.08%

neo4j-movies-template's Introduction

README

This Neo4j-based example app displays movie and person data in a manner similar to IMDB. It is designed to serve as a template for further development projects. There are two versions of the backend - a Python/Flask backend at /flask-api, and a JavaScript/Express backend at /api. The web frontend can be found at /web. Feel encouraged to fork and update this repo!

The Model

image of movie model

Nodes

  • Movie
  • Person
  • Genre

Relationships

  • (:Person)-[:ACTED_IN {role:"some role"}]->(:Movie)
  • (:Person)-[:DIRECTED]->(:Movie)
  • (:Person)-[:WRITER_OF]->(:Movie)
  • (:Person)-[:PRODUCED]->(:Movie)
  • (:MOVIE)-[:HAS_GENRE]->(:Genre)

Database Setup: Sandbox

Go to https://sandbox.neo4j.com/?usecase=recommendations&ref=movie-app-tutorial, pick "Recommendations", and press play to start the database.

Make sure to edit the file flask-api/.env or api/.env and update the MOVIE_DATABASE_USERNAME, MOVIE_DATABASE_PASSWORD, and MOVIE_DATABASE_URL of your chosen backend to connect to your instance.

Node API

First, configure your api/.env file to point to your database.

Then, from the root directory of this project:

Alternative: Flask API

First, configure your flask-api/.env file to point to your database.

Then, from the root directory of this project:

cd flask-api
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
export FLASK_APP=app.py
flask run

Frontend

From the root directory of this project, set up and start the frontend with:

  • cd web
  • nvm use
  • npm install
  • update web/.env file

If you are using the Node API set REACT_APP_API_BASE_URL to http://localhost:3000/api/v0

If you are using the Flask api then set it to http://localhost:5000/api/v0

image of PATH settings for NPM

voilà! IMDB, eat your heart out ;-)

Ratings and Recommendations

User-Centric, User-Based Recommendations

Based on my similarity to other users, user Omar Huffman might be interested in movies rated highly by users with similar ratings as himself.

MATCH (me:User {name:"Omar Huffman"})-[my:RATED]->(m:Movie)
MATCH (other:User)-[their:RATED]->(m)
WHERE me <> other
AND abs(my.rating - their.rating) < 2
WITH other,m
MATCH (other)-[otherRating:RATED]->(movie:Movie)
WHERE movie <> m
WITH avg(otherRating.rating) AS avgRating, movie
RETURN movie
ORDER BY avgRating desc
LIMIT 25

Contributing

Node.js/Express API

The Express API is located in the /api folder.

Create Endpoint

The API itself is created using the Express web framework for Node.js. The API endpoints are documented using Swagger.

To add a new API endpoint there are 3 steps:

  1. Create a new route method in /api/routes directory
  2. Describe the method with swagger specification inside a JSDoc comment to make it visible in swagger
  3. Add the new route method to the list of route methods in /api/app.js.

Flask API

The Flask API is located in the /flask-api folder. The application code is in the app.py file.

Create Endpoint

The API itself is created using the Flask-RESTful library. The API endpoints are documented using Swagger.

To add a new API endpoint there are 3 steps:

  1. Create a new Flask-RESTful resource class
  2. Create an endpoint method including the swagger docs decorator.
  3. Add the new resource to the API at the bottom of the file.

neo4j-movies-template's People

Contributors

whatsocks avatar janekk avatar kbastani avatar nossila avatar dependabot[bot] avatar jexp avatar chrisportela avatar lenniezelk avatar mneedham avatar michael-simons avatar yrong avatar

Stargazers

Selman Orhan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.