- You need to have
NodeJS(AdonisJS needsNode.js >= 20.6) - Docker
- Clone the repo with
git clone
In the root folder in terminal: - Run
npm installto install dependencies - Run Docker and then run
docker-compose up -dto run containers (redis,mysql,phpmyadmin) - Run
npm run devto start server - Run
node ace migration:runandnode ace db:seedto run migrations and to seed
To see routes run node ace list:routes or look into start/routes.ts
To run tests run node ace test
Luxon(time library) andVineJs(validation) are acting weird when working with ISO 8601 date format. I think its a bug. But this is the reason you will see some weird conversion in the code base as well as some weird types.- There are only tests for get sleep entries, login, register and get stats. I didnt want to write tests for all of the endpoints as this is purely showcase project. This includes unit tests.
- I have stored only current week averages. But of course it is possible to store previous week averages in the DB and then pull them directly from DB. This of course introduces some complexity if previous sleep entries can be updated or delete because we need to recalculate those previous averages.
- Speaking of recalculating averages, if any current week sleep entry is deleted or updated I am recalculating entire week average from DB. This can of course can be optimized.
- There are multiple places that can be further optimized but it depends on project direction/C-level decisions.