Skip to content

inakianduaga/scala-play-car-advert

Repository files navigation

scala-play-car-advert

Build Status Coverage Status

Scala Play Restful example app w/ AWS DynamoDB integration

This is a small exercise app to demonstrate integration of a Restful service w/ AWS DynamoDB using the Scala Play framework

Interacting with production app

Use the Swagger UI official-hosted client to test the Rest application in production. This is the Swagger specification of the REST API used by the client

Local Setup

The entire application is dockerized and can be run locally easily w/ minimal dependencies.

Requirements:

Docker, Docker Compose must be installed

Installation:

From the ./docker folder

  1. Build docker containers for dynamoDB and SBT by running docker-compose build

  2. Spin up Play app & DynamoDB: docker-compose up -d (first run will take a while because SBT needs to populate the cache). App will be reachable on http://localhost:9000

  3. API can be tested through the Swagger UI endpoint. Local DynamoDB provides a shell UI as well to query DB directly

Tests:

  • There are unit tests for the main Model classes / Storage service.
  • Code coverage is generated automatically on Travis and sent to Coveralls for tracking changes / history
  • Currently no integration test (those could be generated by using the Swagger auto-generated client)

Deployment

Travis CI is used for building and deploying the application on production (also runs tests on PR/Commit/Merges)

  • Tagged commits merged to master generate a GitHub release with the Scala jar
  • Production app runs on Heroku, with database running on AWS DynamoDB

Task Goals

Service should:

  • have functionality to return list of all car adverts;
  • optional sorting by any field specified by query parameter, default sorting - by id; This was only partially implemented due to lack of time, currently sorts by id only
  • have functionality to return data for single car advert by id;
  • have functionality to add car advert;
  • have functionality to modify car advert by id;
  • have functionality to delete car advert by id;
  • have validation (see required fields and fields only for used cars);
  • accept and return data in JSON format
  • Service should be able to handle CORS requests from any domain.
  • do not use GlobalSettings or any globals like Play.configuration or Play.application, use dependency injection instead.