Skip to content

Commit

Permalink
Benoitguigal patch 1 (#12)
Browse files Browse the repository at this point in the history
* update version in package.json

* Flask v1.0.2

* make Flask configurable based on FLASK_ENV

* update README with table of contents, credits and installation steps
  • Loading branch information
benoitguigal authored Sep 26, 2018
1 parent 1e9e6b6 commit 8907129
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 9 deletions.
67 changes: 62 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ Explore and find suspicious patterns in a large graph of money transactions.

![home](docs/img/home.png)

## Table of Contents

* **[Architecture](#architecture)**
* **[Demo](#demo)**
* **[Installation](#installation)**
* [Prerequisites](#prerequisites)
* [Steps](#steps)
* **[Development](#development)**
* [Flask Server](#flask-server)
* [Frontend](#frontend)
* **[Credits](#credits)**
* **[License](#license)**

## Architecture

* JanusGraph 0.2.1
Expand All @@ -11,6 +24,8 @@ Explore and find suspicious patterns in a large graph of money transactions.
* Python Flask server
* Vue.js
* d3.js v4 force layout

</br>
<img src="docs/img/architecture.png" alt="architecture" width="400px">


Expand All @@ -19,13 +34,13 @@ Start exploring the graph from any node (e.g with *Amanda Walker*)
[https://graph-explorer.fr](https://graph-explorer.fr)


## Prerequisites
## Installation

### Prerequisites

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

## Installation

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`
Expand Down Expand Up @@ -108,12 +123,54 @@ In this case you can run a cleanup script and then restart the `janus` container
> curl localhost:9200/transactions/doc/_count
{"count":2156,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0}}
```
* Start the app in the foreground
* Start the Flask server with Gunicorn
```
docker-compose up app
docker-compose up -d app
```
* Visit [http://localhost:5000](http://localhost:5000)

## Development

### 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=app.py FLASK_ENV='development' python -m flask run
```

### Frontend
* Make sure to use a version of `nodejs` higher than 8.0.0. We recomand using [`nvm`](https://github.com/creationix/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](http://localhost:5000) and start coding !

## Credits

<div align="center">
<a href="https://entrepreneur-interet-general.etalab.gouv.fr/">
<img src="docs/img/logo-eig.png" width="500px">
</a>
</div>

Please visit the [Hopkins mission](https://entrepreneur-interet-general.etalab.gouv.fr/defis/2018/hopkins.html) page for more information

## License

MIT License
Expand Down
10 changes: 8 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

application = Flask(__name__, static_folder="local")

es_host = 'elasticsearch'
# Set special config based on environment
if application.config['ENV'] == 'development':
application.config.from_object('config.DevelopmentConfig')
else:
application.config.from_object('config.ProductionConfig')

es_host = application.config['ELASTICSEARCH_HOST']
es = Elasticsearch(es_host, timeout=120, max_retries=10, retry_on_timeout=True)
index = 'transactions'

janus_host = 'janus'
janus_host = application.config['JANUS_HOST']
janus_server_url = 'ws://%s:8182/gremlin' % janus_host
statics.load_statics(globals())
graph = Graph()
Expand Down
10 changes: 10 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Config(object):
pass

class ProductionConfig(Config):
ELASTICSEARCH_HOST = 'elasticsearch'
JANUS_HOST = 'janus'

class DevelopmentConfig(Config):
ELASTICSEARCH_HOST = '127.0.0.1'
JANUS_HOST = '127.0.0.1'
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graph-explorer",
"description": "Explore and find suspicious activities in a graph of money transactions",
"version": "0.3.1",
"version": "0.4.0",
"author": "benoitguigal <[email protected]>",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
elasticsearch==6.3.1
Flask==0.12.3
Flask==1.0.2
gremlinpython==3.2.6
gunicorn==19.9.0
Binary file added docs/img/logo-eig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8907129

Please sign in to comment.