Giter VIP home page Giter VIP logo

graph-service's Introduction

Graph-service

This is a service that provides a REST API (according to the HAL+JSON specification) against which you can create and query nodes and relationships in a graph.

The service uses neo4j version 3.5 internally to store data.

There is also a small client, that implements a (very poor) algorithm to calculate the shortest path between two nodes using the API. The algorithm is naively implemented and will not take edge cases and circular dependencies into consideration (with more time I would have adapted a proper algorithm such as Dijkstras).

To run the tests

First start a neo4j database using Docker:

docker run \
     --name testneo4j \
     -p7474:7474 -p7687:7687 \
     -d \
     -v $HOME/neo4j/data:/data \
     -v $HOME/neo4j/logs:/logs \
     -v $HOME/neo4j/import:/var/lib/neo4j/import \
     -v $HOME/neo4j/plugins:/plugins \
     --env NEO4J_AUTH=neo4j/test \
     neo4j:3.5

Then run tests by running lein test

The tests use the open source library halboy https://github.com/jimmythompson/halboy to traverse the API and its resources.

To run the service

First start a neo4j database using Docker:

docker run \
     --name testneo4j \
     -p7474:7474 -p7687:7687 \
     -d \
     -v $HOME/neo4j/data:/data \
     -v $HOME/neo4j/logs:/logs \
     -v $HOME/neo4j/import:/var/lib/neo4j/import \
     -v $HOME/neo4j/plugins:/plugins \
     --env NEO4J_AUTH=neo4j/test \
     neo4j:3.5

Then run lein run

The service will be available under http://localhost:1234

The API (mostly) conforms to the HAL+JSON specification so it's partially self-documenting and explorable.

Nodes require a JSON body but only optionally takes decorative fields under the key propeties, for example:

{
  "properties": {
    "someField": "someValue"
  }
}

Relationships require the fields from, to, type and optionally takes additional fields under the key propeties, for example:

{
  "from": "<SOME_NODE_ID>",
  "to": "<SOME_OTHER_NODE_ID>",
  "type": "friend",
  "properties": {
    "someField": "someValue"
  }
}

Due to time constraints there is no validation added and currently the running service and the component tests use the same underlying database, which of course you wouldn't do on an actual production service.

graph-service's People

Watchers

 avatar

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.