This project simulates an e-commerce-style distributed system that decouples order creation, processing, and status management. Using Redis as a queue, orders are processed asynchronously by a Go service, with inter-service communication via gRPC to ensure scalable, event-driven architecture.
- Mimics real-world backend systems used in online marketplaces and retail platforms.
- Demonstrates asynchronous communication and processing using a message queue (Redis).
- Provides hands-on understanding of gRPC, microservices, and inter-language service orchestration (Node.js ↔ Go).
- Highlights efficient status transition workflows (
pending
→processing
→completed
) in distributed environments.
- Create Orders via REST API (
POST /orders
) - Push to Redis Queue with essential data (
orderId
,quantity
) - Process Orders asynchronously using Go service
- Update Status via gRPC to
processing
and latercompleted
- View All Orders using REST (
GET /orders
) - MySQL Persistence for order lifecycle tracking
Category | Technology |
---|---|
API Layer | Node.js, Express |
Database | MySQL |
Message Queue | Redis |
Worker Service | Go |
Communication | gRPC, RESTful |
Containerization | Docker |
- Asynchronous queue-based processing with Redis
- Microservice architecture: loose coupling and high cohesion
- Language-agnostic gRPC interface between Go and Node.js
- Sequelize
sync()
ensures schema alignment without migrations - Retries and health checks ensure robust startup via Docker Compose
- Modular codebase with separation of concerns (controllers, models, services)
Make sure Docker and Docker Compose are installed.
# Step 1: Clone the repo
git clone https://github.com/your-username/distributed-order-system.git
cd distributed-order-system
# Step 2: Start all services
docker-compose up --build
You should see:
- REST API on http://localhost:3000
- gRPC running on port
50051
curl -X POST http://localhost:3000/orders \
-H "Content-Type: application/json" \
-d '{
"item": "Laptop",
"quantity": 2,
"price": 1299.99
}'
curl http://localhost:3000/orders
- The Redis queue only stores
orderId
andquantity
for efficiency. - Statuses (
pending
,processing
,completed
) are updated in MySQL through Sequelize. - gRPC services are defined in
.proto
files and loaded using@grpc/proto-loader
. - Retry mechanisms ensure the Node service waits for MySQL and Redis before starting.
- The system is extensible to include features like email notifications, billing, etc.