Skip to content

A graph database service to store interactions between users

License

Notifications You must be signed in to change notification settings

forevertz/interact-db

Repository files navigation

InteractDB

This project is a simple service API to store interactions between users in a graph database.

license

Concepts

  • There are 2 types of nodes : Users and Contents.
  • You can add Interactions, which are links between a User and another User or a Content (for example (a:User)-[:LIKES]->(c:Content) or (a:User)-[:FOLLOWS]->(b:User))
  • You can also add Comments, which are a special kind of Content (for example (a:User)-[:COMMENTED]->(:Comment:Content { text: 'This is cool' })-[:ABOUT]->(c:Content), same with a User or another Comment)

Getting started

Development

$ git clone https://github.com/forevertz/interact-db.git
$ cd interact-db
$ yarn install
$ yarn run dev

Production

$ git clone https://github.com/forevertz/interact-db.git
$ cd interact-db
$ # Edit password in docker-compose.yml
$ docker-compose up -d
# Your API is now running locally on http://127.0.0.1:3000
# Recommended: install a reverse proxy to handle authentification and authorizations

API

  • GET /user: Get a User
  • POST /user: Add or update a User
  • POST /content: Add an Content linked to a User
  • POST /comment: Add a Comment on a User or a Content
  • POST /interaction: Add an Interaction between a User and another User or a Content

Examples

GET /user

$ curl http://127.0.0.1:3000/user?id=my-user-id-1

{
  "success": true,
  "result": {
    "user": {
      "name": "Alice",
      "created": 1534249561246,
      "id": "my-user-id-1"
    }
  }
}

# OR (if no result)
{
  "success": true,
  "result": null
}

POST /user

# Add Alice
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "id": "my-user-id-1", "name": "Alice" }' \
       http://127.0.0.1:3000/user

# Add Bob
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "id": "my-user-id-2", "name": "Bob" }' \
       http://127.0.0.1:3000/user

POST /content

# Alice adds Content
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-1", "id": "my-content-id-1", "type": "Article", "action": "SHARED", "url": "http://...", "text": "my content" }' \
       http://127.0.0.1:3000/content

POST /comment

# Bob comments Alice's Content
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-2", "id": "my-content-id-2", "aboutContentId": "my-content-id-1", "text": "Useful content, thanks Alice!" }' \
       http://127.0.0.1:3000/comment

# Alice comments Bob's comment
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-1", "id": "my-content-id-3", "aboutContentId": "my-content-id-2", "text": "Glad it helps." }' \
       http://127.0.0.1:3000/comment

# Bob adds a comment about Alice
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-2", "id": "my-content-id-4", "aboutUserId": "my-user-id-1", "text": "Alice is great!" }' \
       http://127.0.0.1:3000/comment

POST /interaction

# Bob likes Alice's comment on his comment
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-2", "toContentId": "my-content-id-3", "type": "LIKED" }' \
       http://127.0.0.1:3000/interaction

# Bob follows Alice
$ curl --request POST \
       --header "Content-Type: application/json" \
       --data '{ "userId": "my-user-id-2", "toUserId": "my-user-id-1", "type": "FOLLOWED" }' \
       http://127.0.0.1:3000/interaction

LICENSE

license

This project is based on neo4j, which is licensed under GPL v3.

About

A graph database service to store interactions between users

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published