Eldorado

Eldorado is a project to graph cool things with / related to wiki - using Neo4j, Graphviz, and integrating code written by Ward Cunningham. See github

strict digraph { rankdir=LR node [shape=box style=filled, fillcolor=palegreen] "dogs" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=dogs"] "movies" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=movies"] "movies" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=movies"] "movies" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=movies"] "movies" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=movies"] "movies" [shape=plaintext fillcolor=white URL="http://localhost:9292/schema_with_sources?source=movies"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Person" [URL="http://localhost:9292/schema_with_sources?label=Person"] "Movie" [URL="http://localhost:9292/schema_with_sources?label=Movie"] "Movie" [URL="http://localhost:9292/schema_with_sources?label=Movie"] "Movie" [URL="http://localhost:9292/schema_with_sources?label=Movie"] "Movie" [URL="http://localhost:9292/schema_with_sources?label=Movie"] "Movie" [URL="http://localhost:9292/schema_with_sources?label=Movie"] "PersonFOLLOWSPerson" [label="FOLLOWS" shape=plaintext fillcolor=white] "PersonACTED_INMovie" [label="ACTED\nIN" shape=plaintext fillcolor=white] "PersonPRODUCEDMovie" [label="PRODUCED" shape=plaintext fillcolor=white] "PersonDIRECTEDMovie" [label="DIRECTED" shape=plaintext fillcolor=white] "PersonWROTEMovie" [label="WROTE" shape=plaintext fillcolor=white] "PersonREVIEWEDMovie" [label="REVIEWED" shape=plaintext fillcolor=white] "Person" -> "PersonFOLLOWSPerson" "Person" -> "PersonACTED_INMovie" "Person" -> "PersonPRODUCEDMovie" "Person" -> "PersonDIRECTEDMovie" "Person" -> "PersonWROTEMovie" "Person" -> "PersonREVIEWEDMovie" "PersonFOLLOWSPerson" -> "Person" "PersonACTED_INMovie" -> "Movie" "PersonPRODUCEDMovie" -> "Movie" "PersonDIRECTEDMovie" -> "Movie" "PersonWROTEMovie" -> "Movie" "PersonREVIEWEDMovie" -> "Movie" "dogs" -> "PersonFOLLOWSPerson" [style=dotted arrowhead=none label=3 fontcolor=gray URL="http://localhost:9292/sample_relations?source=dogs&type=FOLLOWS&from=Person&to=Person&count=3&regex=.*"] "movies" -> "PersonACTED_INMovie" [style=dotted arrowhead=none label=172 fontcolor=gray URL="http://localhost:9292/sample_relations?source=movies&type=ACTED_IN&from=Person&to=Movie&count=172&regex=.*"] "movies" -> "PersonPRODUCEDMovie" [style=dotted arrowhead=none label=15 fontcolor=gray URL="http://localhost:9292/sample_relations?source=movies&type=PRODUCED&from=Person&to=Movie&count=15&regex=.*"] "movies" -> "PersonDIRECTEDMovie" [style=dotted arrowhead=none label=44 fontcolor=gray URL="http://localhost:9292/sample_relations?source=movies&type=DIRECTED&from=Person&to=Movie&count=44&regex=.*"] "movies" -> "PersonWROTEMovie" [style=dotted arrowhead=none label=10 fontcolor=gray URL="http://localhost:9292/sample_relations?source=movies&type=WROTE&from=Person&to=Movie&count=10&regex=.*"] "movies" -> "PersonREVIEWEDMovie" [style=dotted arrowhead=none label=9 fontcolor=gray URL="http://localhost:9292/sample_relations?source=movies&type=REVIEWED&from=Person&to=Movie&count=9&regex=.*"] }

This is the ui that can query neo4j and render results in dot. https://github.com/WardCunningham/el-dorado-ui This repo includes some of my favorite queries. This query selects 1% of the nodes and draws the links between them using node labels to stand for all of the nodes with that label. https://github.com/WardCunningham/el-dorado-ui/blob/master/config/queries.yml#L12-L33

This is the ruby code that translates a cypher result to a dot diagram based on the template provided along with the query. Gethub

def dotify template columns = @results.first.members output = [] add_base_to_urls(template).lines.each do |line| line = line.gsub(/&/, '&amp;') # http://www.graphviz.org/doc/info/lang.html if (keywords = columns.select {|key| line.include? "{#{key}}"}).any? @results.each do |row| next unless keywords.all? {|key| row[key]} buffer = line.dup keywords.each do |key| buffer = interpolate_kv(buffer, key, row[key]) end output << buffer end else output << line end end output.join("\n") end

# El Dorado UI This is a Sinatra app that provides a UI and canned queries for El Dorado, an enterprise structure warehouse. The web user can retreive results from a menu of queries or author new ad-hoc queries interactively. Results are in the form of tables or diagrams both of which can hyperlink to related queries. Queries are written in Neo4j's Cypher language. Tabular results are then optionally rendered by template expansion into Graphviz's Dot language and displayed as SVG. Modeling conventions support tracing relations to their ETL source, but the graph database is not otherwise restricted. ![system diagram](images/system-diagram.png?raw=true) Learn more about this project at http://ddd.ward.wiki.org/ ## Running Locally To get this app running locally: ~~~ gem install bundler bundle install bundle exec rackup ~~~ You can then visit the app at http://localhost:9292 We assume the `dot` command is available from [Graphviz](http://www.graphviz.org/). If you are not running your own instance of Neo4J locally, you'll need to alter the database connection string with the GRAPHDBURL environment variable. ~~~ GRAPHDBURL='http://neo4j:neo4j@example.com:7474/' bundler exec rackup -o '0.0.0.0' ~~~ ## Docker version Use `Dockerfile` and `build-docker-image.sh` to build a docker image. The `run-with-neo4j.sh` runs it with a connection to a local neo4j instance. To run a local neo4j database, you can use docker: ``` docker run --name neo4j --rm -d --publish=7474:7474 --publish=7687:7687 -e NEO4J_AUTH=neo4j/neo4j1234 --volume=$HOME/neo4j/data:/data neo4j:3.5 ```