The project is split in two, the backend and the frontend. This means that you have to do the setup for both of them.
app
- Frontend appsrc
- Backend serverscripts
- Scripts for general purposetest
- All unit tests
Docker:
- Install and run docker
- Run
docker-compose up mongo -d
to start the mongo database - Run
docker-compose up redis -d
to start the redis database
Server:
- Use node version equal or greater than 16.10.0
- Install dependencies with
npm install
- Run
npm run start:server
to start the server - In another terminal tab, run
npm run start:worker
to start the worker. This is needed for the job queue to work. - Run the seed script with
node scripts/seedDb.js
to seed the database with some dummy data. - Runs tests with
npm run test
- Use node version equal or greater than 16.10.0
cd app
- Install dependencies with
npm install
- Run
npm start
- You can also run the app from the root folder with
npm run start:app
The server follows a layered architecture. It contains controllers, services, models. Aside from the standard back-end that handles request, responses and server needs we also have a background job worker.
The worker is backed by BullJs. When the server receives a schedule request, it will enqueue a job in the queue. The worker will then pick up the job and execute it. This is useful for tasks that take a long time to complete, like sending emails or processing images.
As for the front-end, is a very simple React app. It uses hooks and lets the user schedule a journey start for a given user and a given time.
- Move all DB queries to a repository layer. It it will make testing easier and it will decouple the business logic from the DB.
- Create a generic queue factory function that contains all the logic for creating a queue. It will abstract the lib we use for the queue and make it easier to switch to another one. The interface would be the same.
- Improve step failure handling. Right now, if a step fails, the promise fails silently. We should add a retry mechanism and a way to handle the failure.