This sample app shows you how to write a Node.js application that interfaces with IBM Graph, IBM's graph database as a serivce. It can be deployed to Bluemix and other cloud foundry platforms. The application uses a graph dataset with movies and actors as nodes in the graphs connected by edges that show who played a part in which movie. The user can use the application to traverse the graph and find connections between actors. IBM Graph is well suited for this task, as its data model is a property graph and its support for Gremlin makes it easy to write queries that involve graph traversals.
-
If you do not already have access to a Cloud Foundry PaaS, sign up for Bluemix.
-
Download and install the Cloud Foundry CLI.
-
Clone the app to your local environment from your terminal using the following command:
git clone https://github.com/ibm-cds-labs/6degrees-of-kevin-bacon.git
- Change into the newly created directory:
cd 6degrees-of-kevin-bacon
- Open the
manifest.yml
file and change thehost
value to something unique.
The host you choose will determine the subdomain of your application's URL.
- Connect to Bluemix in the command line tool and log in.
cf api <API_URL> # e.g. https://api.ng.bluemix.net
cf login
- Create an instance of the IBM Graph service.
cf create-service 'IBM Graph' Entry six-degrees
- Push the app.
# optionally, log in
cf api <API_URL> # e.g. https://api.ng.bluemix.net
cf login
# deploy the app
cf push
- Import the sample data
Put your service credentials into a new file named config.json
. Then, run the import script:
./import.js -c config.json -p data/movies-demo.csv
The application uses Node.js and npm so you will have to download and install them as part of the steps below.
- Duplicate the
.env.example
to.env
cp .env.example .env
-
Copy the credentials from your
ibm-graph
service in Bluemix to.env
, you can see the credentials using:$ cf env <application-name>
Example output:
System-Provided: { "VCAP_SERVICES": { "IBM Graph": [ { "credentials": { "apiURL": "<graph-url>", "password": "<graph-password>", "username": "<graph-username>" }, "label": "IBM Graph", "name": "six-degrees", "plan": "Entry", "tags": [ "ibm_created", "data_management", "ibm_beta" ] } ] } }
You need to copy
graph-username
,graph-password
andgraph-url
. -
Install Node.js
-
Go to the project folder in a terminal and run:
npm install
-
Start the application
-
node index.js
├── assets - frontend assets: css, js, images
├── data
│ └── movies-demo.csv - movie sample data in csv format
├── import.js - import script to import movie data into IBM Graph
├── index.js - main program
├── manifest.yml - manifest that describes the application and its deployment to cloud foundry
├── package.json - node package file with metadata about the project, e.g. dependencies
├── schema.json - the schema definition for the sample data
├── setup.js - setup script to set the schema
└── templates
└── index.jade - jade template
The fastest way to deploy this application to Bluemix is to click the Deploy to Bluemix button below.
Don't have a Bluemix account? If you haven't already, you'll be prompted to sign up for a Bluemix account when you click the button. Sign up, verify your email address, then return here and click the the Deploy to Bluemix button again. Your new credentials let you deploy to the platform and also to code online with Bluemix and Git. If you have questions about working in Bluemix, find answers in the Bluemix Docs.
See CONTRIBUTING.md