scala-play-car-advert
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
-
Build docker containers for dynamoDB and SBT by running docker-compose build
-
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
-
API can be tested through the Swagger UI endpoint. Local DynamoDB provides a shell UI as well to query DB directly
Tests:
- [x] There are unit tests for the main Model classes / Storage service.
- [x] 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)
- [x] Tagged commits merged to master generate a GitHub release with the Scala jar
- [x] Production app runs on Heroku, with database running on AWS DynamoDB
Task Goals
Service should:
- [x] 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
- [x] have functionality to return data for single car advert by id;
- [x] have functionality to add car advert;
- [x] have functionality to modify car advert by id;
- [x] have functionality to delete car advert by id;
- [x] have validation (see required fields and fields only for used cars);
- [x] accept and return data in JSON format
- [x] Service should be able to handle CORS requests from any domain.
- [x] do not use GlobalSettings or any globals like Play.configuration or Play.application, use dependency injection instead.