Skip to main content

How DDD works in an agentic-AI development lifecycle?

Scenario

Build an Order Management system with:

  • order lifecycle

  • payments

  • shipment

  • cancellations

  • refunds

We’ll map roles → inputs → artifacts → outputs → consumers.


1) Roles in AI-era DDD

We’ll use these roles:

  • Architect

  • Domain Designer

  • Developer

  • AI Coding Agent

  • QA / Validator AI


2) Step-by-step lifecycle with artifacts


Step 1 — Architect defines domain boundaries

Architect input

  • business scope

  • enterprise architecture

  • system landscape

  • integration needs

Architect produces

Bounded Context Map

Example:

Order Management Payment Shipping Customer Catalog

Relationships:

Order → uses Payment Order → triggers Shipping Orderreads Catalog

Who consumes

  • Domain Designer

  • AI Agent

  • Developers

👉 This tells AI: “don’t mix payment logic into order.”


Step 2 — Domain Designer defines ubiquitous language

Designer input

  • workshops with business

  • policies

  • terminology

  • lifecycle rules

Designer produces

Domain Glossary

Example:

Order: confirmed customer purchase request OrderItem: purchasable line in order PaymentAuthorization: reserved funds approval Shipment: physical dispatch record Cancellation: customer or system termination Refund: money returned after capture

Format given to AI

concepts:

Order: description: confirmed purchase PaymentAuthorization: description: reserved funds approval

Who consumes

  • AI Agent

  • Developers

  • QA


Step 3 — Designer defines lifecycle & invariants

Designer produces

State model

Draft → Placed → Paid → Shipped → Completed ↘ Cancelled

Invariants

- Cannot ship unpaid order - Cannot cancel shipped order - Refund requires payment

AI input format

aggregate: Order states: - Draft - Placed - Paid - Shipped - Completed - Cancelled rules: - ship requires Paid - cancel forbidden after Shipped

Who consumes

  • AI Agent

  • Developers

  • QA


Step 4 — Architect defines events between contexts

Architect produces

Domain Events

OrderPlaced PaymentAuthorized OrderPaid OrderShipped OrderCancelled RefundIssued

And routing:

OrderPlaced → Payment OrderPaid → Shipping OrderCancelled → Payment (refund)

Who consumes

  • AI Agent

  • Integration teams

  • Developers


Step 5 — AI Agent generates domain model & services

AI input

  • contexts

  • glossary

  • states

  • invariants

  • events

AI produces

Aggregate

Order { id items state paymentStatus }

Methods

place() markPaid() ship() cancel() refund()

Guards (from invariants)

ship(): require state == Paid

Events

emit OrderPaid emit OrderShipped

Who consumes

  • Developers

  • QA

  • Architect


Step 6 — Developer reviews & refines

Developer input

  • AI-generated domain code

  • invariants

  • business edge cases

Developer tasks

  • edge rules

  • performance concerns

  • persistence mapping

  • error handling

Developer produces

  • refined domain logic

  • APIs

  • integration adapters

Who consumes

  • AI QA

  • System tests


Step 7 — AI QA validates domain correctness

AI checks:

  • invalid transitions

  • rule violations

  • missing guards

  • event consistency

Example test generated:

Given unpaid order When ship Then error "Unpaid order"

Who consumes

  • Developers

  • CI pipeline


3) Artifact flow summary

ArchitectContext MapAI + Designer + Dev DesignerGlossaryAI + Dev DesignerStates/InvariantsAI + Dev ArchitectEventsAI + Dev AIDomain ModelDev DevRefined SystemQA AI QA AITestsDev

4) What each role does in AI-era DDD

Architect

Focus: boundaries & interactions

Produces:

  • contexts

  • events

  • integrations

Does NOT:

  • design classes


Domain Designer

Focus: meaning & rules

Produces:

  • glossary

  • lifecycle

  • invariants

This role becomes MORE important with AI.


Developer

Focus: correctness & engineering

Does:

  • validate AI output

  • refine logic

  • implement infra

  • performance

Less time on:

  • boilerplate


AI Coding Agent

