How albasyir/nestjs-microservice works
Project type and purpose
• This is a microservices system built with NestJS implementing a fan-out event pattern.
• It consists of three core services—Order, Kitchen, Notification—communicating via RabbitMQ, backed by a MySQL database, and containerized via Docker (development and production).
File structure
• Top-level “apps” folder: three microservices (order, kitchen, notification).
• apps/order:
– Domain layer (menu & order modules, entities, repos, services, controllers)
– Infrastructure layer (TypeORM config/migrations for MySQL, RabbitMQ config)
– Main entrypoint (main.ts)
• apps/kitchen and apps/notification: each has its own module/controller/service/config files and a main.ts.
• “libs/keep-alive-microservice”: shared library that likely kicks off a heartbeat publisher to RabbitMQ.
• Root-level compose.yml and docker/*: Docker Compose setup for dev and production, including RabbitMQ, MySQL, and service containers.
• Config files: .env per service, Dockerfiles, Nest CLI, TS configs.
README for insights
• Services run on ports 3000 (Order), 3001 (Kitchen), 3002 (Notification) in dev.
• RabbitMQ and MySQL management UIs exposed (ports 15672, 5100).
• In production, a single multi-stage Docker image runs each service based on APP_TYPE env var.
• Fan-out pattern: Order service publishes events to RabbitMQ; Kitchen and Notification services subscribe.
Main components
a. API Clients (Users or UI)
b. Order Microservice
c. Kitchen Microservice
d. Notification Microservice
e. Keep-Alive Microservice (heartbeat)
f. RabbitMQ Broker + Management UI
g. MySQL Database + Admin UI
h. Docker Compose / Container Orchestrator
Relationships & interactions
• Clients → Order Service (HTTP/REST requests)
• Order Service ↔ MySQL (TypeORM reads/writes)
• Order Service —publishes→ RabbitMQ Exchanges
• Kitchen & Notification Services —consume→ RabbitMQ Queues
• Keep-Alive Service —publishes→ RabbitMQ (ensures open connections)
• Orchestrator (Docker Compose) brings up containers and networking
Architectural patterns & technologies
• Microservice decomposition: each bounded context (order, kitchen, notification) lives in its own NestJS app.
• Fan-out messaging pattern via RabbitMQ (exchange → multiple queues).
• Domain-driven design in Order service (separation of domain vs. infra).
• TypeORM for persistence.
• Config modules for environment-agnostic settings.
• Containerization: Docker Compose for developer workflow; multi-stage Docker builds for production.