Scalable and modular microservices architecture built with Node.js (NestJS & ExpressJS), PostgreSQL, MongoDB and Docker. It leverages RabbitMQ for event-driven communication, ideal for modern e-commerce and real-time systems.
This project demonstrates a modern microservices architecture for an Order & Inventory System, suitable for real-world companies. Each service is designed with a single responsibility, clear separation, and scalable technologies.
graph TB
%% Application Layer
subgraph "Application Layer"
agw[API Gateway]
us[User Service
NestJS]
ps[Product Service
ExpressJS]
os[Order Service
NestJS]
isvc[Inventory Service
ExpressJS]
ns[Notification Service
ExpressJS]
end
%% Database Layer
subgraph "Database Layer"
pg[(PostgreSQL)]
mongo[(MongoDB)]
end
%% Messaging Layer
subgraph "Messaging"
rmq[[RabbitMQ
Message Broker]]
end
%% Dependencies and Connections
agw -->|REST| us
agw -->|REST| ps
agw -->|REST| os
agw -->|REST| isvc
agw -->|REST| ns
us -- "DATABASE_URL" --> pg
os -- "DATABASE_URL" --> pg
ps -- "mongodb://..." --> mongo
isvc -- "mongodb://..." --> mongo
ns -- "mongodb://..." --> mongo
us -- "RABBITMQ_URL" --> rmq
os -- "RABBITMQ_URL" --> rmq
isvc -- "RABBITMQ_URL" --> rmq
ns -- "RABBITMQ_URL" --> rmq
%% Messaging Events
rmq -- "Events" --> os
rmq -- "Events" --> isvc
rmq -- "Events" --> ns
%% External Ports Exposure
agw -->|":3000"| extgw[External Access]
us -->|":3001"| extus[External Access]
ps -->|":3002"| extps[External Access]
os -->|":3003"| extos[External Access]
isvc -->|":3004"| extis[External Access]
ns -->|":3005"| extns[External Access]
pg -->|":9091"| extpg[External Access]
mongo -->|":9092"| extmongo[External Access]
rmq -->|":9093/9094"| extrmq[External Access]
%% Class Styling
classDef app fill:#2ecc71,stroke:#27ae60,color:white
classDef db fill:#3498db,stroke:#2980b9,color:white
classDef msg fill:#e67e22,stroke:#d35400,color:white
classDef ext fill:#95a5a6,stroke:#7f8c8d,color:white
class agw,us,ps,os,isvc,ns app
class pg,mongo db
class rmq msg
class extgw,extus,extps,extos,extis,extns,extpg,extmongo,extrmq ext
| Microservice | Tech Stack | DB | Responsibility |
|---|---|---|---|
| User Service | NestJS | PostgreSQL | User registration, login, authentication, roles |
| Product Service | ExpressJS | MongoDB | Product CRUD (create, update, list, delete) |
| Order Service | NestJS | PostgreSQL | Order creation, validation, and processing |
| Inventory Service | ExpressJS | MongoDB | Stock tracking, update on orders |
| Notification Service | ExpressJS | MongoDB | Email/log notifications on events |
| API Gateway | ExpressJS/NestJS | - | Unified API entry, routing, token verification |
| Message Broker | RabbitMQ | - | Inter-service event bus |
nodejs-microservices/
├── api-gateway/ # API Gateway (routing, auth)
├── user-service/ # User microservice
├── product-service/ # Product microservice
├── order-service/ # Order microservice
├── inventory-service/ # Inventory microservice
├── notification-service/ # Notification microservice
├── docker-compose.yml # Infrastructure orchestration
├── docs/ # Architecture diagrams, docs
├── README.md
Between Services: Messaging (RabbitMQ)
OrderService emits order_created
InventoryService listens and adjusts stockNotificationService listens and sends notificationorder_created eventorder_createdorder_created, etc)/products, /orders, /users to servicesPowered by docker-compose.yml:
Before starting the app, create the Docker network:
docker network create \
--driver=bridge \
--subnet=172.21.0.0/24 \
nodejs_network
Then run the entire system:
sudo docker-compose up --build -d
All services will be available on their respective internal IP addresses and ports, or via the API Gateway.
We welcome contributions, ideas, and feedback. Feel free to open issues or submit pull requests.
MIT License. See LICENSE for details.
Jawher Kallel GitHub @JawherKl
Made with ❤️ for scalable, real-world systems.
$ claude mcp add nodejs-microservices \
-- python -m otcore.mcp_server <graph>