Giter Site home page Giter Site logo

entrepreneur-interet-general / graph-explorer Goto Github PK

View Code? Open in Web Editor NEW
27.0 19.0 11.0 29.34 MB

Graph Explorer

Home Page: https://graph-explorer.fr

License: MIT License

Python 20.30% JavaScript 16.21% CSS 1.93% HTML 0.47% Vue 53.52% Dockerfile 2.35% Groovy 5.06% Makefile 0.16%
entrepreneur-interet-general graph flask vuejs d3js fraud-detection network-visualization janusgraph gremlin python

graph-explorer's Introduction

Graph Explorer

Visualize and explore a large graph of money transactions.

architecture

Table of Contents

Architecture

  • JanusGraph 0.2.1
  • ScyllaDB 2.2.0 (storage backend for JanusGraph)
  • Elasticsearch 6.0.1 (index backend for JanusGraph)
  • Python Flask server
  • Vue.js
  • d3.js v4 force layout

architecture

Demo

Start exploring the graph from any node (e.g. with Amanda Walker) https://graph-explorer.fr

Installation

Prerequisites

  • Docker CE >= 1.13.0
  • docker-compose >= 1.10.0

Below is a step by step guide explaining how to install the app with sample data. If you want to run it with your own data, just replace the following files with your owns:

  • janus/data/nodes.csv
  • janus/data/links.csv
  • logstash/data/transactions.csv

Data directories for Elasticsearch and ScyllaDB will be mounted in the PROJECT_HOME/data.

The different services in the docker-compose setup need to be started in a specific order. wait-for-it.sh mechanisms (or alike) could be implemented in the future to allow running all the services in a one line command like docker-compose --build up.

Steps

  1. Clone the repository
> git clone  [email protected]:entrepreneur-interet-general/graph-explorer.git
> cd graph-explorer
  1. Download and build Docker images
> docker-compose build
  1. Create data directories
mkdir -p data/elasticsearch data/scylla
chown -R 1000:1000 data/elasticsearch
  1. Start Elasticsearch
> docker-compose up -d elasticsearch
  1. Wait for Elasticsearch to be available on port 9200
> curl localhost:9200/_cat/health
docker-cluster yellow 1 1 6 6 0 0 6 0 - 50.0%
  1. Start ScyllaDB
> docker-compose up -d scylladb
  1. Wait for ScyllaDB to be available
> docker-compose exec scylladb nodetool status
--  Address     Load       Tokens       Owns    Host ID                               Rack
UN  172.22.0.3  1.07 MB    256          ?       c961595a-ee52-4f94-baf3-74cdc5058af6  rack1
  1. Start JanusGraph
> docker-compose up -d janus

If a previous janus container has not been shut down correctly, you might get the following error:

A JanusGraph graph with the same instance id [*] is already open. Might required forced shutdown.

In this case you can run a cleanup script and then restart the janus container.

> docker-compose run --no-deps janus bin/gremlin.sh -e scripts/clean.groovy
  1. Wait for JanusGraph to be available on port 8182
> curl -XPOST -d '{"gremlin" : "1+1" }' localhost:8182
{"result":{"data":[2],"meta":{}}}
  1. Create the graph schema and load nodes and edges into JanusGraph (do it only the first time or after deleting the data directory)
> docker-compose exec janus bin/gremlin.sh -e scripts/create_schema.groovy
> docker-compose exec janus bin/gremlin.sh -e scripts/load_data.groovy
  1. Checks that nodes and edges have been loaded
> curl -XPOST -d '{"gremlin" : "g.V().count()" }' localhost:8182
{"result":{"data":[1606],"meta":{}}}

> curl -XPOST -d '{"gremlin" : "g.E().count()" }' localhost:8182
{"result":{"data":[2156],"meta":{}}}
  1. Load raw transactions into Elasticsearch (do it only the first time or after deleting the data directoy)
> docker-compose up -d logstash
  1. Check that transactions have been loaded in the transactions index
> curl localhost:9200/transactions/doc/_count
{"count":2156,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0}}
  1. Start the Flask server with Gunicorn
docker-compose up -d app

Development

Run the tests

  • Unit tests
make test_unit
  • Integration tests requiring ScyllaDB, Elasticsearch and Janus to be up and running with data loaded from steps 10 and 12
make test_integration

Flask server

  • Start Elasticsearch, ScyllaDB and JanusGraph with docker-compose as described in the installation steps.
  • Create a vitualenv for this project with Python version 3.6.0 or higher.
  • Install the dependencies
pip install -r requirements.txt
  • Run Flask in development mode. This will reload the server on code changes.
FLASK_APP=api.app.py FLASK_ENV='development' CONFIG='api.config.Development' python -m flask run

Frontend

  • Make sure to use a version of nodejs higher than 8.0.0. We recomand using nvm.
  • Install the dependencies
npm install
  • The project is built using webpack into the file local/build.js.
  • Build the source once with:
npm run build
  • Or watch for file changes with:
npm run watch

Visit http://localhost:5000 and start coding!

Credits

Please visit the Hopkins mission page for more information.

License

MIT License

Copyright (c) 2018 Ministère de l'Action et des Comptes Publics, Benoît Guigal, Paul Boosz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

graph-explorer's People

Contributors

benoitguigal avatar bzg avatar paulboosz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graph-explorer's Issues

groovy.lang.MissingPropertyException: No such property: JanusGraphFactory for class: groovysh_evaluate

Hi Benoît !

I can't really explain why but suddenly, after almost a year of working perfectly fine, this week, when trying to update the graph using the groovy scripts as every week, I got an error at the first line :

graph = JanusGraphFactory.open('conf/gremlin-server/janusgraph_cassandra_es.properties')

No such property: JanusGraphFactory for class: groovysh_evaluate
groovy.lang.MissingPropertyException: No such property: JanusGraphFactory for class: groovysh_evaluate
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at groovysh_evaluate.run(groovysh_evaluate:3)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.codehaus.groovy.tools.shell.Interpreter.evaluate(Interpreter.groovy:70)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:191)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.super$3$execute(GremlinGroovysh.groovy)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:72)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:124)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:83)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.apache.tinkerpop.gremlin.console.Console.(Console.groovy:166)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:478)

The workaround was to add this line just before
import org.janusgraph.core.JanusGraphFactory

I had to do it in the clean.groovy and load_data.groovy files. (You had it in create_schema.groovy but not the other ones). It took care of the error.

So I found the fix but I don't know why it started behaving like that just this week.
We haven't upgraded anything... just made a few changes in ElasticSearch configuration for optimisation purposes and restarted everything. Or maybe it is because I had to clear gremlin-server log in the meantime...

Regards
Delphine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.