Live El Dorado Demo

We consider how to build a read-only demo db from the manufactured data we collect in this site. github

# Docker

We'll start with a neo4j docker image, run a script to load the db with data from json files, then deploy the built db in a read-only configuration. github

FROM neo4j:3.1.5

We'll install various tools.

RUN apk --no-cache upgrade && \ apk --no-cache add curl jq WORKDIR / COPY . /

We will fetch json and import it into the running db using a shell script which takes a cypher script as its second argument.

# Configure neo4j for read/write COPY neo4j.write.conf /var/lib/neo4j/conf/neo4j.conf WORKDIR /var/lib/neo4j ENV PATH /var/lib/neo4j/bin:$PATH RUN neo4j start && \ sleep 15 && \ cat /var/lib/neo4j/logs/neo4j.log && \ echo ================================ && \ sh / organization-chart && \ sh / source-code-control && \ sh / dataflow-diagram && \ sh / service-traffic-reports && \ echo ================================ && \ neo4j stop # Configure neo4j for read-only COPY neo4j.conf /var/lib/neo4j/conf/

We disable the cache for all steps when only those after reading from the network should be repeated. There is technique to achieve this. stackoverflow

# Cypher

Michael Hunger shows that retrieving that data and ingesting it into Neo4j using Cypher is really straightforward and takes only little effort. post

Note: Michael shows a lightweight solution using bash instead of ruby. This might be a better approach to copying bits into Neo4j.

Our json is typically organized as an array of objects. We'll fetch each file and then pass them to a cypher query that will process each object.

WITH {json} as data UNWIND data as obj

Consider how this would work for the Organization Chart. Each object has a name, email and a manager identified by their email.


A careful reading of create and merge documentation indicates there could be more clever coding. neo4j

UNWIND {json} as props CREATE (e:EMPLOYEE) SET e = props

# Wiki

We collect data from various sources to be transformed and loaded into the graph database. We've designed a specification suitable for validating uploads. Experience shows that sources change continually and such validation may be the only notice of significant changes.

The Metamodel plugin could use the same specification to generate cypher commands for creating nodes and relations in the graph by the methods already shown. In this way one wiki page provides both the data to be stored and the cypher to store it.

For for now we add handcrafted cypher as code. Neo4j build from this information now available. local

With the domain specific part of this build reduced to a list of pages we now realize that is easily moved to a "Charmed" list in markdown that can be invoked through graph transport. github

GRAPH POST https://ward.local:3000/neo4j-build-run

Handcrafting cypher can be error prone with error messages mixed in with all the other docker build noise. If handcrafting is to be the norm, we should make a Cypher plugin that at least validates the text. There are modules to help. npm

# Explain

Our most recent script extracts more source information from the wiki page and passes it to cypher scripts as a second parameter, props, ready made for creating EXPLAIN nodes in the graph.

create (s:EXPLAIN {props})