Web Development · WDC-92

Building Microservices with NestJS

Building Microservices with NestJS is an intermediate course in splitting a backend into small services with NestJS 12, from service design and an API gateway to messaging with RabbitMQ, NATS and gRPC, sagas for cross-service data, tracing and deployment with Docker Compose. It suits backend developers who already use NestJS, tech leads and DevOps teams.

Updated
From 9,000 THB / person 10,000 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration18 hours · 3 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

Microservices split a large system into small services by business function, such as users, products, orders and payments. Each service can be developed, deployed and scaled on its own, in exchange for more complex communication between services, data consistency and troubleshooting. NestJS provides the @nestjs/microservices package, which supports several transports with the same programming style, making it a good fit for teams building this kind of system on Node.js.

This course builds on Basic NestJS and Advanced NestJS using current NestJS 12. Learners design service boundaries, build microservices and an API gateway, communicate over TCP, RabbitMQ, NATS and gRPC, give each service its own database and handle cross-service transactions with sagas and the outbox pattern. They then make the system resilient and observable with logs and tracing, and finish by deploying a complete store system with Docker Compose. (3 days, 6 hours per day, 18 hours in total, Intermediate level.)

What you’ll gain

  • Explain the benefits and trade-offs of microservices and split services by business boundary
  • Build microservices and hybrid applications with NestJS 12
  • Choose between request-response and event-based messaging for each task
  • Connect services over TCP, RabbitMQ, NATS and gRPC
  • Design a database per service and handle cross-service transactions with sagas
  • Make the system resilient and trace problems with health checks, logs and tracing
  • Deploy a multi-service system with Docker Compose

Who this course is for

  • Backend developers who already use NestJS and want to split systems into smaller services
  • Learners who have completed Basic NestJS or Advanced NestJS and want to go further
  • Software architects and tech leads who design medium to large systems
  • DevOps engineers and system administrators who deploy and run multi-service systems

Prerequisites

  • Working NestJS knowledge, including modules, controllers, providers and dependency injection
  • TypeScript, including async and await
  • Some experience building REST APIs and using a database
  • Basic Docker commands, and a laptop that can run Docker Desktop (16 GB RAM recommended)

Curriculum

Course Details

This course is the 2026 edition of Building Microservices with NestJS. It runs for 3 days, 6 hours per day (18 hours in total, 09:00-16:00), as lectures with labs. Intermediate level. The previous edition built microservices over TCP and deployed with PM2. This edition moves to NestJS 12, which uses ES modules, organises the project as a monorepo and adds an API gateway, RabbitMQ, NATS, gRPC,

a database per service, sagas and the outbox pattern, resilience, health checks and distributed tracing with OpenTelemetry, then deploys the whole system with Docker Compose. It builds on Basic NestJS and Advanced NestJS, which already cover ORMs, JWT and OpenAPI. Every lab uses open source or free tools that run on the learner's own machine. Learners take home a lab guide and the source code of a microservices store system.

Day 1 Microservice Concepts, a First Transport and the API Gateway

Section 1: What Microservices Are and When to Use Them

  • Compare monoliths, modular monoliths and microservices
  • The benefits and the trade-offs a team must accept
  • Split services by business boundary with bounded contexts
  • How synchronous and asynchronous communication differ
  • Workshop: design the services of an online store

Section 2: Lab: Setting Up a Monorepo

  • Review NestJS 12, which uses ES modules and needs Node.js 20 or later
  • Create a monorepo with the Nest CLI and add several applications
  • Move shared code such as DTOs and constants into a library
  • Configure each service with @nestjs/config and .env files
  • Lab: a store project with product and order services

Section 3: Lab: A First Microservice over TCP

  • Install @nestjs/microservices and start a service with createMicroservice
  • Handle requests with @MessagePattern and return a value
  • Call other services with ClientProxy and send
  • Register clients with ClientsModule.registerAsync
  • Lab: a product service that answers the order service

Section 4: Message Patterns and Event Patterns

  • How request-response and event-based messaging differ
  • Publish events with emit and handle them with @EventPattern
  • Read the context and payload with @Ctx and @Payload
  • Handle errors with RpcException and exception filters
  • Lab: announce a new order to several services

Section 5: Lab: API Gateway and Hybrid Applications

  • The role of an API gateway in a multi-service system
  • Build a gateway that accepts HTTP and forwards to internal services
  • Hybrid applications with connectMicroservice
  • Validate input at the gateway and map errors to HTTP status codes
  • Lab: a store REST API that calls every internal service
Day 2 Message Brokers, gRPC and Cross-Service Data

Section 6: Lab: Messaging with RabbitMQ

  • How a message broker reduces coupling between services
  • Run RabbitMQ on Docker and use the management UI
  • Configure Transport.RMQ on both server and client
  • Durable queues, acknowledgements and redelivery after failures
  • Lab: send receipt jobs through a queue

