Public | Automated Build

Last pushed: 2 years ago
Short Description
Automated build for experiece layer poc microservice
Full Description

Experience Layer Service

Project showcasing an implementation of Option 3 of the experience layer.

Use Case

At the moment the web team has to traverse the Sports API hierarchy to get the information required to render the in-play pages. This basic information, which is three levels deep, results in a multiple calls to the core service, increase as the number of live events increases. This situation causes page load to slow down.


The experience layer contract has been defined using the RAML 0.8 spec and published to Anypoint accesible on the WebXL API Portal. It exposes the following endpoints:

  1. /v1/inplay/summary
    • Retrieves live event information. The implementation has logic to invoke Sports API to retrieve sport, competition and event information. This results in multiple calls to the underlying service but consolidates them into a sigle response to the client (i.e. web channel).
  2. /v1/inplay/detail/{eventid} [in progress]
    • Retrieves live event detail information (i.e. markets for the event)

The service has been implemented using Node.js as its event-driven non-blocking features are well suited to implement a lightweight experience layer.


The service currently runs standalone but a Docker image has also been created. The experience-layer-poc image has been published to DockerHub. Scalability is planned to be achieved leveraging Docker Swarm clustering capabilities.

The container can be launched running the below command. It will fetch the image from Dockerhub and launch the service listening on port 8000 of the docker host.

$ docker run --rm -p 8000:8000 -e NODE_ENV=uat -e PORT=8000 redlumxn/experience-layer-poc
  • --rm removes the container once it is stopped.
  • -p publishes port 8000 to the docker host
  • -e sets environment variables for the container app. In this case the environment to hit and the listening port


The node implementation relies on the following dependencies:

  • Express - Node.js web framework framework.
  • Osprey - generates Express API middleware from RAML definitions.
  • Unirest - http library used for calling the core sports service API.
  • MounteBank - Provides backends stubs required for unit testing the service.
  • Grunt - Task runner used for linting and (more importantly) spin up Mountebank stub and Mocha tests.

Running locally

# Install dependencies required and listed in the packages.json file
$ npm install

# Install grunt-cli globally to be able to run grunt from anywhere
$ sudo install -g grunt-cli

# Start Mountebank Sports API Stub (stub/imposter listens on port 4545, admin console on http://localhost:2525)
$ grunt startStub

# Stop Mountebank Sports API Stub
$ grunt stopStub

# Start the server (defaults to port 3000 unless PORT env var is set)
# NODE_ENV determines which sports API instance to call. Values: development (default if not present), sit, uat and production
# If running it in development mode mountebank stub needs to be started. 
$ NODE_ENV=uat npm start 

# Run unit (mocha) tests (spins up Mountebank Sports API stub first)
$ grunt test

Docker Pull Command
Source Repository