Focus: generation

Consumes:

  • domain specs

Produces:

  • aggregates

  • services

  • APIs

  • tests


AI QA Agent

Focus: verification

Consumes:

  • invariants

  • lifecycle

Produces:

  • tests

  • violations

  • edge scenarios


5) How DDD artifacts look in practice

Example combined spec given to AI:

context: OrderManagement aggregate: Order states: Draft Placed Paid Shipped Completed Cancelled rules: - ship requires Paid - cancel forbidden after Shipped - refund requires Paid events: OrderPlaced OrderPaid OrderShipped OrderCancelled RefundIssued

This replaces hundreds of lines of manual modeling.


6) Key shift from traditional DDD

Before:

Designer → UML
Dev → Code manually

Now:

Designer → semantic spec
AI → code
Dev → validate

DDD moves from diagrams → machine-readable semantics.


7) Why this works well with AI

AI is strong at:

  • structure generation

  • boilerplate

  • mapping rules to code

Humans remain better at:

  • meaning

  • boundaries

  • policies

  • intent

DDD defines exactly those.


Final takeaway

In agentic-AI development:

  • Architect defines contexts & events

  • Designer defines language & invariants

  • AI generates domain implementation

  • Developer validates & engineers

  • AI QA verifies rules

DDD becomes the semantic foundation layer that guides AI agents to produce correct systems.

Comments

Popular posts from this blog

Example 1: ArchiMate relationship in PlantUML code to demonstrate 15 relationship types

 Following section presents 15 types of relationships in ArchiMate and PlantUML to generate the diagram. Since this code is generated by GEN-AI it may require precision on aspects other than PlantUML syntax: Diagram Plant UML Code:  @startuml '!includeurl https://raw.githubusercontent.com/plantuml-stdlib/Archimate-PlantUML/master/Archimate.puml ' Another way of including Archimate Library (above is commented for following) !include <archimate/Archimate> !theme archimate-standard from https://raw.githubusercontent.com/plantuml-stdlib/Archimate-PlantUML/master/themes title ArchiMate Relationships Overview <style> element{     HorizontalAlignment: left;     MinimumWidth : 180;     Padding: 25; } </style> left to right direction rectangle Other {     Business_Role(Role_SeniorManager, "Senior Manager")     Business_Role(Role_Manager, "Manager") } rectangle Dynamic {     Business_Event(Event_CustomerReques...

Mastering Trade-Off Analysis in System Architecture: A Strategic Guide for Architects

 In system architecture and design, balancing conflicting system qualities is both an art and a science. Trade-off analysis is a strategic evaluation process that enables architects to make informed decisions that align with business goals and technical constraints. By prioritizing essential system attributes while acknowledging inevitable compromises, architects can craft resilient and efficient solutions. This enhanced guide provides actionable insights and recommendations for architects aiming to master trade-off analysis for impactful architectural decisions. 1. Understanding Trade-Off Analysis Trade-off analysis involves identifying and evaluating the conflicting requirements and design decisions within a system. Architects must balance critical aspects like performance, scalability, cost, security, and maintainability. Since no system can be optimized for every quality simultaneously, prioritization based on project goals is essential. Actionable Insights: Define key quality ...

Virtual environments in python

 Creating virtual environments is essential for isolating dependencies and ensuring consistency across different projects. Here are the main methods and tools available, along with their pros, cons, and recommendations : 1. venv (Built-in Python Virtual Environment) Overview: venv is a lightweight virtual environment module included in Python (since Python 3.3). It allows you to create isolated environments without additional dependencies. How to Use: python -m venv myenv source myenv/bin/activate # On macOS/Linux myenv\Scripts\activate # On Windows Pros: ✅ Built-in – No need to install anything extra. ✅ Lightweight – Minimal overhead compared to other tools. ✅ Works across all platforms . ✅ Good for simple projects . Cons: ❌ No dependency management – You still need pip and requirements.txt . ❌ Not as feature-rich as other tools . ❌ No package isolation per project directory (requires manual activation). Recommendation: Use venv if you need a simple, lightweight solut...