family-playground

Proof of concept for a REST-full service using Scala/Play, Elasticseach and Couchbase.

View on GitHub

Family playground

Proof of concept for a REST-full service using Scala/Play, Elasticseach and Couchbase.

family-rest service

This service maintains people’s registration and the registered relations between people. People can be registered by posting data to the /people end-point. For example:

curl -H 'Content-Type: application/json' -X POST -d '{ "id" : "d6932481-dbda-4dec-aca8-68d1466b98f2", "name" : "P1" }' http://localhost:9000/people

People can be retrieved also using:

curl http://localhost:9000/people/d6932481-dbda-4dec-aca8-68d1466b98f2

In order to register a relation between two people:

curl -H 'Content-Type: application/json' -X POST -d '{ "toId" : "86dfdab4-8ccc-4eb6-8fb7-9fc1592158b4", "relationType" : "Friends" }' http://localhost:9000/people/d6932481-dbda-4dec-aca8-68d1466b98f2/relatedto

And a family/relation graph can be accessed as:

curl http://localhost:9000/people/d6932481-dbda-4dec-aca8-68d1466b98f2/familytree

For more API documentation please take a look at ./family-rest/README.md

Technology decisions

Here are some reason why the current technology stack was chosen:

Data storage configuration

The Couchbase instances and Elasticsearch instances the family-rest service use should be configured on the file ./family-rest/conf/application.conf on the following sections:

# Couchbase
couchbase {
  akka {
    timeout=1000
    execution-context {
      fork-join-executor {
        parallelism-factor = 4.0
        parallelism-max = 40
      }
    }
  }
  buckets = [{
    host="192.168.99.100"
    port="8091"
    base="pools"
    bucket="default"
    user=""
    pass=""
    timeout="0"
  }]
}

# Elasticseach
elasticseach.urls="elasticsearch://192.168.99.100:9300"

In above example the service is configured to talk to one instance of each server only, but both libraries has the ability to configure more than one instance for resiliency. The IP address in use there is the IP address returned from:

docker-machine ip default

Containers setup

This PoC use Docker to create instances of Elasticsearch and Couchbase for the family-rest service to access. The setup scripts on ./Setupscripts will help to create and configure an Elasticseach instance and Couchbase instance. The scripts assume docker, and docker-machine is installed locally, but they could be modified to run on another environments easily.