Skip to content

DDD四层架构(微服务样板)

全栈工程:Java 11 / Spring Boot 后端 + Vite + Vue 3 前端,DDD 四层架构(adapter → application → domain ← infrastructure)

技术栈

技术
后端Java 11 / Spring Boot 2.2.x
前端Vite + Vue 3 + TypeScript
网关Spring Cloud Gateway + OpenFeign

项目结构

/
├── frontend/                      # Vite + Vue 3 + TypeScript
├── backends/
│   ├── service-bff/              # API Gateway(鉴权/路由)
│   ├── service-base/             # 基础域服务(用户/网点/日志/定时)
│   ├── service-domain-demo/      # 示例域服务 + 团队规范样板
│   └── package-common/           # 通用 SDK
└── docs/
    ├── designs/                  # 系统设计现状
    ├── features/                 # 需求原始规格
    ├── plans/                   # 执行方案
    └── standards/               # 开发规范

四层架构规范

层级职责
adapter对外适配层(Controller/MQ listener),协议转换 + 参数校验
application用例编排层(AppService),组合 domain 行为、管理事务边界
domain领域模型层,承载业务不变量与状态机
infrastructure基础设施层(DB/外部API/缓存/锁)

依赖方向:adapter → application → domain ← infrastructure

运行时形态

Client → frontend → service-bff(鉴权/路由)→ service-base / service-domain-demo

相关概念

  • [[harness-engineering]] — 驭化工程,Harness 模式

Sources

  • GitHub domain-driven-design/ddd-harness-microservices (2026-06-04)

Released under the MIT License.