
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
Classifies subdomains as Core, Supporting, or Generic and distinguishes them from bounded contexts. Walks through every context mapping pattern — Partnership, Shared Kernel, Customer-Supplier, Conformist, Anticorruption Layer, Open Host Service — and shows how to read a full context map.
In this lesson:
- Subdomains: Core, Supporting, Generic
- Invest in the Core Domain
- Bounded Context
- Subdomain vs Bounded Context
- Context Mapping: Overview
- Partnership and Shared Kernel
- Customer-Supplier and Conformist
- Anticorruption Layer
- Open Host Service and Published Language
- Reading a Context Map
Teaches the Event Storming notation, how to run a session, and how to turn a wall of orange events into bounded context boundaries. Includes a full worked example on a task-management domain.
In this lesson:
- Model-Driven Design
- Event Storming: Purpose
- Event Storming: The Notation
- Running the Session
- From Storm to Boundaries
- Worked Example: Task Management
Covers identity strategies, value object semantics, and a complete Money implementation. Explains aggregate roots, invariants, the four aggregate design rules, and why small aggregates win, ending with a worked Task aggregate.
In this lesson:
- Tactical Patterns Overview
- Entities
- Choosing an Identity Strategy
- Value Objects
- Value Object Semantics
- Implementing Money
- Value Objects That Guard Rules
- Entity or Value Object?
- Aggregates
- The Aggregate Root
- Invariants
- Aggregate Design Rules
- Small Aggregates Win
- Referencing Other Aggregates
- Worked Example: The Task Aggregate
Distinguishes domain events from integration events and shows how to name and shape them. Covers where repository interfaces live, common repository pitfalls, domain services, application services, factories, and how to organize modules and packages.
In this lesson:
- Domain Events
- Domain Events vs Integration Events
- Naming and Shaping Events
- Repositories
- Where Does the Interface Live?
- Repository Pitfalls
- Domain Services
- Application Services
- Factories
- Modules and Packages
Contrasts anemic and rich domain models, then explains layered architecture and the Dependency Rule. Draws the hexagonal and onion shapes, clarifies primary versus secondary adapters, and answers how pure the domain must be when NestJS is involved.
In this lesson:
- Anemic vs Rich Domain Model
- Layered Architecture
- The Dependency Rule
- Hexagonal Architecture
- Onion Architecture
- Primary vs Secondary Adapters
- Where NestJS Fits
- How Pure Must the Domain Be
Explains CQRS, when it pays off, and gives a first look at event sourcing with its consequences for transactions and eventual consistency. Closes by naming the recurring tactical anti-patterns to avoid.
In this lesson:
- CQRS: Separating Writes from Reads
- When CQRS Pays Off
- Event Sourcing: A First Look
- Transactions and Eventual Consistency
- Tactical Anti-Patterns
Installs the toolchain and walks the generated project structure. Covers modules, controllers, providers, custom providers and tokens for repository interfaces, and provider scopes.
In this lesson:
- Why NestJS
- NestJS Architecture at a Glance
- Installing the Toolchain
- Generated Project Structure
- Modules
- Controllers
- Providers and Dependency Injection
- Custom Providers and Tokens
- Provider Scopes
Works through middleware, pipes, DTOs with class-validator, guards, interceptors, and exception filters in order. Adds configuration, Jest testing, CLI generators, logging, and OpenAPI documentation as a Published Language.
In this lesson:
- Middleware
- Pipes and Transformation
- DTOs with class-validator
- Guards
- Interceptors
- Exception Filters
- Configuration
- Testing with Jest
- CLI Generators and Libraries
- Logging
- OpenAPI Documentation
Maps DDD layers onto NestJS and presents a reference folder structure. Shows how to write the domain layer in plain TypeScript — identity, value objects, and an aggregate root that raises events — with no decorators or ORM types.
In this lesson:
- Mapping DDD Layers onto NestJS
- Reference Folder Structure
- The Domain Layer in Plain TypeScript
- Identity in TypeScript
- Value Objects in TypeScript
- The Aggregate Root with Events
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.