An example project using a couple of NestJS microservices with an React frontend app. Redis is used as a read database and also acts as the message broker for the pub/sub communication between the microservices. All the events are persisted into a PostgreSQL database.
- Responsible for the management of orders
- Each order can only be at a single state at a time
- Order states: created, confirmed, delivered, cancelled
- Once an order is created, the order app publishes an event which is subscribed by the payment app to process a payment for the order
- If the payment of the order is declined, the order is set to cancelled
- If the payment of the order is confirmed, the order is set to confirmed
- After X amount of seconds a confirmed order is automatically set to delivered
- Has endpoints to do the following:
- view all orders
- create an order
- cancel an order
- tracking order status
- Responsible for payment processing
- Each order is handled by the payment app by setting the payment of the order to confirmed or declined based on random logic
- Each payment is persisted into its own table in the PostgreSQL database
- Once a payment is processed, the payment app publishes an event which is subscribed by the order app to continue with order processing
- A user of the client app can do the following:
- view list of orders
- view the details of an order
- create an order
- cancel an order
- Implements socket listening message from server
Copy the file .env.example and set each environment variable accordingly.
$ cp .env.example .env
$ yarn start:order
$yarn start:payment
$yarn start:client
cd ./setel-assignment
docker compose build
docker compose up