ddd4j-project-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DDD4j Project Creator

DDD4j 项目创建器

When to use this skill

何时使用此技能

CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project, initializing ddd4j project, or setting up ddd4j-boot project.
ALWAYS use this skill when the user mentions:
  • Creating a ddd4j project (explicitly mentions "ddd4j")
  • Initializing ddd4j-boot project
  • Setting up ddd4j project structure
  • Creating ddd4j project scaffolding
  • 创建 ddd4j 项目 (explicitly mentions "ddd4j")
  • 初始化 ddd4j 项目 (initialize ddd4j project)
  • ddd4j-boot 项目创建 (create ddd4j-boot project)
Trigger phrases include:
  • "创建 ddd4j 项目" (create ddd4j project) - must include "ddd4j"
  • "初始化 ddd4j 项目" (initialize ddd4j project) - must include "ddd4j"
  • "创建 ddd4j-boot 项目" (create ddd4j-boot project) - must include "ddd4j"
  • "使用 ddd4j 创建项目" (create project using ddd4j)
  • "ddd4j 项目脚手架" (ddd4j project scaffolding)
DO NOT trigger this skill for:
  • Generic DDD projects without mentioning ddd4j
  • JPA/Hibernate projects
  • Other ORM frameworks
  • Generic project initialization without ddd4j context
  • "创建 DDD 项目" without "ddd4j" (too generic)
  • "初始化项目" without "ddd4j" (too generic)
重要提示:仅当用户明确提及创建ddd4j项目、初始化ddd4j项目或搭建ddd4j-boot项目时,才可触发此技能。
当用户提及以下内容时,务必使用此技能:
  • 创建ddd4j项目(明确提及“ddd4j”)
  • 初始化ddd4j-boot项目
  • 搭建ddd4j项目结构
  • 创建ddd4j项目脚手架
  • 创建 ddd4j 项目(明确提及“ddd4j”)
  • 初始化 ddd4j 项目
  • ddd4j-boot 项目创建
触发短语包括:
  • "创建 ddd4j 项目" - 必须包含“ddd4j”
  • "初始化 ddd4j 项目" - 必须包含“ddd4j”
  • "创建 ddd4j-boot 项目" - 必须包含“ddd4j”
  • "使用 ddd4j 创建项目"
  • "ddd4j 项目脚手架"
请勿触发此技能的场景:
  • 未提及ddd4j的通用DDD项目
  • JPA/Hibernate项目
  • 其他ORM框架相关项目
  • 无ddd4j上下文的通用项目初始化
  • 未包含“ddd4j”的“创建 DDD 项目”(过于通用)
  • 未包含“ddd4j”的“初始化项目”(过于通用)

About DDD4j Boot

关于DDD4j Boot

DDD4j Boot is a Java microservice development scaffold based on Domain-Driven Design (DDD) principles. It is built with Spring Boot 3.5.x and uses lightweight ddd-4-java and cqrs-4-java libraries to implement Domain-Driven Design, Command Query Responsibility Segregation (CQRS), and Event Sourcing.
DDD4j Boot 是一款基于**领域驱动设计(DDD)**原则的Java微服务开发脚手架。它基于Spring Boot 3.5.x构建,采用轻量级的ddd-4-javacqrs-4-java库来实现领域驱动设计、命令查询职责分离(CQRS)以及事件溯源。

Core Design Principles

核心设计原则

  • Domain-Driven Design (DDD): Strategic design through bounded contexts, tactical design with entities, value objects, aggregates, domain services, repositories, and domain events
  • Command Query Responsibility Segregation (CQRS): Separation of read and write models, independent optimization
  • Event Sourcing: State changes recorded as event sequences, supporting complete history and state reconstruction
  • Diamond Architecture (COLA): Adapter → Application → Domain ← Infrastructure four-layer architecture
  • 领域驱动设计(DDD):通过限界上下文进行战略设计,通过实体、值对象、聚合、领域服务、仓库和领域事件进行战术设计
  • 命令查询职责分离(CQRS):读写模型分离,可独立优化
  • 事件溯源:将状态变更记录为事件序列,支持完整历史追溯和状态重建
  • 菱形架构(COLA):适配器→应用→领域←基础设施四层架构

Key Features

