Graph databases are particularly useful and powerful when working with complex hierarchical data structures. Application data is modeled and stored as nodes, edges, and properties to represent entities, relationships, and their attributes. A graph query language, instead of traditional SQL, retrieves and manipulates data by traversing the graph over a number of edges and nodes.

The new “Develop a graph database app using JanusGraph” journey provides a sample Twitter app and utility code to help you become familiar with developing a graph database application in JanusGraph, a scalable open source graph database solution.

The sample Twitter app consists of two parts:

  1. A data model that defines users and messages as nodes, and user actions as edges. A few indexes are included so you can use the storage and the index back-ends for better query performance. You can take the model to generate and import schema and data in JanusGraph in a few minutes.
  2. The sample queries are prepared so you can make basic search requests, such as “find the tweets by your best friend in Jan 2017,” “find his/her tweets that his/her followers retweeted,” and write simple requests like “create a user” and “create a tweet.” The easiest ways to try queries is to use the Gremlin Console or the REST calls.

The utility code supports three key features:

  1. Load schema – The schema importer reads the GraphSON schema document and writes it to JanusGraph. You can either run the Groovy script in the Gremlin Console or use sh with the loadsch option to load the schema by using the JanusGraph Java™ API.
  2. Generate data – The data generator takes a data model and generates a schema file, a few CSV files for graph data, and a data mapper file that defines the relationships between the graph schema and the contents in the CSV.
  3. Import data from CSV files – The CSV data importer imports graph data into JanusGraph by using a schema file, a mapper file, and typically data from a few CSV files. While the data generator can generate these files, you can also create them from scratch so you can use them for your particular data sets. To achieve full speed, the importer uses multiple workers to import the data. This is a good example of client apps using JanusGraph Java APIs to directly interact with the graph.

We also provide an architecture diagram and instructions that show you how to deploy and configure a distributed JanusGraph environment. However, the sample can run with all components on a single server or virtual machine so you can quickly see the graph system.

Building a graph database application is fun. Get started with our journey, run the Twitter sample, and check out the utility code. You’ll be able to develop your own applications in no time.

Please give us your feedback and consider code contributions to help make JanusGraph and the utility even better.

Join The Discussion

Your email address will not be published. Required fields are marked *