A simple lottery system, based on cats-effect
, http4s
, circe
, tapir
, and doobie
.
Use a containerized PostgreSQL
database as a storage.
GET docs/
POST /principals
Return a UUID
to use a bearer token to identify yourself.
POST /lotteries/{lotteryId}/ballot
Need a UUID
as a bearer token to authenticate yourself.
Return 201
if successful, 403
if the lottery is closed.
GET /lotteries
Return a list of lotteries, accept endDate=year-month-day
or status=closed | open
as query param to filter the results.
POST /admin/lotteries
Need the ApiKey
as a bearer token to authenticate yourself.
Take a date in the ISO-8601 format (year-month-day
) as Json string in input.
Return 201
if successful.
PUT /admin/lotteries/{lotteryId}/close
Need the ApiKey
as a bearer token to authenticate yourself.
Return 200
if successful, 403
if the lottery is closed
or there are no ballots for the lottery.
In order to identify yourself as admin you need the environment variable API_KEY
.
By default, is read from the .env
file but if the variable is invalid or not found
the system generate a one time ApiKey
for the session.
Use the .data/
folder as permanent storage.
docker compose up
sbt run
Run both tests and integration test.
sbt test