Back to blog

DDD Matters More in the Age of AI

aidddsoftware-architecturedomain-driven-designsoftware-engineering
DDD Matters More in the Age of AI

A few years ago, the slow part of building software was typing it. Controllers, DTOs, repositories, migrations, tests, glue code. Hours of it.

Today an AI assistant produces all of that in a minute. So where did the hard part go?

It did not go anywhere. It was always the other thing: deciding what the software should model. When implementation gets cheap, that decision becomes the most valuable thing left. And that is exactly what Domain-Driven Design (DDD) is about.

This post is an opinion, not research. It is how I currently think about splitting work between myself and an AI assistant.

What I'll Talk About

✅ Why cheap implementation makes design more valuable, not less
✅ Core domain vs everything around it, and who should own which
✅ How DDD gives a clean seam between design (human) and implementation (AI)
✅ Why ubiquitous language, bounded contexts and aggregates happen to be AI-friendly
✅ A concrete example: a hand-written aggregate and AI-generated everything else
✅ Pitfalls: anemic models, AI designing the core by accident, and DDD overkill

If you need a refresher on the basics first, read Domain-Driven Design: Strategic & Tactical Patterns.


1. When Implementation Gets Cheap

Think of any feature as two jobs:

JobQuestion it answersWho is good at it now
DesignWhat are the concepts? What rules must never be broken? What does "refund" actually mean here?Humans who talk to the business
ImplementationHow do I turn that design into working code, an API, a table, a test?Humans and AI, with AI much faster

For decades these two jobs were tangled in one person's head and one editor window. Typing speed and design skill were bundled together, so nobody noticed they were different skills.

AI pulls them apart. The implementation job has a huge, well-documented training set: every CRUD endpoint ever written. The design job depends on your business: your rules, your exceptions, the thing the sales team promised last quarter. No training set contains that.

So the scarce resource is no longer "who can write this code". It is "who knows what this code is supposed to mean".

2. Core Domain vs Everything Around It

DDD already has a vocabulary for this. A system is made of subdomains:

  • Core domain: the part that makes your business different. Your pricing engine, your matching algorithm, your risk rules. This is where you win or lose.
  • Supporting subdomains: necessary, but not unique. Notifications, reporting, admin screens.
  • Generic subdomains: solved problems. Authentication, payments, email sending.

Eric Evans' advice was always: spend your best people on the core, buy or simplify the rest. AI changes the economics of "the rest" dramatically. Now you can generate the rest.

Notice the direction of the arrows. Everything depends on the core; the core depends on nothing. That is the dependency rule from Hexagonal and Clean Architecture, and it is not a coincidence that it also describes the ideal AI delegation boundary: the AI works at the edges, against a contract that a human has defined in the middle.

3. DDD Gives You a Clean Seam

"Let AI do the implementation" is easy to say and hard to do in a codebase where business rules are scattered across controllers, SQL triggers and a 2,000-line service class. The AI has no idea which of those lines are sacred and which are incidental. Neither will you, three months later.

DDD forces a separation that makes delegation safe:

  1. The domain model is pure code. No framework, no database, no HTTP. Just concepts and rules.
  2. Everything else is replaceable. Swap Postgres for something else, REST for GraphQL: the core does not care.
  3. The core is small. A good core domain is usually a few aggregates, not hundreds of classes. A human can fully hold it in their head and review it carefully.

That is the real deal here. You are not asking AI to "build the app". You are asking it to implement adapters around a contract you wrote, and the contract is small enough to be reviewed line by line.

4. Why DDD Concepts Happen to Be AI-Friendly

I did not plan this, but several DDD ideas turn out to be good prompt engineering.

Ubiquitous Language = A Shared Vocabulary With Your AI

In DDD, the team agrees on one precise word for each concept. "Customer" is not "User" is not "Account". When the AI reads a codebase where Shipment, Parcel and Delivery each mean something specific, its output uses the same words. When the codebase calls the same thing item, product, sku and article in four places, so will the AI, and you get four slightly different implementations.

Naming is not cosmetic anymore. It is the interface between you and the model.

Bounded Contexts = A Small, Focused Context Window

A bounded context is a region of the system where the language is consistent. That is also a perfect unit of context for an AI assistant. Point it at one context, give it that context's rules, and it does not need to reason about the other fifteen. This lines up with what I wrote in Context Engineering for AI Agents: the best results come from giving the model less, but more relevant information.

Aggregates = A Clear Consistency Boundary

An aggregate says: "these objects change together, and this root enforces the rules". It tells the AI where business rules live and where they must not leak. Instead of a vague "validate the order somewhere", the instruction becomes "all order rules live in Order; the service only calls its methods".

5. A Concrete Example

Let me show the split with a small example. Say we are building order management for an online shop. The core rule set is not complicated, but it is ours.

The Part I Write by Hand: The Domain Core

