Skip to content
An experiment in representing an organisations structure in a GraphDB
Python HTML Shell
Branch: master
Clone or download
Latest commit 9096817 Aug 21, 2019


An experiment in representing an organisations structure in a GraphDB

Getting started

To try out the organisation graph you'll need a neo4j instance, which I'm going to run via docker, and a working python 3 install with some additional modules.

First we'll set our chosen Neo4j password and install the Neo4j container. By default this will place the persistent Neo4j server files under $HOME/python-neo4j. You can change this by editing the bin/ script before running it.

export ORG_GRAPH_NEO_PASSWORD=my_test_pass

$ bin/
0d45567uhdfdthae4731b8fc74sdff20g44740e32888ac5bd2d6438eba1d8a4d0f22e # Container ID

You can confirm the container is running with docker ps and the container ID returned by our bash script above.

Now we have the server running we will install the python environment used to load data into it. I'm using python 3 and a venv to ensure this experiment stays isolated.

# Create the python venv
$ python3 -mvenv venv

# Active it
$ source venv/bin/activate

# Install the required modules
$ pip install -r requirements.txt
Successfully installed ...snip... py2neo-4.3.0 pyyaml-5.1.1 ...snip...

Dependencies done you can now run python3 from the shell you activated the venv in and exported the Neo4J password. Once this has completed, open a web browser to, login and run a query to show all results:

MATCH (n) return n

You should now see all the nodes and relationships you've created and be able to explore the data.

A Graph screenshot

Example Queries

This repo includes a collection of sample queries that give examples of the syntax and shows some of the possibles. You can also see a few inline examples below

Show the services and which teams own them as a table:

MATCH (s:Service)-[:`owns`]-(t:Team)
RETURN as Service, as Team

Table of service names and the teams that own them

Or as a pretty graph

MATCH (s:Service)-[:`owns`]-(t:Team)
RETURN s as Service, t as Team

Show all the people in the team that owns a service. This can be handy for finding people to help you in an incident.

MATCH (s:Service {name: 'Prison 42'})-[:`owns`]-(t:Team)
MATCH (t:Team)-[:`assigned to`]-(p:Person)
RETURN as Service, as Owners

Data and data formats

The example data I've included under data is the bare minimum required to have a graph you can click around and run some interesting queries over. If you want to add your own data the current formats are:

Data formats - Staff

The individual staff entries should look like this:

FirstName LastName:
    - Team-1
    - Team-2
  is_a: 'Role title'
  - FirstName LastName 1
  - FirstName LastName 2
  - FirstName LastName 3
  member_of: 'Department Name'

and a worked example:

Malcolm Reynolds:
    - Serenity
  is_a: 'Captain'
  - Kaylee
  - Wash
  - Jayne Cobb
  member_of: Independents

It's worth noting nearly every element is optional.

Data formats - Services

  - ServiceName:
      owner: 'Team Name'

An example with less abstract values:

  - Cerebro:
      owner: 'X-Men'
  - 'Danger Room':
      owner: 'X-Men'


This graph is all based on here and now. There are no date relationships available, such as looking up the line manager six months ago.


Dean Wilson


  • Released under the GPLv2
You can’t perform that action at this time.