Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Domain-Driven Design (DDD) with NestJS Essentials 2026
New
4 students

Domain-Driven Design (DDD) with NestJS Essentials 2026

Model your domain properly, then wire it into NestJS with downloadable starter code
Created byJoey Guo
Last updated 11/2026
English

What you'll learn

  • Distinguish subdomains from bounded contexts and draw a context map using Partnership, Shared Kernel, Customer-Supplier, Conformist, Anticorruption Layer, and O
  • Run an Event Storming session and convert the output into concrete bounded context boundaries
  • Implement Entities, Value Objects, Aggregates, and Domain Events in plain TypeScript with enforced invariants
  • Design small aggregates and decide when to reference another aggregate by identity
  • Place repository interfaces in the domain layer and bind them in NestJS with custom providers and tokens
  • Build a hexagonal NestJS project with TypeORM and Mongoose adapters, mappers, and controllers as primary adapters
  • Add CQRS with @nestjs/cqrs — commands, queries, sagas — and implement the Outbox pattern for reliable event dispatch
  • Write fast domain unit tests plus integration and E2E tests, and apply a code review checklist to catch tactical anti-patterns

Course content

15 sections • 15 lectures • 4h 28m total length
  • DDD Foundations and the Ubiquitous Language23:25

    Explains why architecture matters, dissects the anatomy of a big ball of mud, and introduces the two halves of DDD. You will learn how to build a glossary and spot language traps that silently corrupt a model.


    In this lesson:


    - Course Overview

    - Why Architecture Matters

    - Course Roadmap

    - Anatomy of a Big Ball of Mud

    - What Is Domain-Driven Design?

    - The Two Halves of DDD

    - The Ubiquitous Language

    - Ubiquitous Language in Code

    - Language Traps

    - Building a Glossary

Requirements

  • Entry level programming skills required, need to understand basic programming terms

Description

This course contains the use of artificial intelligence. (voice overs)
Most NestJS codebases start clean and end up as a big ball of mud: fat controllers, anemic entities, repositories that leak SQL into the domain, and business rules scattered across services. This course fixes that by teaching Domain-Driven Design as a practical discipline, not a vocabulary list. You will learn to separate the problem space (subdomains) from the solution space (bounded contexts), map how contexts relate, and run an Event Storming session that produces real boundaries instead of a wall of sticky notes.


On the tactical side you will build Entities, Value Objects, Aggregates, Domain Events, Repositories, and Domain Services in plain TypeScript, then see exactly where each one lives in a hexagonal NestJS project. You will implement a TypeORM adapter and a Mongoose variant, add CQRS with @nestjs/cqrs, handle transactions with a Unit of Work, and use the Outbox pattern so domain events survive a crash. The course closes with a capstone where you model and implement a task-management domain end to end, plus a code review checklist you can take to your team on Monday.


The teaching is slide-driven with worked examples throughout: Money as a value object, the Task aggregate, a full Event Storming session, and a reference folder structure you can copy. Every NestJS feature — modules, controllers, providers, custom tokens, pipes, guards, interceptors, filters — is shown in service of keeping the domain pure, so you can see where the framework helps and where it should stay out of the way.


We also included a starter pack for you to work on, this starter is a fork of

[deadislove/nestJS-hexagonal-architecture-template]

**What is the difference between a subdomain and a bounded context?**

A subdomain is part of the problem space (Core, Supporting, or Generic), while a bounded context is a boundary in the solution space where one model applies. Lesson 2 devotes a dedicated slide to Subdomain vs Bounded Context and walks through the seven context mapping patterns the course covers: Partnership, Shared Kernel, Customer-Supplier, Conformist, Anticorruption Layer, Open Host Service, and Published Language.


**How do I run an Event Storming session?**

Lesson 3 teaches the Event Storming notation, how to run the session, and how to convert a wall of orange events into bounded context boundaries. It includes a full worked example on a task-management domain.


**Where should repository interfaces live in a NestJS project?**

Repository interfaces belong in the domain layer, bound in NestJS with custom providers and tokens. Lesson 5 covers Where Does the Interface Live? and repository pitfalls; lesson 11 ends with the repository interface and its injection token.


**How do I implement CQRS in NestJS?**

Use @nestjs/cqrs to dispatch domain events and implement commands, command handlers, queries, query handlers, and sagas. Aggregates extend the library's `AggregateRoot`, queue events with `apply()`, and dispatch them through `EventPublisher.mergeObjectContext(aggregate)` plus `commit()`. Lesson 11 covers each of these in 12:20, and lesson 7 explains when CQRS pays off.


**What is the Outbox pattern and why do I need it?**

The Outbox pattern makes domain events survive a crash by persisting them alongside the transaction before dispatch. Lesson 12 covers the Outbox pattern together with Unit of Work transactions.


**How do I keep my domain layer pure when using NestJS?**

Write the domain layer in plain TypeScript with no decorators or ORM types, then wire it in through adapters. Lesson 10 shows identity, value objects, and an aggregate root that raises events in plain TypeScript, and lesson 6 answers how pure the domain must be.


**How do I test a DDD domain in NestJS?**

Write fast domain unit tests in plain TypeScript, then add integration and E2E tests for the adapters. Lesson 13 covers Testing the Domain plus Integration and E2E Tests, and lesson 9 covers Jest setup.


**When should I not use DDD?**

Skip DDD when the business rules are trivial and a simple CRUD model suffices. Lesson 13 has a dedicated When Not to Use DDD section and also covers adopting DDD incrementally.


Who this course is for:

  • Backend developers who know NestJS basics and are about to start a project where the business rules are non-trivial
  • Tech leads inheriting a NestJS codebase where business logic is spread across controllers and services and want a concrete restructuring plan
  • Developers who have read about DDD but cannot see how Aggregates, Repositories, and Domain Events map onto NestJS modules and providers
  • Engineers preparing for a system design interview or architecture review where bounded contexts and CQRS come up