Exploring the Project

You must set up a development environment to run the code examples and exercises.

Get started

The repository, neo4j-graphacademy/app-python, has been created for this course. It contains any starter code and resources you need.

You can use a GitHub codespace as an online IDE and workspace for this course. It will automatically clone the course repository and set up your environment.

Open in GitHub Codespace

GitHub Codespaces

You will need to login with a GitHub account. The GitHub Codespaces free monthly usage will cover the duration of this course.

Develop on your local machine

You will need Python installed and the ability to install packages using pip.

You may want to set up a virtual environment using venv or virtualenv to keep your dependencies separate from other projects.

Clone the github.com/neo4j-graphacademy/app-python repository:

bash
git clone https://github.com/neo4j-graphacademy/app-python

Install the required packages using pip:

bash
cd app-python
pip install -r requirements.txt

Setup the environment

Create a copy of the .env.example file and name it .env. Update the required values.

Create a .env file
# Create a copy of this file named `.env` and update the values as needed.
FLASK_APP=api
FLASK_DEBUG=true
FLASK_RUN_PORT=3000

NEO4J_URI=neo4j://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=neo

JWT_SECRET=secret
SALT_ROUNDS=10

Update the Neo4j sandbox connection details:

NEO4J_URI

neo4j://{instance-ip}:{instance-boltPort}

NEO4J_USERNAME

{instance-username}

NEO4J_PASSWORD

{instance-password}

Explore the Repository

Here are some of the important directories in the project:

  • example/ - Example code for working with the driver.

  • api/ - The application code:

    • dao/ - Data Access Objects which will be modified to communicate with Neo4j

    • middleware/ - Some custom middleware functions that are used by Flask throughout the request lifecycle

    • routes/ - Route handlers that are registered on the server. You shouldn’t need to edit these files.

  • public/ - Minified build files for the SPA. Do not edit these files.

Run the Application

You can run the application using the following commands:

bash
Run the application
export FLASK_APP=api
export FLASK_ENV=development
flask run

Your Sandbox Instance

As part of this course, a Neo4j Sandbox instance has been created for you with the recommendations dataset. This dataset contains all of the details required to populate the Neoflix website.

What is Neo4j Sandbox?

Neo4j Sandbox is a free service that allows you to create pre-populated Neo4j instances completely free of charge. Neo4j Sandbox is the perfect environment for experimenting with Neo4j.

You can log into Neo4j Sandbox and create a database with a number of pre-populated datasets by visiting sandbox.neo4j.com.

Extending Your Sandbox Instance

By default, a Neo4j sandbox instance exists for 3 days. You can extend it for another 7 days by going to the sandbox site and extending it in the details (right-most down arrow) for the recommendations sandbox.

How to extend your Neo4j Sandbox instance

Accessing Your Sandbox Credentials

Your sandbox credentials can be accessed within the project through the os.getenv() function.

python
Accessing Environment Variables
import os

NEO4J_URI=os.getenv('NEO4J_URI')
NEO4J_USERNAME=os.getenv('NEO4J_USERNAME')
NEO4J_PASSWORD=os.getenv('NEO4J_PASSWORD')

Done!

Once you are ready, click the button below to complete this lesson.

Next Steps

Now that we have the project up and running, let’s take a look at the Neo4j Sandbox instance that has been created as part of your enrollment in this course.

Chatbot

How can I help you today?