// domain/order.ts: written and reviewed by a human
// (Money and OrderLine value objects omitted for brevity)
 
export type OrderStatus = "draft" | "placed" | "paid" | "shipped" | "cancelled";
 
export class DomainError extends Error {}
 
export class Order {
  private lines: OrderLine[] = [];
  private status: OrderStatus = "draft";
 
  constructor(readonly id: string, readonly customerId: string) {}
 
  addLine(sku: string, quantity: number, unitPrice: Money): void {
    if (this.status !== "draft") {
      throw new DomainError("Cannot change an order after it is placed");
    }
    if (quantity <= 0) {
      throw new DomainError("Quantity must be positive");
    }
    this.lines.push(new OrderLine(sku, quantity, unitPrice));
  }
 
  place(): void {
    if (this.lines.length === 0) {
      throw new DomainError("An empty order cannot be placed");
    }
    this.status = "placed";
  }
 
  cancel(): void {
    // Business rule: shipped orders are never cancelled, they are returned.
    if (this.status === "shipped") {
      throw new DomainError("Shipped orders must be returned, not cancelled");
    }
    this.status = "cancelled";
  }
 
  total(): Money {
    return this.lines.reduce((sum, l) => sum.add(l.subtotal()), Money.zero());
  }
}

This file is where my thinking goes. When can an order change? What happens to a shipped order? Is a cancelled order deleted or kept? Each if is a decision somebody had to make with the business.

The Part I Delegate: Everything Else

Now I give the AI a prompt like this:

Context: bounded context "Ordering". Domain model is in domain/order.ts.
Do NOT modify files under domain/.
 
Task:
1. Implement OrderRepository (port is in domain/order-repository.ts)
   with a Postgres adapter using Drizzle.
2. Add REST endpoints: POST /orders, POST /orders/:id/lines,
   POST /orders/:id/place, POST /orders/:id/cancel.
3. Map DomainError to HTTP 422. Never reimplement business rules in the controller.
4. Write integration tests for each endpoint.

The AI produces the migration, the Drizzle mapping, the controllers, the DTO validation, the OpenAPI doc and the tests. That is a lot of typing I did not do.

And the review is cheap in the right way. I do not need to read every line to know whether the rules are correct, because the rules are not in the generated code. I check the edges: does the controller call order.place() and not do its own checks? Does the mapper round-trip correctly? Does the test actually assert behaviour?

6. What to Delegate and What to Keep

A rough rule of thumb I use:

Keep (human decides)Delegate (AI implements)
Naming of core conceptsBoilerplate, mappers, DTOs
Aggregate boundariesRepository and persistence adapters
Invariants and business rulesControllers and API wiring
Context boundaries and integration contractsClient SDKs and anti-corruption layer plumbing
Which tests prove the rulesTests for plumbing, fixtures, docs

The left column is small and high-leverage. The right column is large and low-risk if the left column is solid.

7. Pitfalls

This is not magic. A few ways it goes wrong:

The anemic model. If your domain objects are just bags of getters and setters, the rules live somewhere else: in services, in controllers, in the AI's imagination. The AI will happily invent them and scatter them. The seam only works if the model really contains the behaviour.

The AI designs the core by accident. Ask an AI "build me an order system" with no model and it will produce a domain model, a plausible and generic one. Nobody reviewed it, and it will quietly become the foundation. Always bring the model, or at least the language and the rules, to the conversation first.

The model is never finished. Design and implementation are not a waterfall. Implementing something reveals that a concept was wrong, and you go back and change the core. That is fine, and it is the point: the loop is faster now. But a human must close that loop, not the AI.

DDD overkill. If the feature is a plain CRUD screen with no real rules, a rich domain model is ceremony. Let the AI generate the CRUD and move on. DDD earns its cost only where the domain is genuinely complex, and I covered that in the overkill section of the DDD guide.

You still need a domain expert. AI does not remove the need to learn the business. If anything it raises it, because your design is now the only thing standing between a generic implementation and a correct one. See Why Developers Can't Build Projects Alone.

Summary and Key Takeaways

✅ AI makes implementation cheap, so the value moves to design
✅ DDD's core domain is the part worth your best human attention
✅ A pure domain model is a small contract AI can build around but should not rewrite
✅ Ubiquitous language, bounded contexts and aggregates double as good AI context
✅ Keep the rules in the model, never in the generated glue
✅ Use DDD where the domain is genuinely complex, skip it for plain CRUD

The craft did not get less important. It got more concentrated. Fewer people will type the controllers, but the person who can say precisely what an order is and what must never happen to it just became the most useful person in the room.

If you are still working on your workflow with these tools, My Coding Workflow with AI is a good companion read.

📬 Subscribe to Newsletter

Get the latest blog posts delivered to your inbox every week. No spam, unsubscribe anytime.

We respect your privacy. Unsubscribe at any time.

💬 Comments

Sign in to leave a comment

We'll never post without your permission.