Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.
/ Reserveon Public archive

Sample reactive Movie Ticket reservation system written in Scala on akka-http with slick, postgres and redis

License

Notifications You must be signed in to change notification settings

bugthesystem/Reserveon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reserveon

Sample reactive Movie Ticket reservation system

Build Status

Tech stack

Implemented Features:

  • 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

Commands

Run

⚠️ If you want to use docker-compose, you can skip manual steps.

Setup Postgres Database using Docker

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

Setup Redis using Docker

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/db
  • DB_PG_USER - db user
  • DB_PG_PWD - db password
  • DB_CREATE_SAMPLE_DATA - enable or disable to create sample data (credential, token etc)
  • REDIS_HOST - redis host
  • REDIS_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

Create executable

sbt packageBin

Test

sbt test

P.S Postman Rest Client collections also provided for manual testing in postman folder.

Coverage

sbt clean coverage test

To create coverage report

sbt coverageReport

Improvements / TODO

  • 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
    1. DB integration tests using embedded postgres or similar tool/lib
    2. Redis integration tests using embedded redis or similar tool/lib
  • 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 is true

ziλasal.

About

Sample reactive Movie Ticket reservation system written in Scala on akka-http with slick, postgres and redis

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages