- Each log should generate a chart value
- Each log should be associated to a user
- Chart value must be within the range [0, 100]
- Chart value increases by 10 every hour, starting at 0 for each new day
- Logs will always arrive in chronological order, i.e. log date is strictly in ascending order
- Log date is in the format "YYYY-MM-DD HH:mm:ss Z"
- For each user per day, log
datetime
is unique - Utc offset in log date must be the same as user utc offset
- Chart value interval in 1 hour, i.e. chart value only increase on the hour, not part thereof
seed.json
: Contains user data that are seeded into the databasesrc/bin/www
: Server entry point in productionsrc/config
: Contain environment variables and other configurationsrc/controller
: Logic for handling API requestssrc/db/
: MySQL sequelize setupsrc/middleware
: Express middlewaressrc/routes
: API routessrc/seed/
: Seed users into databasesrc/service
: Handles the main business logicsrc/type
: Type definitionssrc/util
: Utilitiessrc/validator
: Validator API request parameterstest/
: Contains unit tests and integration testsapp.ts
: Express server configurationserver.ts
: Server entry point in development
- Install docker: https://docs.docker.com/get-docker/
- Install docker compose: https://docs.docker.com/compose/install/
- Clone project:
git clone https://github.com/hanchiang/performance-labs.git
- Rename
.env.sample
to.env
,.env.test.sample
to.env.test
- Start MySQL:
docker-compose up -d mysql
, createanalytics
andanalytics_test
database, and create the tables usingsrc/db/schema.sql
- Start:
docker-compose up -d
- Generate users:
npm run build && node dist/seed/seed.js
- Stop:
docker-compose down
- Unit tests:
npm run test-unit
- Integration tests:
npm run test-integration
- All tests:
npm run test