A Spring Boot 4.1 DDD Scaffold Built to Be Read by AI, Not Just Humans
AI coding agents produce better output when they have a concrete, well-structured reference to imitate. This scaffold treats its own codebase as the prompt—giving agents a working DDD template with real multi-data source transactions and event-driven wiring, which cuts down on architectural drift in generated code.
The scaffold enforces a clean separation across interfaces, application, domain, and infrastructure layers, with MySQL and PostgreSQL running under independent transaction managers. Domain models are kept free of framework annotations, repository interfaces live in the domain layer, and implementations sit in infrastructure—a structure meant to give AI agents unambiguous boundaries to follow.
It ships with JdbcClient for data access, MyBatis Plus for complex queries, and RocketMQ 5.3 for domain event publishing with graceful degradation. A full Agent CLI guide is included, showing how to point Claude Code or Cursor Agent at the scaffold as a reference project and generate new aggregates, repositories, and events that conform to the same conventions.
The pitch is that architecture setup drops from one to two weeks down to about ten minutes, and that the codebase doubles as a specification an AI can read to stay on track. The project lives inside a larger design-patterns repository and targets teams adopting AI-assisted development who want generated code to land inside a disciplined DDD structure.
Treating a codebase as a machine-readable specification for AI agents is a pragmatic shift: the architecture itself becomes the prompt, reducing the need to describe conventions in natural language.
Keeping domain models completely free of framework annotations is a hard rule that many real-world DDD projects relax; enforcing it here gives AI agents a clearer signal about where business logic ends and infrastructure begins.
The scaffold's value is less about the individual technology choices and more about the consistent structure it imposes—AI tools are sensitive to pattern regularity, and a disciplined codebase produces more predictable output than a loose set of guidelines.