- Introduction
- System Overview
- Microservice 1 - Order Management Service
- Microservice 2 - Inventory Service
- System Workflow
- Use Cases 3. Order Processing
- API Documentation
- Deployment and Scalability
- API Documentation
- Conclusion
- Java 8 or later
- Node.js 16 or later
- Docker
- Docker Compose
-
From the root directory, build the docker images for the two microservices running the following command:
docker-compose build -t order-processing-system .
-
Run the application using the following command:
docker-compose up
-
The application will be running on
http://localhost:8080
The Order Processing System for E-commerce is designed to facilitate seamless order creation, modification, and processing for an e-commerce platform. This documentation provides an in-depth understanding of how the system functions, the roles of the two microservices involved, and key use cases.
The system consists of two microservices:
- Microservice 1 - Order Management Service
- Microservice 2 - Inventory Service
- Handle order creation, modification, and processing.
- Communicate with the inventory service.
- Expose RESTful APIs for order creation and management.
- Publish order events to Kafka for downstream processing.
- Manage inventory levels and product availability.
- Communicate with the order management service
- Consume order events from Kafka for inventory updates.
- Publish inventory events to kafka if inventory levels are low, or if products are out of stock
- Publish inventory events to the OMS when updates are made to inventory levels
- Customers place orders through the e-commerce platform - through a web application, mobile app, or other means (authentication and authorization services are not covered in this documentation)
- Microservice 1 creates orders and publishes order events the inventory service through Kafka
- Microservice 2 listens for order events, updates inventory, and coordinates communicate with the order management service - when inventory levels are low, or if products are out of stock, inventory events are published to Kafka - when the inventory updates are complete, inventory events are published to the order management service so order statuses can be updated - notification services are not covered in this documentation
- Microservice 1 receives inventory events and updates order statuses accordingly
- Each service has internal opertations that don't trigger events - for example, Microservice 1 may update order statuses when payment is processed, or Microservice 2 may update inventory levels when new products are added to the system
- Product service, authentication / user service, and notification service are not covered in this documentation
- Inter-service communication is handled through Kafka if the business logic requires it we can add an SSL encryption layer to the Kafka cluster to ensure data security
- Microservice 1 receives order requests and creates orders.
- Order events are published to Kafka for downstream processing.
- Microservice 2 consumes order events, manages inventory, and coordinates back with Microservice 1.
- Microservices can run, be sca, and be deployed independently
- A customer selects products and initiates an order - Note that in a single order, we can have multiple products, and each product can have multiple quantities - we check and update orderItem status for each product upon order creation and inventory updates - default status is
PENDING
can beCANCELED
if the inventory update fails orEXECUTED
if the inventory update is successful - Microservice 1 creates an order and publishes an order event to Kafka.
- Microservice 2 updates inventory levels.
- Microservice 2 publishes inventory events to Kafka.
- Microservice 1 receives inventory events and updates order statuses accordingly.
Detailed API documentation for Microservice 1 and Microservice 2 can be found in separate documents. These APIs cover order creation, modification, retrieval and inventory management
The system can be deployed in a containerized environment with orchestration (e.g., Docker and Kubernetes) to ensure scalability and high availability. Microservices can be replicated horizontally to handle increased loads.
POST oms/orders
- Create a new order- Body
userId
- ID of the customer who placed the orderorderItems
- List of order itemsproductId
- ID of the productquantity
- Quantity of the product
- Response
- success -
true
if the order was created successfully - data - the order object
- error - error message if the order creation failed
- success -
- Body
GET oms/orders/{orderId}
- Get an order by order IDPUT oms/orders/{orderId}
- Update an order by order ID - can be used to update order status- Body
status
- new status of the order- (optional)
orderItems
- list of order items to be updatedproductId
- ID of the productquantity
- Quantity of the productstatus
- new status of the order item
- Response
- success -
true
if the order was updated successfully - data - the order object
- error - error message if the order update failed
- success -
- Body
Listens to order events from Kafka and updates inventory levels accordingly
The Order Processing System for E-commerce provides a robust solution for efficient order management and processing. The collaboration between Microservice 1 and Microservice 2 enables seamless order handling and inventory management
This documentation serves as a comprehensive guide to understanding the system's architecture, functionalities, and key use cases, demonstrating how the two microservices work together to deliver a reliable and responsive e-commerce order processing system.