Sample reactive Movie Ticket reservation system
- OAuth2 support (client_credentials, password, refresh_token flows)
- CORS support
- Movie & Reservation CRUD
- Simple reservation mechanism using Redis ( without distributed lock mechanism see: Improvements section )
- Database schema migration
- Route tests
docker-compose
, you can skip manual steps.
Run Postgres container
It will create database and user
docker run --name pg-reserveon -itd --restart always \
--publish 65432:5432 \
--env 'PG_PASSWORD=passw0rd' \
--env 'DB_USER=reserveonUser' --env 'DB_PASS=s3cret' --env 'DB_NAME=reserveon' \
sameersbn/postgresql:9.6-2
To Run redis container;
docker run --name redis-reserveon -d -p 6379:6379 redis
Environment variables
DB_PG_URL
- db url by scheme jdbc:postgresql://host:port/dbDB_PG_USER
- db userDB_PG_PWD
- db passwordDB_CREATE_SAMPLE_DATA
- enable or disable to create sample data (credential, token etc)REDIS_HOST
- redis hostREDIS_PORT
- redis port
Sample run command
DB_PG_URL=jdbc:postgresql://localhost:65432/reserveon \
DB_PG_USER=reserveonUser \
DB_PG_PWD=s3cret \
DB_CREATE_SAMPLE_DATA=true \
REDIS_HOST=localhost \
REDIS_PORT=6379
sbt run
Sample run command using docker link
to posgtres
and redis
using local application image
docker run --name api \
-e DB_USER=reserveonUser -e DB_PASSWORD=s3cret \
-e DB_NAME=reserveon -e DB_CREATE_SAMPLE_DATA=true \
--link pg-reserveon:database \
--link redis-reserveon:redis \
-d -p 9001:9001 ziyasal/reserveon
OR
Run docker-compose
, it will start api
, redis
and postgres
and will expose api port to host.
docker-compose up
sbt packageBin
sbt test
P.S Postman Rest Client collections also provided for manual testing in postman
folder.
sbt clean coverage test
To create coverage report
sbt coverageReport
- Store refresh tokens in cache (e.g redis) to decrease load on DB
- Produce better error/validation messages from API
- API Documentation using swagger or similar tool/lib
- Persist reservation data to DB to use for reports etc later on (currently stored in Redis)
- Serve data as paged and implement data caching (implement cache invalidation etc)
- Implement distributed locking mechanism for reservations (zookeeper, redis, custom etc)
- Integration Testing
- DB integration tests using
embedded postgres
or similar tool/lib - Redis integration tests using
embedded redis
or similar tool/lib
- DB integration tests using
- Use JWT authentication protocol with OAuth2 authentication framework
- Implement account CRUD routes (logic currently implemented and
sample data seed uses it to create test user/s on startup if
DB_CREATE_SAMPLE_DATA
istrue
ziλasal.