Section 7: NATS, Redis and an Overview of Kafka

  • Use NATS for fast messaging and queue groups
  • Use Redis as a pub/sub transport
  • An overview of Kafka for high-volume event streams
  • Criteria for choosing the right transport
  • Lab: move the notification service to NATS

Section 8: Lab: gRPC and Protocol Buffers

  • What gRPC is and which internal calls it suits
  • Write a .proto file to define services and messages
  • Configure Transport.GRPC and use @GrpcMethod
  • Call gRPC from the gateway and handle gRPC status codes
  • Lab: a gRPC stock-checking service

Section 9: A Database per Service

  • The database-per-service principle and its pitfalls
  • Run a separate PostgreSQL instance for each service on Docker
  • Replicate shared data through events
  • Idempotency so repeated messages are handled safely
  • Lab: product and order services with their own databases

Section 10: Workshop: Sagas and the Outbox Pattern

  • Why cross-service transactions cannot work the traditional way
  • Choreography and orchestration sagas
  • Write compensating actions for failed steps
  • The outbox pattern to keep saved data and published events in step
  • Workshop: an order, stock and payment flow as a saga
Day 3 Resilience, Security, Observability and Deployment

Section 11: Lab: Resilience in a Multi-Service System

  • Set timeouts on service calls with RxJS
  • Retry with back-off, and when not to retry
  • The circuit breaker idea and fallbacks
  • Graceful shutdown with enableShutdownHooks
  • Lab: a gateway that still responds when a downstream service fails

Section 12: Security between Services

  • Authenticate at the gateway with JWT and pass user details on
  • Check permissions in internal services with guards
  • Keep an internal network and never expose service ports publicly
  • Store secrets safely, and the idea of TLS between services
  • Lab: make the order service accept only requests from the gateway

Section 13: Lab: Health Checks, Logs and Tracing

  • Health checks for services, databases and brokers with @nestjs/terminus
  • Structured logs with a correlation ID across services
  • Distributed tracing with OpenTelemetry
  • Follow a request's path in Jaeger
  • Lab: find the service that slows down orders

Section 14: Lab: Testing and Deploying with Docker Compose

  • Unit-test handlers with Vitest and a mocked ClientProxy
  • Write a multi-stage Dockerfile for each service
  • Combine every service, broker and database in docker-compose.yml
  • Scale out instances and share work through queues
  • PM2 for a single server, and an overview of moving to Kubernetes

Section 15: Workshop: A Microservices Store Capstone

  • Bring together the gateway and the user, product, order and notification services
  • Connect services over RabbitMQ, NATS and gRPC as designed
  • Test failed services and duplicate messages
  • Monitor the whole system with health checks and tracing
  • Workshop: present the architecture and next steps for your organisation

Schedule & training options

For individuals — public rounds

No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

How do microservices differ from a monolithic system?

A monolith keeps every part of the system in one application deployed as a single unit: simple to start, but harder to change and scale as it grows. Microservices split the system into small services by business function, such as users, products and orders, each with its own database and each developed, deployed and scaled independently. The trade-off is more complex communication, troubleshooting and data consistency, so small teams or young systems may start with a modular monolith.

How can NestJS microservices communicate with each other?

The @nestjs/microservices package supports several transports, including TCP, Redis, NATS, MQTT, RabbitMQ, Kafka and gRPC, all written in the same style. There are two main styles: request-response, sent with send and handled with @MessagePattern when a reply is needed, and event-based, sent with emit and handled with @EventPattern when you only announce that something happened. gRPC uses .proto files as the contract between services, and external clients usually call a REST API exposed by an API gateway.

How do you handle transactions that span several services?

When each service owns its database, one transaction cannot cover everything. Instead, a saga splits the work into local steps in each service, and if a step fails it runs compensating actions to undo earlier steps, such as returning stock when payment fails. Combine it with the outbox pattern, which stores events in the same database as the main data before publishing them, and design handlers to process repeated messages safely (idempotency).

How do you deploy a NestJS microservices system?

The course writes a multi-stage Dockerfile for each service and combines the services, message brokers and databases in a docker-compose.yml file so the whole system starts with one command. Health checks use @nestjs/terminus, and graceful shutdown lets services stop cleanly. PM2 is still an option for a single server, and larger systems can move on to Kubernetes.

Who is the Building Microservices with NestJS course for, and what should I know beforehand?

It suits backend developers who already use NestJS, learners who have completed Basic NestJS or Advanced NestJS, software architects and tech leads, and DevOps teams who run multi-service systems. You should be able to write NestJS and TypeScript, have built REST APIs and used a database, and know basic Docker commands.

What do I need to prepare for Building Microservices with NestJS?

Bring a laptop that can run the Node.js LTS release, the Nest CLI, VS Code and Docker Desktop. 16 GB of RAM is recommended, because several services run alongside RabbitMQ, NATS, Redis, PostgreSQL and Jaeger on Docker on one machine. All tools are open source or free, and no cloud account is needed.