A modular, production-ready microservices system inspired by e-commerce architectures, built with TypeScript, Node.js, NestJS, ExpressJS, PostgreSQL, MongoDB, Docker, and RabbitMQ/NATS for event-driven communication.

This project demonstrates a modern microservices architecture for an Order & Inventory System, suitable for real-world companies. Each service is designed with single responsibility, clear separation, and scalable technologies.
- Tech Focus: TypeScript-first, RESTful APIs, event-driven messaging, containerized infrastructure
- Monorepo: All services managed together for easy orchestration and development
- Best Practices: Security, scalability, and maintainability in mind
graph TB
%% Application Layer
subgraph "Application Layer"
agw[API Gateway]
us[User Service<br/>NestJS]
ps[Product Service<br/>ExpressJS]
os[Order Service<br/>NestJS]
isvc[Inventory Service<br/>ExpressJS]
ns[Notification Service<br/>ExpressJS]
end
%% Database Layer
subgraph "Database Layer"
pg[(PostgreSQL)]
mongo[(MongoDB)]
end
%% Messaging Layer
subgraph "Messaging"
rmq[[RabbitMQ<br/>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/NATS | - | 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
- API Gateway β Services: REST (HTTP)
- Between Services: Messaging (RabbitMQ/NATS)
OrderService
emitsorder_created
InventoryService
listens and adjusts stockNotificationService
listens and sends notification
- Secure sign up & login
- JWT authentication
- Role-based access (admin/user)
- Create/list/delete products
- Fetch by product ID
- Simple MongoDB schema
- Place new orders
- Validate users & product stock
- Emits
order_created
event
- Listens to
order_created
- Decreases stock or rejects if insufficient
- Listens to events (
order_created
, etc) - Sends notification (email/log)
- One entrypoint for frontend
- Reverse proxy, JWT verification
- Routes
/products
,/orders
,/users
to services
Powered by docker-compose.yml
:
- All microservices (with build contexts)
- MongoDB, PostgreSQL databases
- RabbitMQ or NATS for messaging
- Optional admin UIs: pgAdmin, Mongo Express, RabbitMQ dashboard
docker-compose up --build
- Add OpenAPI/Swagger docs for each service
- Service discovery and dynamic routing
- Production-ready monitoring & logging
- Integration with frontend (React/Angular)
- Advanced notification channels (SMS, Push)
Contributions, ideas, and feedback are welcome!
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.