This repository contains a set of microservices for managing the order process. The system is composed of four services: order-service, customer-service, stock-service, and saga-coordinator.
The order process microservices provide a distributed architecture for handling the order placement, payment processing, and inventory management. It follows the saga pattern for managing long-lived transactions that span multiple services.
- RabbitMQ - https://www.rabbitmq.com/
- PostgreSQL - https://www.postgresql.org/
The order-service is responsible for handling the order placement. It provides APIs for creating new orders, retrieving order details, and updating order statuses. This service communicates with the customer-service and the saga-coordinator to coordinate the order processing.
The customer-service handles the payment processing for the orders. It integrates with external payment gateways to authorize and process payments. Upon successful payment, it notifies the saga-coordinator about the payment status.
The stock-service manages the inventory levels for the products. It provides APIs for updating the available stock quantity and retrieving the current stock status. The saga-coordinator communicates with this service to verify the availability of stock before processing an order.
The saga-coordinator is the central orchestrator of the order processing workflow. It coordinates the interactions between the order-service, customer-service, and stock-service to ensure the consistency of the order process. It handles compensating actions in case of failures or inconsistencies during the transaction.
Install dependencies for root.
npm install
Install service deps
npm run service-install
Build services
npm run build
Start services in development mode
npm start
start services in production mode
npm run start:prod
Build docker-compose images
docker-compose up --build
Contributions are welcome! If you want to contribute to this project, please follow these steps:
- Fork this repository.
- Create a new branch:
git checkout -b my-new-feature
. - Make your changes and commit them:
git commit -am 'Add some feature'
. - Push the changes to your fork:
git push origin my-new-feature
. - Submit a pull request.