关键特性

  • Complete DDD layered architecture supporting COLA V5 pattern
  • Lightweight DDD implementation based on ddd-4-java and cqrs-4-java
  • Technology stack integration: Spring Boot 3.5.x, MyBatis Plus, Jackson, Guava, Swagger, SaToken
  • Dual stack support: WebMVC (traditional Servlet) and WebFlux (reactive)
  • Domain model base capabilities: BaseEntity, BaseRepository, BaseService
  • Domain event support with built-in event publishing mechanism
  • Anti-Corruption Layer (ACL) for external service integration
  • Unified exception handling mechanism
  • 支持COLA V5模式的完整DDD分层架构
  • 基于ddd-4-java和cqrs-4-java的轻量级DDD实现
  • 技术栈集成:Spring Boot 3.5.x、MyBatis Plus、Jackson、Guava、Swagger、SaToken
  • 双栈支持:WebMVC(传统Servlet)和WebFlux(响应式)
  • 领域模型基础能力:BaseEntity、BaseRepository、BaseService
  • 内置事件发布机制的领域事件支持
  • 用于外部服务集成的防腐层(ACL)
  • 统一异常处理机制

Project Types Supported

支持的项目类型

1. Single-Module Monolith (单体单模块)

1. 单体单模块

适用场景: 中小型应用,单个业务领域,团队规模 5-15 人
特点:
  • 单一 Maven 模块
  • 所有层(interfaces, application, domain, infrastructure)在同一模块内
  • 适合快速开发和部署
适用场景: 中小型应用,单一业务领域,团队规模5-15人
特点:
  • 单一Maven模块
  • 所有层级(interfaces、application、domain、infrastructure)位于同一模块内
  • 适合快速开发与部署

2. Multi-Module Monolith (单体多模块)

2. 单体多模块

适用场景: 中大型应用,多个业务域,团队规模 15-50 人
特点:
  • 多个 Maven 模块,按业务域划分
  • 每个业务域包含完整的 DDD 四层架构
  • 共享 common 模块
  • 统一 BOM 和依赖管理
适用场景: 中大型应用,多个业务域,团队规模15-50人
特点:
  • 多个Maven模块,按业务域划分
  • 每个业务域包含完整的DDD四层架构
  • 共享common模块
  • 统一的BOM和依赖管理

3. Microservices (单体微服务)

3. 微服务

适用场景: 大型电商平台,多个业务域,团队规模 50+ 人
特点:
  • 每个服务独立部署
  • 服务间通过 RPC 和消息队列通信
  • 每个服务内部按 DDD 四层架构组织
  • 独立的数据库和配置
适用场景: 大型电商平台,多个业务域,团队规模50+人
特点:
  • 每个服务独立部署
  • 服务间通过RPC和消息队列通信
  • 每个服务内部按DDD四层架构组织
  • 独立的数据库和配置

How to use this skill

如何使用此技能

CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project. Do NOT trigger for generic DDD project creation requests without ddd4j context.
重要提示:仅当用户明确提及创建ddd4j项目时,才可触发此技能。若用户请求的是无ddd4j上下文的通用DDD项目创建,请勿触发。

For New DDD4j Project Creation

