dflow-sdd-ddd 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/README.en.md +5 -5
- package/README.md +8 -8
- package/docs/examples-by-stack.md +516 -0
- package/docs/release-versioning-policy.md +13 -0
- package/lib/init.js +187 -24
- package/package.json +1 -1
- package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +25 -15
- package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
- package/templates/brownfield/scaffolding/Git-principles-trunk.md +1 -1
- package/templates/brownfield/scaffolding/_conventions.md +1 -1
- package/templates/brownfield/scaffolding/_overview.md +40 -29
- package/templates/brownfield/templates/CLAUDE.md +25 -17
- package/templates/brownfield/templates/context-definition.md +4 -4
- package/templates/brownfield/templates/context-map.md +1 -1
- package/templates/brownfield/templates/lightweight-spec.md +3 -1
- package/templates/brownfield/templates/models.md +1 -1
- package/templates/brownfield/templates/phase-spec.md +10 -8
- package/templates/brownfield/templates/tech-debt.md +2 -2
- package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +6 -6
- package/templates/greenfield/scaffolding/Git-principles-gitflow.md +2 -2
- package/templates/greenfield/scaffolding/Git-principles-trunk.md +2 -2
- package/templates/greenfield/scaffolding/_overview.md +29 -11
- package/templates/greenfield/templates/CLAUDE.md +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Project: {系統名稱} —
|
|
1
|
+
# Project: {系統名稱} — {Framework}
|
|
2
2
|
|
|
3
3
|
**重要:所有開發工作都必須遵循本文件定義的流程。**
|
|
4
4
|
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
### Background
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
這是一個運行中的既有系統,使用 {Framework} / {Language},目前持續新增與修改功能。
|
|
14
|
+
目前採用 SDD 流程,同時為 DDD 與 target architecture 做準備。
|
|
15
15
|
|
|
16
16
|
### Project Structure
|
|
17
17
|
|
|
18
18
|
```
|
|
19
19
|
dflow/specs/
|
|
20
20
|
├── shared/ # 專案級治理文件(由 dflow init 寫入)
|
|
21
|
-
│ ├── _overview.md #
|
|
21
|
+
│ ├── _overview.md # 系統現況與 target architecture
|
|
22
22
|
│ └── _conventions.md # 規格撰寫慣例與模板
|
|
23
23
|
├── domain/ # 領域知識
|
|
24
24
|
│ ├── glossary.md # 術語表(Ubiquitous Language)
|
|
@@ -40,16 +40,24 @@ dflow/specs/
|
|
|
40
40
|
└── tech-debt.md # 技術債與遷移備忘
|
|
41
41
|
|
|
42
42
|
src/
|
|
43
|
-
├── Domain/ #
|
|
43
|
+
├── Domain/ # 抽離的領域邏輯(framework-pure)
|
|
44
44
|
│ ├── {Context}/
|
|
45
45
|
│ │ ├── Entities/
|
|
46
46
|
│ │ ├── ValueObjects/
|
|
47
47
|
│ │ ├── Services/
|
|
48
48
|
│ │ └── Interfaces/
|
|
49
49
|
│ └── SharedKernel/
|
|
50
|
-
└──
|
|
50
|
+
└── Delivery/ # delivery-layer code(entrypoints, controllers, handlers)
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
> **目錄命名說明**:上方 `src/Domain/` / `src/Delivery/` 是 Clean
|
|
54
|
+
> Architecture 通用示意,不限 stack。請依專案實際慣例對應(例:Java/Spring 用
|
|
55
|
+
> `src/main/java/com/example/domain/`、Node/TS 用 `src/domain/` /
|
|
56
|
+
> `src/routes/`、Python 用 `domain/` package、Go 用 `internal/domain/` /
|
|
57
|
+
> `internal/handler/`、.NET 用 `src/{Project}.Domain/` + `.csproj` 分層)。
|
|
58
|
+
> 完整 per-stack 範例見 `docs/examples-by-stack.md`。重點是
|
|
59
|
+
> `src/Domain/`(或對應命名)保持與 delivery/entrypoint code 獨立。
|
|
60
|
+
|
|
53
61
|
---
|
|
54
62
|
|
|
55
63
|
## Development Workflow
|
|
@@ -58,9 +66,9 @@ src/
|
|
|
58
66
|
|
|
59
67
|
### Core Principles
|
|
60
68
|
1. **Spec Before Code** — 沒有規格就不寫實作
|
|
61
|
-
2. **Domain Extraction** — 業務邏輯屬於 `src/Domain/`,不屬於
|
|
69
|
+
2. **Domain Extraction** — 業務邏輯屬於 `src/Domain/`,不屬於 delivery/entrypoint code(presentation/UI layer、controllers、handlers、jobs、message consumers、data pipelines、stored procedures)
|
|
62
70
|
3. **Ubiquitous Language** — 使用 `dflow/specs/domain/glossary.md` 中定義的術語
|
|
63
|
-
4. **Migration Awareness** —
|
|
71
|
+
4. **Migration Awareness** — 每個決策都要考慮 target architecture
|
|
64
72
|
|
|
65
73
|
### Three Ceremony Tiers
|
|
66
74
|
|
|
@@ -81,8 +89,8 @@ src/
|
|
|
81
89
|
1. 建 feature 目錄 `dflow/specs/features/active/{SPEC-ID}-{slug}/`
|
|
82
90
|
2. 建 `_index.md`(feature dashboard)+ 第一份 `phase-spec-YYYY-MM-DD-{slug}.md`
|
|
83
91
|
3. 識別涉及的領域概念,更新 `dflow/specs/domain/` 下的對應文件
|
|
84
|
-
4. 盡可能將業務邏輯實作在 `src/Domain/`
|
|
85
|
-
5.
|
|
92
|
+
4. 盡可能將業務邏輯實作在 `src/Domain/` 中(語言純粹的 class,不依賴 delivery framework)
|
|
93
|
+
5. Delivery/entrypoint code 僅負責輸入解析、協調流程與輸出綁定,呼叫 Domain 層處理邏輯
|
|
86
94
|
6. 撰寫測試驗證 Domain 層行為符合規格
|
|
87
95
|
|
|
88
96
|
### New Phase
|
|
@@ -95,7 +103,7 @@ src/
|
|
|
95
103
|
2. 若偵測到改動與 completed feature 相關,主動詢問是否為 follow-up
|
|
96
104
|
(follow-up 走新建 feature + `follow-up-of` 鏈回原 feature;不把 T2/T3
|
|
97
105
|
寫回 completed 目錄)
|
|
98
|
-
3. 如果該功能的邏輯還在
|
|
106
|
+
3. 如果該功能的邏輯還在 delivery/entrypoint code 中,評估是否值得先抽離到 Domain 層
|
|
99
107
|
4. 在 `dflow/specs/migration/tech-debt.md` 記錄發現的技術債
|
|
100
108
|
|
|
101
109
|
### Bug Fix
|
|
@@ -136,12 +144,12 @@ bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
|
|
|
136
144
|
### Domain Layer Rules (`src/Domain/`)
|
|
137
145
|
|
|
138
146
|
此目錄中的程式碼必須遵守:
|
|
139
|
-
- ❌
|
|
147
|
+
- ❌ 不可引用任何 delivery-framework 命名空間(例:HTTP 請求/回應物件、Session/Cookie context、job runner context、CLI flag parser、ViewState 類等)
|
|
140
148
|
- ❌ 不可直接存取資料庫(使用 interface + Repository pattern)
|
|
141
|
-
- ❌ 不可使用
|
|
142
|
-
- ❌ 不可有 UI 相關邏輯(格式化顯示、
|
|
143
|
-
- ✅
|
|
144
|
-
- ✅ 所有公開行為都能在沒有
|
|
149
|
+
- ❌ 不可使用 delivery-framework runtime context(例:HTTP request/response、session/cookie、job runner state、CLI args)
|
|
150
|
+
- ❌ 不可有 UI / entrypoint 相關邏輯(格式化顯示、controller/page/handler 引用)
|
|
151
|
+
- ✅ 語言純粹的 class(不依賴 delivery framework),可直接搬到 target architecture
|
|
152
|
+
- ✅ 所有公開行為都能在沒有 delivery infrastructure 的情況下測試
|
|
145
153
|
|
|
146
154
|
### Glossary
|
|
147
155
|
|
|
@@ -152,6 +160,6 @@ bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
|
|
|
152
160
|
|
|
153
161
|
- 開發者提出任何功能需求時,先引導建立 spec
|
|
154
162
|
- 在回答 Domain 相關問題時,優先參考 `dflow/specs/domain/` 中的文件
|
|
155
|
-
- 發現
|
|
163
|
+
- 發現 delivery/entrypoint code 中的業務邏輯時,建議抽離到 `src/Domain/`
|
|
156
164
|
- 每次開發循環結束時,提醒更新術語表和技術債記錄
|
|
157
165
|
- 建立分支前,確認命名符合規範且對應 spec 存在
|
|
@@ -49,9 +49,9 @@ created: {YYYY-MM-DD}
|
|
|
49
49
|
|
|
50
50
|
## Code Mapping
|
|
51
51
|
|
|
52
|
-
### Current
|
|
53
|
-
-
|
|
52
|
+
### Current Delivery/Entrypoint Mapping
|
|
53
|
+
- Delivery/entrypoint code: `{project/path/or/namespace}`
|
|
54
54
|
- Domain: `src/Domain/{Context}/`
|
|
55
55
|
|
|
56
|
-
###
|
|
57
|
-
-
|
|
56
|
+
### Target Architecture
|
|
57
|
+
- 預計作為 target architecture 中的獨立模組、服務、套件或 bounded context
|
|
@@ -69,7 +69,9 @@ Template note (for AI):
|
|
|
69
69
|
|
|
70
70
|
> Keep T2 Light tasks concise. If the fix scope starts to expand, AI should pause and ask the developer whether to keep this as T2 or upgrade it to T1. Do not auto-upgrade based on task count alone.
|
|
71
71
|
>
|
|
72
|
-
> Recommended layer tags (
|
|
72
|
+
> Recommended layer tags (Brownfield): `DOMAIN` / `DELIVERY` / `DATA` / `TEST` / `DOC`
|
|
73
|
+
> (`DELIVERY` covers delivery/entrypoint code: presentation/UI layer, controllers,
|
|
74
|
+
> handlers, jobs, message consumers, data pipelines, or stored procedures)
|
|
73
75
|
|
|
74
76
|
- [ ] {LAYER}-1: {minimal required change}
|
|
75
77
|
- [ ] TEST-1: {minimal verification / regression test}
|
|
@@ -131,9 +131,11 @@ Then {新的預期結果}
|
|
|
131
131
|
|
|
132
132
|
## Implementation Notes <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
133
133
|
|
|
134
|
-
### Current
|
|
134
|
+
### Current Delivery-Layer Implementation
|
|
135
135
|
|
|
136
|
-
> 在現有架構下如何實作?哪些
|
|
136
|
+
> 在現有架構下如何實作?哪些 business logic embedded in delivery/entrypoint code
|
|
137
|
+
> (presentation/UI layer、controllers、handlers、jobs、message consumers、data
|
|
138
|
+
> pipelines、stored procedures)會被修改?
|
|
137
139
|
|
|
138
140
|
### Domain Layer Design
|
|
139
141
|
|
|
@@ -143,13 +145,13 @@ Then {新的預期結果}
|
|
|
143
145
|
// 關鍵 Domain 類別草稿
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
### Keep Code
|
|
148
|
+
### Keep Delivery/Entrypoint Code Thin
|
|
147
149
|
|
|
148
|
-
>
|
|
150
|
+
> Delivery/entrypoint code 只負責:解析輸入 -> 呼叫 Domain 層 -> 回傳或顯示結果
|
|
149
151
|
|
|
150
|
-
###
|
|
152
|
+
### Target Architecture Considerations
|
|
151
153
|
|
|
152
|
-
>
|
|
154
|
+
> target architecture 需要注意的事項,或者現在的設計如何幫助後續演進。
|
|
153
155
|
|
|
154
156
|
## Data Structure Changes <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
155
157
|
|
|
@@ -178,13 +180,13 @@ Then {新的預期結果}
|
|
|
178
180
|
> 格式:`[LAYER]-[NUMBER]: 任務描述`
|
|
179
181
|
> 分類標籤(Brownfield track):
|
|
180
182
|
> - `DOMAIN` — Domain 層類別、VO、Service、Interface
|
|
181
|
-
> - `
|
|
183
|
+
> - `DELIVERY` — Delivery-layer code(entrypoints, controllers, handlers, UI/API adapters)
|
|
182
184
|
> - `DATA` — 資料表 schema 或 Repository 實作
|
|
183
185
|
> - `TEST` — 測試案例
|
|
184
186
|
> 本段在 spec 歸檔(搬到 `completed/`)前應確認全部勾選,或明確標註未完成項的 follow-up。
|
|
185
187
|
|
|
186
188
|
- [ ] DOMAIN-1: {任務描述}
|
|
187
189
|
- [ ] DOMAIN-2: {任務描述}
|
|
188
|
-
- [ ]
|
|
190
|
+
- [ ] DELIVERY-1: {任務描述}
|
|
189
191
|
- [ ] DATA-1: {任務描述}
|
|
190
192
|
- [ ] TEST-1: {任務描述}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# Migration Tech Debt
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Target-architecture debt backlog discovered during SDD/DDD work.
|
|
6
6
|
|
|
7
7
|
## Debt Items
|
|
8
8
|
|
|
9
9
|
| Item | Location | Description | Severity | Migration impact | Status |
|
|
10
10
|
|---|---|---|---|---|---|
|
|
11
|
-
| {Debt item} | `{file/path/or/namespace}` | {問題描述} | {Low/Medium/High/Critical} | {對
|
|
11
|
+
| {Debt item} | `{file/path/or/namespace}` | {問題描述} | {Low/Medium/High/Critical} | {對 target architecture 的影響} | {open/planned/in-progress/done} |
|
|
12
12
|
|
|
13
13
|
## Follow-up Notes
|
|
14
14
|
|
|
@@ -29,7 +29,7 @@ keeps every project's `CLAUDE.md` scannable for AI in the same shape.
|
|
|
29
29
|
## Snippet to merge into `CLAUDE.md`
|
|
30
30
|
|
|
31
31
|
```markdown
|
|
32
|
-
# Project: {系統名稱} —
|
|
32
|
+
# Project: {系統名稱} — Clean Architecture + DDD
|
|
33
33
|
|
|
34
34
|
**重要:所有開發工作都必須遵循本文件定義的流程。**
|
|
35
35
|
|
|
@@ -45,8 +45,8 @@ keeps every project's `CLAUDE.md` scannable for AI in the same shape.
|
|
|
45
45
|
- **Users / Customers**: {使用者 / 客戶描述}
|
|
46
46
|
- **Team**: {團隊組成;e.g. "全端工程團隊,3-5 人;DDD 經驗中等"}
|
|
47
47
|
- **Dflow Adoption Context**: {新專案 greenfield / 既有系統導入 / 遷移等}
|
|
48
|
-
- **Tech Stack**:
|
|
49
|
-
|
|
48
|
+
- **Tech Stack**: {Framework} {Framework version};{ORM / persistence} {ORM version} / {Mediator} / {其他};
|
|
49
|
+
{Language}
|
|
50
50
|
|
|
51
51
|
### Architecture (Clean Architecture)
|
|
52
52
|
|
|
@@ -60,7 +60,7 @@ Presentation → Application → Domain ← Infrastructure
|
|
|
60
60
|
|---|---|---|
|
|
61
61
|
| Domain | 業務規則、Aggregate、Value Object、Domain Event | 依賴外部套件、存取資料庫、處理 HTTP |
|
|
62
62
|
| Application | 編排領域操作、CQRS、驗證、DTO | 包含業務邏輯、直接存取資料庫 |
|
|
63
|
-
| Infrastructure |
|
|
63
|
+
| Infrastructure | {ORM / persistence}、外部 API、檔案存取 | 包含業務邏輯 |
|
|
64
64
|
| Presentation | HTTP 端點、Request/Response | 包含業務邏輯、直接操作 Domain 物件 |
|
|
65
65
|
|
|
66
66
|
### Project Structure
|
|
@@ -120,7 +120,7 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
120
120
|
|
|
121
121
|
### Domain Layer Rules (Hard Invariants)
|
|
122
122
|
|
|
123
|
-
- ❌
|
|
123
|
+
- ❌ 不可有任何外部套件依賴(語言純粹 types)
|
|
124
124
|
- ❌ 不可有 ORM 屬性(`[Table]`、`[Column]` 等)
|
|
125
125
|
- ❌ 不可有序列化屬性(`[JsonProperty]` 等)
|
|
126
126
|
- ❌ 不可有 `DbContext`、`IConfiguration`、`HttpClient`
|
|
@@ -133,7 +133,7 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
133
133
|
|
|
134
134
|
{此段由專案自行填入。例如:}
|
|
135
135
|
|
|
136
|
-
- **本專案使用
|
|
136
|
+
- **本專案使用 {Mediator} 做 Command / Query dispatch(若適用)**,Application 層
|
|
137
137
|
Command / Query Handler 命名為 `{Name}CommandHandler` /
|
|
138
138
|
`{Name}QueryHandler`
|
|
139
139
|
- **整合測試使用 {Testcontainers / WebApplicationFactory / 其他}**;
|
|
@@ -174,7 +174,7 @@ Before making key Git operations:
|
|
|
174
174
|
`context-map.md` reflect the feature's net changes
|
|
175
175
|
- [ ] `dflow/specs/domain/glossary.md` updated with any new terms
|
|
176
176
|
- [ ] `dflow/specs/architecture/tech-debt.md` updated with any debt discovered
|
|
177
|
-
- [ ] Domain project has zero external
|
|
177
|
+
- [ ] Domain project has zero external package dependencies
|
|
178
178
|
- [ ] No ORM / serialization attributes on Domain entities
|
|
179
179
|
- [ ] Domain unit tests pass (invariants + value object equality)
|
|
180
180
|
|
|
@@ -334,7 +334,7 @@ exists, e.g. `.github/workflows/ci.yml` or `azure-pipelines.yml`.}
|
|
|
334
334
|
|
|
335
335
|
### Suggested CI gates for Clean Architecture
|
|
336
336
|
|
|
337
|
-
- Verify Domain project has zero (or allow-listed)
|
|
337
|
+
- Verify Domain project has zero (or allow-listed) external package deps
|
|
338
338
|
- Run Domain unit tests + Application tests on every PR
|
|
339
339
|
- Run Integration tests on `develop` and `release/*` branches
|
|
340
340
|
- Verify EF migrations build cleanly
|
|
@@ -249,7 +249,7 @@ Before making key Git operations:
|
|
|
249
249
|
`context-map.md` reflect the feature's net changes
|
|
250
250
|
- [ ] `dflow/specs/domain/glossary.md` updated with any new terms
|
|
251
251
|
- [ ] `dflow/specs/architecture/tech-debt.md` updated with any debt discovered
|
|
252
|
-
- [ ] Domain project has zero external
|
|
252
|
+
- [ ] Domain project has zero external package dependencies
|
|
253
253
|
- [ ] No ORM / serialization attributes on Domain entities
|
|
254
254
|
- [ ] Domain unit tests pass (invariants + value object equality)
|
|
255
255
|
- [ ] CI is green (all required checks passing)
|
|
@@ -359,7 +359,7 @@ exists, e.g. `.github/workflows/ci.yml` or `azure-pipelines.yml`.}
|
|
|
359
359
|
|
|
360
360
|
### Suggested CI gates for Clean Architecture
|
|
361
361
|
|
|
362
|
-
- Verify Domain project has zero (or allow-listed)
|
|
362
|
+
- Verify Domain project has zero (or allow-listed) external package deps
|
|
363
363
|
- Run Domain unit tests + Application tests on every PR
|
|
364
364
|
- Run Integration tests on `main` and pre-deploy
|
|
365
365
|
- Verify EF migrations build cleanly
|
|
@@ -30,19 +30,18 @@ delivers. Keep it non-technical enough that a new hire can skim it in
|
|
|
30
30
|
|
|
31
31
|
## Technical Architecture
|
|
32
32
|
|
|
33
|
-
This project
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
This project follows **Clean Architecture** and **Domain-Driven Design
|
|
34
|
+
(DDD)**. Dependencies flow inward only — the Domain layer is the core
|
|
35
|
+
and depends on nothing.
|
|
36
36
|
|
|
37
37
|
### Stack
|
|
38
38
|
|
|
39
39
|
| Item | Choice |
|
|
40
40
|
|------|--------|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
| Mediator | {e.g. MediatR, internal CQRS dispatcher, or none} |
|
|
41
|
+
| Language | {Language} |
|
|
42
|
+
| Framework | {Framework} {Framework version} |
|
|
43
|
+
| ORM / persistence | {ORM / persistence} {ORM version} |
|
|
44
|
+
| Mediator | {Mediator} (or none) |
|
|
46
45
|
| Validation | {e.g. FluentValidation} |
|
|
47
46
|
| Database | {e.g. PostgreSQL 16, SQL Server 2022} |
|
|
48
47
|
| Auth | {e.g. JWT bearer, OIDC via Azure AD, cookie auth} |
|
|
@@ -57,13 +56,32 @@ Presentation → Application → Domain ← Infrastructure
|
|
|
57
56
|
|
|
58
57
|
| Layer | Responsibilities | Must NOT |
|
|
59
58
|
|-------|------------------|----------|
|
|
60
|
-
| Domain | Aggregates, Entities, Value Objects, Domain Events, Domain Services, repository interfaces | Depend on
|
|
59
|
+
| Domain | Aggregates, Entities, Value Objects, Domain Events, Domain Services, repository interfaces | Depend on package-manager libraries outside the project's allow-list; know about ORM/persistence frameworks, HTTP, DI containers |
|
|
61
60
|
| Application | Commands / Queries (CQRS), Validators, DTOs, Event Handlers, orchestration | Contain business logic; access database directly |
|
|
62
|
-
| Infrastructure |
|
|
61
|
+
| Infrastructure | ORM / persistence configuration, repository implementations, external API clients | Contain business logic |
|
|
63
62
|
| Presentation | HTTP endpoints, Request / Response mapping, auth + middleware | Contain business logic; expose Domain objects directly |
|
|
64
63
|
|
|
65
64
|
### Project Layout
|
|
66
65
|
|
|
66
|
+
> **Note**: The project layout below uses .NET/C# conventions —
|
|
67
|
+
> project-level namespaces like `{Project}.Domain` and a separate `.csproj`
|
|
68
|
+
> per layer. This is shown as a concrete example so you can see "what a
|
|
69
|
+
> real Clean Architecture layout looks like".
|
|
70
|
+
>
|
|
71
|
+
> If this project's stack is **not** .NET, this layout does **not**
|
|
72
|
+
> literally apply — translate to the conventions of your stack:
|
|
73
|
+
>
|
|
74
|
+
> - Java/Spring: `com.example.domain` / `com.example.application` packages, often a multi-module Maven/Gradle build
|
|
75
|
+
> - Node/TypeScript: `src/domain/` / `src/application/` folders, monorepo workspaces optional
|
|
76
|
+
> - Python: `domain/` / `application/` packages
|
|
77
|
+
> - Go: `internal/domain/` / `internal/application/`
|
|
78
|
+
> - PHP/Laravel: `app/Domain/` / `app/Application/`
|
|
79
|
+
>
|
|
80
|
+
> For full per-stack examples, see `docs/examples-by-stack.md`. If the
|
|
81
|
+
> convention for your stack is unclear, consult authoritative sources
|
|
82
|
+
> for the stack (e.g., its official project structure guide) or ask the
|
|
83
|
+
> developer before placing code.
|
|
84
|
+
|
|
67
85
|
```
|
|
68
86
|
src/
|
|
69
87
|
├── {Project}.Domain/
|
|
@@ -147,7 +165,7 @@ format / MADR / other}.
|
|
|
147
165
|
Initial ADRs that typically exist:
|
|
148
166
|
|
|
149
167
|
- **ADR-0001** — Choice of ORM / persistence approach
|
|
150
|
-
- **ADR-0002** — CQRS +
|
|
168
|
+
- **ADR-0002** — CQRS + mediator/dispatcher vs direct handlers
|
|
151
169
|
- **ADR-0003** — Auth strategy
|
|
152
170
|
|
|
153
171
|
---
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Project: {系統名稱} —
|
|
1
|
+
# Project: {系統名稱} — Clean Architecture + DDD
|
|
2
2
|
|
|
3
3
|
**重要:所有開發工作都必須遵循本文件定義的流程。**
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
### Background
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
這是一個遵循 Clean Architecture 與 Domain-Driven Design 的新建專案;具體 stack 詳見 `dflow/specs/shared/_overview.md`。
|
|
14
14
|
採用 SDD 流程,所有開發工作必須遵循本文件定義的流程。
|
|
15
15
|
|
|
16
16
|
### Architecture (Clean Architecture)
|
|
@@ -27,7 +27,7 @@ Presentation → Application → Domain ← Infrastructure
|
|
|
27
27
|
|---|---|---|
|
|
28
28
|
| Domain | 業務規則、Aggregate、Value Object、Domain Event | 依賴外部套件、存取資料庫、處理 HTTP |
|
|
29
29
|
| Application | 編排領域操作、CQRS、驗證、DTO | 包含業務邏輯、直接存取資料庫 |
|
|
30
|
-
| Infrastructure |
|
|
30
|
+
| Infrastructure | {ORM / persistence}、外部 API、檔案存取 | 包含業務邏輯 |
|
|
31
31
|
| Presentation | HTTP 端點、Request/Response | 包含業務邏輯、直接操作 Domain 物件 |
|
|
32
32
|
|
|
33
33
|
### Project Structure
|
|
@@ -35,7 +35,7 @@ Presentation → Application → Domain ← Infrastructure
|
|
|
35
35
|
```
|
|
36
36
|
dflow/specs/
|
|
37
37
|
├── shared/ # 專案級治理文件(由 dflow init 寫入)
|
|
38
|
-
│ ├── _overview.md #
|
|
38
|
+
│ ├── _overview.md # 系統概覽與架構方向
|
|
39
39
|
│ └── _conventions.md # 規格撰寫慣例
|
|
40
40
|
├── domain/
|
|
41
41
|
│ ├── glossary.md
|
|
@@ -154,7 +154,7 @@ bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
|
|
|
154
154
|
|
|
155
155
|
### Domain Layer Rules
|
|
156
156
|
|
|
157
|
-
- ❌
|
|
157
|
+
- ❌ 不可有任何外部套件依賴(語言純粹 types)
|
|
158
158
|
- ❌ 不可有 ORM 屬性([Table], [Column] 等)
|
|
159
159
|
- ❌ 不可有序列化屬性([JsonProperty] 等)
|
|
160
160
|
- ❌ 不可有 DbContext、IConfiguration、HttpClient
|