Modeling in Neo4j Sans Programming

I have a bit of a problem.

Sometimes I have a hard time implementing a specific solution to a problem. Sometimes I think: “If I just took a step back, I could create a tool which anybody could use to do anything!” If I do it right, nobody will ever need to write a piece of software again!

I’m not there yet, but I’d like to announce a big step on my journey: neo4j-meta_model

neo4j-meta_model is a tool for managing Neo4j graph databases in Ruby on Rails apps. A big goal of the project is to create something which, while a very powerful tool for programmers, can also be used by non-programmers. This is such an important goal that I created a Rails app (creatively named neo4j-meta_model-app) which you need only to download, install, and run to set up a user-friendly interface for working with Neo4j databases.

What does it do?

neo4j-meta_model provides a web-based user interface for doing two things:

  • Defining the structure of your data in Neo4j
  • Browsing and managing your data

Defining the structure of your data

An administrative section is provided to allow users to define models and associations. Since the neo4j Ruby library’s ActiveNode is used behind the scenes, models and associations correspond to Neo4j’s nodes and relationships. A quick primer:

Models

Models correspond to Neo4j Labels which define entity tyes like User, Product, etc… For a model, you can define

  • Properties (such as name or price) with which we are concerned
  • Data validations and other business logic
  • Inheritance for when we want one model to have mostly the same properties as another

Currently neo4j-meta_model supports properties and inheritance but not validation or custom business logic.

Associations

Associations specify which nodes are related to a node under consideration. For example, if there are Person and Article models with a WROTE_ARTICLE relationship between them, one might define an articles association for the Person model and an author association for the Article model. In neo4j-meta_model, both associations are always defined at the same time.

To the right is the diagram which is shown when creating associations. The diagram represents a pair of associations and changes in real time as the pair of associations is defined. In this case it indicates a one-to-many relationship where:

  • the Song model has one artist
  • the Person model has many songs
  • there is a WRITTEN_BY relationship type in Neo4j which goes from Songs to People and it is used to find nodes for the associations

Browsing and managing your data

A `Gist` record with associated `UseCase` and `Domain` records

Once the database model has been established users can browse and edit the data itself. A simple CRUD interface is provided for records of the defined models. When a record is found all other records known via associations are displayed (see screenshot to the right which shows a Gist and it’s associated UseCases and Domains). When editing a record properties can be edited but associations can also be selected to create/destroy relationships. For has one relationships this is done via a simple drop-down, but for has many relationships an add/remove list interface is provided.

Try it!

I’ve deployed an instance of neo4j-meta_model-app at http://neo4j-meta-model-app.herokuapp.com/ so that you can play around with it. Let me know what you think and if you have any issues feel free to report them on the project page!

The Technical Stuff

neo4j-meta_model is a Rails engine, which means it is a Rails application inside a Rails application. It must be given a route inside the host rails application to provide the user interface for the Neo4j database. In the case of neo4j-meta_model-app, this is simply the root (‘/’) route.

The admin side of the engine is built as an Ember.js application, while the CRUD record management side is built with standard Rails server-side rendering (with a touch of Rivets.js and Backbone.js where needed)

The Future

The current version of this project is a bare bones starting point. Some things that I’d like to see in the near future:

  • Search, filtering, and pagination when browsing records
  • Permissions for the admin side as well as individual models
  • Visual data browsing (see Graph Visualization and Neo4j and The Last Mile)
  • Tools for running graph analytics metrics

2024

Let Your Database Update You with EctoWatch

Elixir allows application developers to create very parallel and very complex systems. Tools like Phoenix PubSub and LiveView thrive on this property of the ...

Back to Top ↑

2023

Back to Top ↑

2021

How Far Can I Push a GenServer?

I’ve been using Elixir for a while and I’ve implemented a number of GenServers. But while I think I mostly understand the purpose of them, I’ve not gotten t...

Why I Love Lodash

I love Lodash, but I’m not here to tell you to use Lodash. It’s up to you to decide if a tool is useful for you or your project. It will come down to the n...

Back to Top ↑

2020

Structuring an Elixir+Phoenix App

I’ve mix phx.new ed many applications and when doing so I often start with wondering how to organize my code. I love how Phoenix pushes you to think about th...

Back to Top ↑

2015

Analyzing Ruby’s ObjectSpace with Neo4j

Recently the continuous builds for the neo4j Ruby gem failed for JRuby because the memory limit had been reached. I wanted to see if I could use my favorite...

Master Data Management Scoring Examples

A while ago my colleague Michael suggested to me that I draw out some examples of how my record linkage algorithm did it’s thing. In order to do that, I’ve ...

Loading SQL to Neo4j Like Magic

When using neo4j for the first time, most people want to import data from another database to start playing around. There are a lot of options including LOA...

Back to Top ↑

2014

Analyzing Twitter with Neo4j and Rails

Having recently become interested in making it easy to pull data from Twitter with neo4apis-twitter I also decided that I wanted to be able to visualize an...

neo4apis

I’ve been reading a few interesting analyses of Twitter data recently such as this #gamergate analysis by Andy Baio. I thought it would be nice to have a ...

Normalizing Religion in Ireland

When I told the people of Northern Ireland that I was an atheist, a woman in the audience stood up and said, ‘Yes, but is it the God of the Catholics or t...

Back to Top ↑