新建DDD4j项目

  1. Identify the project type from user requirements:
    • Single-module monolith →
      single-module
    • Multi-module monolith →
      multi-module
    • Microservices →
      microservices
  2. Load the appropriate example from the
    examples/
    directory:
    • examples/single-module.md
      - Single-module monolith structure
    • examples/multi-module.md
      - Multi-module monolith structure
    • examples/microservices.md
      - Microservices structure
    • examples/architecture-patterns.md
      - DDD, Hexagonal, Clean, COLA V5 patterns
  3. Collect project information:
    • groupId
      : Maven group ID (e.g.,
      com.github.hiwepy
      or
      io.ddd4j.base
      )
    • artifactId
      : Maven artifact ID (e.g.,
      ddd4j-douyin
      or
      my-ddd4j-service
      )
    • version
      : Project version (e.g.,
      1.0.0-SNAPSHOT
      )
    • parentVersion
      : Parent POM version (e.g.,
      2023.0.x.20251205-SNAPSHOT
      or reference to
      ddd4j-boot-parent
      )
    • packageBase
      : Base package name (e.g.,
      io.ddd4j.douyin
      or
      com.example.service
      )
    • modules
      : List of business modules (for multi-module/microservices)
    • architecture
      : Architecture pattern (DDD Classic, Hexagonal, Clean, COLA V5)
    • ddd4jBootVersion
      : DDD4j Boot version (if using ddd4j-boot-bom)
  4. Generate project structure:
    • Create directory structure based on selected type
    • Generate
      pom.xml
      files (parent and modules)
    • Create
      package-info.java
      files for each module
    • Generate
      .gitignore
      ,
      LICENSE
      ,
      mvnw
      ,
      mvnw.cmd
    • Create basic directory structure with
      src/main/java
      and
      src/test/java
  5. Save to project directory:
    • Default location: Save directly to the command execution directory (same level as the command)
    • Directory creation: Automatically create the project directory structure if it doesn't exist
    • File naming: Use descriptive names based on project type and module names
  1. 根据用户需求确定项目类型:
    • 单体单模块 →
      single-module
    • 单体多模块 →
      multi-module
    • 微服务 →
      microservices
  2. examples/
    目录加载对应示例
    :
    • examples/single-module.md
      - 单体单模块结构
    • examples/multi-module.md
      - 单体多模块结构
    • examples/microservices.md
      - 微服务结构
    • examples/architecture-patterns.md
      - DDD、六边形、整洁、COLA V5模式
  3. 收集项目信息:
    • groupId
      : Maven组ID(例如:
      com.github.hiwepy
      io.ddd4j.base
    • artifactId
      : Maven工件ID(例如:
      ddd4j-douyin
      my-ddd4j-service
    • version
      : 项目版本(例如:
      1.0.0-SNAPSHOT
    • parentVersion
      : 父POM版本(例如:
      2023.0.x.20251205-SNAPSHOT
      或引用
      ddd4j-boot-parent
    • packageBase
      : 基础包名(例如:
      io.ddd4j.douyin
      com.example.service
    • modules
      : 业务模块列表(适用于多模块/微服务)
    • architecture
      : 架构模式(DDD经典、六边形、整洁、COLA V5)
    • ddd4jBootVersion
      : DDD4j Boot版本(若使用ddd4j-boot-bom)
  4. 生成项目结构:
    • 根据所选类型创建目录结构
    • 生成
      pom.xml
      文件(父模块和子模块)
    • 为每个模块创建
      package-info.java
      文件
    • 生成
      .gitignore
      LICENSE
      mvnw
      mvnw.cmd
    • 创建包含
      src/main/java
      src/test/java
      的基础目录结构
  5. 保存到项目目录:
    • 默认位置: 直接保存到命令执行目录(与命令同级)
    • 目录创建: 若项目目录结构不存在则自动创建
    • 文件命名: 根据项目类型和模块名称使用描述性命名

For Existing Project Validation

现有项目验证

  1. Analyze project structure:
    • Scan project directory for Maven modules
    • Identify layer structure (interfaces, application, domain, infrastructure)
    • Check package naming conventions
    • Verify directory organization
  2. Identify project type:
    • Single-module: Single
      pom.xml
      at root, all layers in one module
    • Multi-module: Parent
      pom.xml
      with multiple modules, each module has complete layers
    • Microservices: Multiple services, each with independent structure
  3. Validate against standards:
    • Check DDD layer compliance
    • Verify dependency direction (interfaces → application → domain ← infrastructure)
    • Validate package naming (
      {basePackage}.{module}.{layer}
      )
    • Check for required directories (
      src/main/java
      ,
      src/test/java
      )
    • Verify
      package-info.java
      files exist
  4. Generate validation report:
    • List identified issues
    • Provide recommendations
    • Suggest fixes for non-compliant structures
  1. 分析项目结构:
    • 扫描项目目录中的Maven模块
    • 识别层级结构(interfaces、application、domain、infrastructure)
    • 检查包命名规范
    • 验证目录组织方式
  2. 确定项目类型:
    • 单体单模块: 根目录下仅有一个
      pom.xml
      ,所有层级位于同一模块
    • 单体多模块: 父
      pom.xml
      包含多个模块,每个模块拥有完整层级
    • 微服务: 多个服务,每个服务具有独立结构
  3. 对照标准验证:
    • 检查DDD层级合规性
    • 验证依赖方向(interfaces → application → domain ← infrastructure)
    • 验证包命名(
      {basePackage}.{module}.{layer}
    • 检查是否存在必需目录(
      src/main/java
      src/test/java
    • 验证
      package-info.java
      文件是否存在
  4. 生成验证报告:
    • 列出识别到的问题
    • 提供改进建议
    • 针对不合规结构提出修复方案

Output Format and File Saving

输出格式与文件保存

When generating a project structure, follow this response structure:
  1. Save the files first: Create the project structure directly in the command execution directory
    • The project will be created at the same level as where the command is executed
    • Generate all required files and directories (pom.xml, src/, etc.)
    • Use the artifactId as the project root directory name
  2. Inform the user: Tell them where the files were saved
  3. Display the structure: Show the generated directory structure in a code block
Example Response Structure:
  • First line: "I've created the DDD project structure and saved it to
    ./{artifactId}/
    in the current directory."
  • Then show the structure wrapped in a code block:
    • Start with: three backticks +
      text
      + newline
    • Then the directory structure
    • End with: three backticks + newline
Critical Requirements:
  • Always save project files directly to the command execution directory (same level)
  • Use artifactId as the project root directory name
  • Create the directory structure automatically if it doesn't exist
  • Generate complete project structure with all required files
  • Follow Maven and DDD conventions strictly
生成项目结构时,请遵循以下响应结构:
  1. 先保存文件: 直接在命令执行目录中创建项目结构
    • 项目将创建在命令执行的同级目录
    • 生成所有必需的文件和目录(pom.xml、src/等)
    • 使用artifactId作为项目根目录名称
  2. 通知用户: 告知用户文件保存位置
  3. 展示结构: 在代码块中显示生成的目录结构
示例响应结构:
  • 第一行: "我已创建DDD项目结构并保存到当前目录的
    ./{artifactId}/
    路径下。"
  • 随后在代码块中展示结构:
    • 开头: 三个反引号 +
      text
      + 换行
    • 然后是目录结构
    • 结尾: 三个反引号 + 换行
关键要求:
  • 始终将项目文件直接保存到命令执行目录(同级)
  • 使用artifactId作为项目根目录名称
  • 若目录结构不存在则自动创建
  • 生成包含所有必需文件的完整项目结构
  • 严格遵循Maven和DDD规范

Project Structure Standards

项目结构标准

Package Naming Convention

包命名规范

For multi-module projects:
{basePackage}.{moduleName}.{layerName}
Examples:
  • io.ddd4j.douyin.api.domain
    - API module, domain layer
  • io.ddd4j.douyin.api.application
    - API module, application layer
  • io.ddd4j.douyin.api.interfaces
    - API module, interfaces layer
  • io.ddd4j.douyin.api.infrastructure
    - API module, infrastructure layer
对于多模块项目:
{basePackage}.{moduleName}.{layerName}
示例:
  • io.ddd4j.douyin.api.domain
    - API模块,领域层
  • io.ddd4j.douyin.api.application
    - API模块,应用层
  • io.ddd4j.douyin.api.interfaces
    - API模块,接口层
  • io.ddd4j.douyin.api.infrastructure
    - API模块,基础设施层

Required Files

必需文件

Every module must have:
  • pom.xml
    - Maven configuration
  • src/main/java/{package}/package-info.java
    - Package documentation
  • src/test/java/
    - Test directory structure
  • .gitignore
    - Git ignore rules (at root)
  • LICENSE
    - License file (at root)
  • mvnw
    ,
    mvnw.cmd
    - Maven wrapper (at root)
每个模块必须包含:
  • pom.xml
    - Maven配置文件
  • src/main/java/{package}/package-info.java
    - 包文档
  • src/test/java/
    - 测试目录结构
  • .gitignore
    - Git忽略规则(根目录)
  • LICENSE
    - 许可证文件(根目录)
  • mvnw
    ,
    mvnw.cmd
    - Maven包装器(根目录)

Layer Dependencies

层级依赖

Correct dependency direction:
interfaces → application → domain ← infrastructure
Rules:
  • Domain layer must not depend on any other layer
  • Infrastructure layer implements domain layer interfaces
  • Application layer depends on domain layer
  • Interfaces layer depends on application layer
正确的依赖方向:
interfaces → application → domain ← infrastructure
规则:
  • 领域层不得依赖任何其他层级
  • 基础设施层实现领域层接口
  • 应用层依赖领域层
  • 接口层依赖应用层

Architecture Patterns

架构模式

The skill supports four architecture patterns:
  1. DDD Classic Layered Architecture (DDD 经典分层架构)
    • Layers: interfaces, application, domain, infrastructure
    • Reference:
      docs/1、DDD 经典分层架构目录结构.md
      and
      examples/architecture-patterns.md#ddd-classic
  2. Hexagonal Architecture (六边形架构)
    • Ports and Adapters pattern
    • Reference:
      docs/2、六边形架构详细目录结构参考.md
      and
      examples/architecture-patterns.md#hexagonal
  3. Clean Architecture (整洁架构)
    • Entities, Use Cases, Interface Adapters
    • Reference:
      docs/3、整洁架构详细目录结构参考.md
      and
      examples/architecture-patterns.md#clean
  4. COLA V5 (菱形架构)
    • Adapter → App → Domain ← Infrastructure
    • Reference:
      docs/4、COLA V5 架构详细目录结构参考.md
      and
      examples/architecture-patterns.md#cola-v5
此技能支持四种架构模式:
  1. DDD经典分层架构
    • 层级: 接口层、应用层、领域层、基础设施层
    • 参考:
      docs/1、DDD 经典分层架构目录结构.md
      examples/architecture-patterns.md#ddd-classic
  2. 六边形架构
    • 端口与适配器模式
    • 参考:
      docs/2、六边形架构详细目录结构参考.md
      examples/architecture-patterns.md#hexagonal
  3. 整洁架构
    • 实体、用例、接口适配器
    • 参考:
      docs/3、整洁架构详细目录结构参考.md
      examples/architecture-patterns.md#clean
  4. COLA V5(菱形架构)
    • 适配器→应用→领域←基础设施
    • 参考:
      docs/4、COLA V5 架构详细目录结构参考.md
      examples/architecture-patterns.md#cola-v5

Validation Rules

验证规则

When checking existing projects, validate:
  1. Structure Compliance:
    • ✓ Correct layer organization
    • ✓ Proper module separation
    • ✓ Package naming conventions
  2. Dependency Rules:
    • ✓ Domain layer has no external dependencies
    • ✓ Infrastructure implements domain interfaces
    • ✓ Correct dependency direction
  3. File Organization:
    • ✓ Required directories exist
    • package-info.java
      files present
    • ✓ Maven configuration correct
  4. Naming Conventions:
    • ✓ Package names follow convention
    • ✓ Module names are descriptive
    • ✓ Layer names are standard
检查现有项目时,需验证以下内容:
  1. 结构合规性:
    • ✓ 正确的层级组织
    • ✓ 合理的模块拆分
    • ✓ 包命名规范
  2. 依赖规则:
    • ✓ 领域层无外部依赖
    • ✓ 基础设施层实现领域层接口
    • ✓ 正确的依赖方向
  3. 文件组织:
    • ✓ 必需目录存在
    • package-info.java
      文件存在
    • ✓ Maven配置正确
  4. 命名规范:
    • ✓ 包名符合规范
    • ✓ 模块名称具有描述性
    • ✓ 层级名称标准

Examples

示例

See the
examples/
directory for:
  • single-module.md
    - Complete single-module monolith example
  • multi-module.md
    - Complete multi-module monolith example (based on ddd4j-douyin structure)
  • microservices.md
    - Complete microservices example
  • architecture-patterns.md
    - All four architecture patterns with detailed structures
请查看
examples/
目录获取:
  • single-module.md
    - 完整的单体单模块示例
  • multi-module.md
    - 完整的单体多模块示例(基于ddd4j-douyin结构)
  • microservices.md
    - 完整的微服务示例
  • architecture-patterns.md
    - 包含四种架构模式的详细结构

Keywords

关键词

English keywords: ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
Chinese keywords (中文关键词): ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
IMPORTANT: All keywords must include "ddd4j" to avoid false triggers. Generic terms like "DDD 项目" (DDD project) or "创建项目" (create project) without "ddd4j" should NOT trigger this skill.
英文关键词: ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
中文关键词: ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
重要提示: 所有关键词必须包含“ddd4j”以避免误触发。未包含“ddd4j”的通用术语,如“DDD 项目”或“创建项目”,请勿触发此技能。