agile-context-engineering 0.3.0 → 0.5.1

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.
Files changed (139) hide show
  1. package/.claude-plugin/marketplace.json +18 -0
  2. package/.claude-plugin/plugin.json +10 -0
  3. package/CHANGELOG.md +7 -1
  4. package/LICENSE +51 -51
  5. package/README.md +330 -318
  6. package/agents/ace-code-discovery-analyst.md +245 -245
  7. package/agents/ace-code-integration-analyst.md +248 -248
  8. package/agents/ace-code-reviewer.md +375 -375
  9. package/agents/ace-product-owner.md +365 -361
  10. package/agents/ace-project-researcher.md +606 -606
  11. package/agents/ace-research-synthesizer.md +228 -228
  12. package/agents/ace-technical-application-architect.md +315 -315
  13. package/agents/ace-wiki-mapper.md +449 -445
  14. package/bin/install.js +605 -195
  15. package/hooks/ace-check-update.js +71 -62
  16. package/hooks/ace-statusline.js +107 -89
  17. package/hooks/hooks.json +14 -0
  18. package/package.json +7 -5
  19. package/shared/lib/ace-core.js +361 -0
  20. package/shared/lib/ace-core.test.js +308 -0
  21. package/shared/lib/ace-github.js +753 -0
  22. package/shared/lib/ace-story.js +400 -0
  23. package/shared/lib/ace-story.test.js +250 -0
  24. package/{agile-context-engineering → shared}/utils/questioning.xml +110 -110
  25. package/{agile-context-engineering → shared}/utils/ui-formatting.md +299 -299
  26. package/{commands/ace/execute-story.md → skills/execute-story/SKILL.md} +116 -138
  27. package/skills/execute-story/script.js +291 -0
  28. package/skills/execute-story/script.test.js +261 -0
  29. package/{agile-context-engineering/templates/product/story.xml → skills/execute-story/story-template.xml} +451 -451
  30. package/skills/execute-story/walkthrough-template.xml +255 -0
  31. package/{agile-context-engineering/workflows/execute-story.xml → skills/execute-story/workflow.xml} +1221 -1219
  32. package/skills/help/SKILL.md +71 -0
  33. package/skills/help/script.js +315 -0
  34. package/skills/help/script.test.js +183 -0
  35. package/{agile-context-engineering/workflows/help.xml → skills/help/workflow.xml} +544 -533
  36. package/{commands/ace/init-coding-standards.md → skills/init-coding-standards/SKILL.md} +91 -83
  37. package/{agile-context-engineering/templates/wiki/coding-standards.xml → skills/init-coding-standards/coding-standards-template.xml} +531 -531
  38. package/skills/init-coding-standards/script.js +50 -0
  39. package/skills/init-coding-standards/script.test.js +70 -0
  40. package/{agile-context-engineering/workflows/init-coding-standards.xml → skills/init-coding-standards/workflow.xml} +381 -386
  41. package/skills/map-cross-cutting/SKILL.md +126 -0
  42. package/{agile-context-engineering/templates/wiki → skills/map-cross-cutting}/system-cross-cutting.xml +197 -197
  43. package/skills/map-cross-cutting/workflow.xml +330 -0
  44. package/skills/map-guide/SKILL.md +126 -0
  45. package/{agile-context-engineering/templates/wiki → skills/map-guide}/guide.xml +137 -137
  46. package/skills/map-guide/workflow.xml +320 -0
  47. package/skills/map-pattern/SKILL.md +125 -0
  48. package/{agile-context-engineering/templates/wiki → skills/map-pattern}/pattern.xml +159 -159
  49. package/skills/map-pattern/workflow.xml +331 -0
  50. package/{commands/ace/map-story.md → skills/map-story/SKILL.md} +180 -165
  51. package/{agile-context-engineering/templates/wiki → skills/map-story/templates}/decizions.xml +115 -115
  52. package/skills/map-story/templates/guide.xml +137 -0
  53. package/skills/map-story/templates/pattern.xml +159 -0
  54. package/skills/map-story/templates/system-cross-cutting.xml +197 -0
  55. package/{agile-context-engineering/templates/wiki → skills/map-story/templates}/system.xml +381 -381
  56. package/{agile-context-engineering/templates/wiki → skills/map-story/templates}/tech-debt-index.xml +125 -125
  57. package/{agile-context-engineering/templates/wiki → skills/map-story/templates}/walkthrough.xml +255 -255
  58. package/{agile-context-engineering/workflows/map-story.xml → skills/map-story/workflow.xml} +1046 -1046
  59. package/{commands/ace/map-subsystem.md → skills/map-subsystem/SKILL.md} +155 -140
  60. package/skills/map-subsystem/script.js +51 -0
  61. package/skills/map-subsystem/script.test.js +68 -0
  62. package/skills/map-subsystem/templates/decizions.xml +115 -0
  63. package/skills/map-subsystem/templates/guide.xml +137 -0
  64. package/{agile-context-engineering/templates/wiki → skills/map-subsystem/templates}/module-discovery.xml +174 -174
  65. package/skills/map-subsystem/templates/pattern.xml +159 -0
  66. package/{agile-context-engineering/templates/wiki → skills/map-subsystem/templates}/subsystem-architecture.xml +343 -343
  67. package/{agile-context-engineering/templates/wiki → skills/map-subsystem/templates}/subsystem-structure.xml +234 -234
  68. package/skills/map-subsystem/templates/system-cross-cutting.xml +197 -0
  69. package/skills/map-subsystem/templates/system.xml +381 -0
  70. package/skills/map-subsystem/templates/walkthrough.xml +255 -0
  71. package/{agile-context-engineering/workflows/map-subsystem.xml → skills/map-subsystem/workflow.xml} +1173 -1178
  72. package/skills/map-sys-doc/SKILL.md +125 -0
  73. package/skills/map-sys-doc/system.xml +381 -0
  74. package/skills/map-sys-doc/workflow.xml +336 -0
  75. package/{commands/ace/map-system.md → skills/map-system/SKILL.md} +103 -92
  76. package/skills/map-system/script.js +75 -0
  77. package/skills/map-system/script.test.js +73 -0
  78. package/{agile-context-engineering/templates/wiki → skills/map-system/templates}/system-architecture.xml +254 -254
  79. package/{agile-context-engineering/templates/wiki → skills/map-system/templates}/system-structure.xml +177 -177
  80. package/{agile-context-engineering/templates/wiki → skills/map-system/templates}/testing-framework.xml +283 -283
  81. package/{agile-context-engineering/templates/wiki → skills/map-system/templates}/wiki-readme.xml +296 -296
  82. package/{agile-context-engineering/workflows/map-system.xml → skills/map-system/workflow.xml} +667 -672
  83. package/{commands/ace/map-walkthrough.md → skills/map-walkthrough/SKILL.md} +140 -127
  84. package/skills/map-walkthrough/walkthrough.xml +255 -0
  85. package/{agile-context-engineering/workflows/map-walkthrough.xml → skills/map-walkthrough/workflow.xml} +457 -457
  86. package/{commands/ace/plan-backlog.md → skills/plan-backlog/SKILL.md} +93 -83
  87. package/{agile-context-engineering/templates/product/product-backlog.xml → skills/plan-backlog/product-backlog-template.xml} +231 -231
  88. package/skills/plan-backlog/script.js +121 -0
  89. package/skills/plan-backlog/script.test.js +83 -0
  90. package/{agile-context-engineering/workflows/plan-backlog.xml → skills/plan-backlog/workflow.xml} +1348 -1356
  91. package/{commands/ace/plan-feature.md → skills/plan-feature/SKILL.md} +99 -89
  92. package/{agile-context-engineering/templates/product/feature.xml → skills/plan-feature/feature-template.xml} +361 -361
  93. package/skills/plan-feature/script.js +131 -0
  94. package/skills/plan-feature/script.test.js +80 -0
  95. package/{agile-context-engineering/workflows/plan-feature.xml → skills/plan-feature/workflow.xml} +1487 -1495
  96. package/{commands/ace/plan-product-vision.md → skills/plan-product-vision/SKILL.md} +91 -81
  97. package/{agile-context-engineering/templates/product/product-vision.xml → skills/plan-product-vision/product-vision-template.xml} +227 -227
  98. package/skills/plan-product-vision/script.js +51 -0
  99. package/skills/plan-product-vision/script.test.js +69 -0
  100. package/{agile-context-engineering/workflows/plan-product-vision.xml → skills/plan-product-vision/workflow.xml} +337 -342
  101. package/{commands/ace/plan-story.md → skills/plan-story/SKILL.md} +139 -159
  102. package/skills/plan-story/script.js +295 -0
  103. package/skills/plan-story/script.test.js +240 -0
  104. package/skills/plan-story/story-template.xml +458 -0
  105. package/{agile-context-engineering/workflows/plan-story.xml → skills/plan-story/workflow.xml} +1301 -944
  106. package/{commands/ace/research-external-solution.md → skills/research-external-solution/SKILL.md} +120 -138
  107. package/{agile-context-engineering/templates/product/external-solution.xml → skills/research-external-solution/external-solution-template.xml} +832 -832
  108. package/skills/research-external-solution/script.js +229 -0
  109. package/skills/research-external-solution/script.test.js +134 -0
  110. package/{agile-context-engineering/workflows/research-external-solution.xml → skills/research-external-solution/workflow.xml} +657 -659
  111. package/{commands/ace/research-integration-solution.md → skills/research-integration-solution/SKILL.md} +121 -135
  112. package/{agile-context-engineering/templates/product/story-integration-solution.xml → skills/research-integration-solution/integration-solution-template.xml} +1015 -1015
  113. package/skills/research-integration-solution/script.js +223 -0
  114. package/skills/research-integration-solution/script.test.js +134 -0
  115. package/{agile-context-engineering/workflows/research-integration-solution.xml → skills/research-integration-solution/workflow.xml} +711 -713
  116. package/{commands/ace/research-story-wiki.md → skills/research-story-wiki/SKILL.md} +101 -116
  117. package/skills/research-story-wiki/script.js +223 -0
  118. package/skills/research-story-wiki/script.test.js +138 -0
  119. package/{agile-context-engineering/templates/product/story-wiki.xml → skills/research-story-wiki/story-wiki-template.xml} +194 -194
  120. package/{agile-context-engineering/workflows/research-story-wiki.xml → skills/research-story-wiki/workflow.xml} +473 -475
  121. package/{commands/ace/research-technical-solution.md → skills/research-technical-solution/SKILL.md} +131 -147
  122. package/skills/research-technical-solution/script.js +223 -0
  123. package/skills/research-technical-solution/script.test.js +134 -0
  124. package/{agile-context-engineering/templates/product/story-technical-solution.xml → skills/research-technical-solution/technical-solution-template.xml} +1025 -1025
  125. package/{agile-context-engineering/workflows/research-technical-solution.xml → skills/research-technical-solution/workflow.xml} +761 -763
  126. package/{commands/ace/review-story.md → skills/review-story/SKILL.md} +99 -109
  127. package/skills/review-story/script.js +249 -0
  128. package/skills/review-story/script.test.js +169 -0
  129. package/skills/review-story/story-template.xml +451 -0
  130. package/{agile-context-engineering/workflows/review-story.xml → skills/review-story/workflow.xml} +279 -281
  131. package/{commands/ace/update.md → skills/update/SKILL.md} +65 -56
  132. package/{agile-context-engineering/workflows/update.xml → skills/update/workflow.xml} +33 -18
  133. package/agile-context-engineering/src/ace-tools.js +0 -2881
  134. package/agile-context-engineering/src/ace-tools.test.js +0 -1089
  135. package/agile-context-engineering/templates/_command.md +0 -54
  136. package/agile-context-engineering/templates/_workflow.xml +0 -17
  137. package/agile-context-engineering/templates/config.json +0 -0
  138. package/agile-context-engineering/templates/product/integration-solution.xml +0 -0
  139. package/commands/ace/help.md +0 -93
@@ -1,343 +1,343 @@
1
- <subsystem-architecture>
2
- <purpose>
3
- Template for `.docs/wiki/subsystems/[subsystem-name]/architecture.md` — the internal
4
- architecture view of a single subsystem. Captures component structure (C4 L3), internal
5
- flows, dependency contracts, data ownership, and subsystem-specific decisions.
6
-
7
- Complements system-architecture.md (which shows system-wide L1/L2 views).
8
- Complements subsystem-structure.md (which shows physical file/folder layout).
9
-
10
- One instance per subsystem — each gets its own architecture doc.
11
-
12
- A "subsystem" is any cohesive code unit with a clear responsibility boundary —
13
- whether deployed as a microservice, a monolith module, or a library package.
14
- </purpose>
15
-
16
- <template>
17
- <subsystem-context>
18
- ## [Subsystem Name]
19
-
20
- **Responsibility:** [One-line — what this subsystem owns and does]
21
- **Root:** `[path from project root]`
22
-
23
- ### System Context
24
-
25
- How this subsystem connects to the rest of the system:
26
-
27
- | Relationship | Counterpart | Pattern | What Flows |
28
- |-------------|-------------|---------|------------|
29
- | Inbound | [Caller subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
30
- | Outbound | [Callee subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
31
- </subsystem-context>
32
-
33
- <architectural-pattern>
34
- ## Architectural Pattern
35
-
36
- **Pattern:** [N-Tier / Clean Architecture / Onion / Hexagonal / Vertical Slice / CQRS / MVC / Simple Layered / Other]
37
- **Detected from:** [e.g., "Domain/, Application/, Infrastructure/ folder hierarchy", "IRepository interfaces in core project", "Feature-first directory layout with per-slice handlers"]
38
-
39
- [1-2 sentences: how the pattern manifests in this subsystem — what the layers are called,
40
- how dependencies flow, and any notable deviations from the canonical pattern.]
41
- </architectural-pattern>
42
-
43
- <c4-l3-component>
44
- ## L3: Internal Components
45
-
46
- Shape this diagram to match the detected architectural pattern. Use the reference diagrams
47
- in the guidelines section. Below is the Clean Architecture default — replace with the
48
- appropriate structure for the actual pattern.
49
-
50
- ```mermaid
51
- flowchart TD
52
- subgraph Entry["Entry Point(s)"]
53
- api["[API Layer]<br/><small>[Router/Controller/Handler]</small>"]
54
- end
55
-
56
- subgraph App["Application Layer"]
57
- svc["[Service / Use Case]<br/><small>[Orchestrates domain]</small>"]
58
- end
59
-
60
- subgraph Domain["Domain"]
61
- entity["[Domain Entity / Aggregate]<br/><small>[Core business logic]</small>"]
62
- end
63
-
64
- subgraph Infra["Infrastructure"]
65
- repo["[Repository]<br/><small>[Data access]</small>"]
66
- client["[External Client]<br/><small>[3rd-party / other subsystem]</small>"]
67
- end
68
-
69
- subgraph Data["Data"]
70
- db[("Data Store")]
71
- end
72
-
73
- api --> svc
74
- svc --> entity
75
- svc --> repo
76
- svc --> client
77
- repo --> db
78
- ```
79
-
80
- ### Component Responsibilities
81
-
82
- | Component | Responsibility | Key Files |
83
- |-----------|---------------|-----------|
84
- | [API Layer] | [Receives and validates requests, maps to use cases] | `[path]` |
85
- | [Service] | [Orchestrates domain logic and infrastructure] | `[path]` |
86
- | [Domain] | [Business rules, entities, value objects] | `[path]` |
87
- | [Repository] | [Persists and retrieves domain objects] | `[path]` |
88
- | [External Client] | [Communicates with external system/subsystem] | `[path]` |
89
- </c4-l3-component>
90
-
91
- <internal-flows>
92
- ## Key Internal Flows
93
-
94
- The flows that define this subsystem's core operations.
95
-
96
- ### Flow: [Flow Name]
97
-
98
- [One sentence: what this achieves and when it triggers.]
99
-
100
- ```mermaid
101
- sequenceDiagram
102
- participant Caller as [Caller / Entry]
103
- participant Svc as [Service]
104
- participant Domain as [Domain]
105
- participant Repo as [Repository]
106
- participant DB as [Data Store]
107
-
108
- Caller->>Svc: [Request / command]
109
- Svc->>Domain: [What is passed]
110
- Domain-->>Svc: [Result / validated object]
111
- Svc->>Repo: [Persist / query]
112
- Repo->>DB: [SQL / query]
113
- DB-->>Repo: [Result]
114
- Repo-->>Svc: [Domain object]
115
- Svc-->>Caller: [Response]
116
- ```
117
- </internal-flows>
118
-
119
- <dependency-inventory>
120
- ## Dependency Inventory
121
-
122
- ### Inbound (Who calls this subsystem)
123
-
124
- | Caller | Call Type | Contract | Notes |
125
- |--------|-----------|----------|-------|
126
- | [Subsystem / External] | [HTTP GET /path, Event: topic-name] | [OpenAPI / schema / event type] | [e.g., "authenticated calls only"] |
127
-
128
- ### Outbound (What this subsystem calls)
129
-
130
- | Dependency | Call Type | Contract | Failure Handling |
131
- |------------|-----------|----------|-----------------|
132
- | [Subsystem / External] | [HTTP / gRPC / SQL / event publish] | [OpenAPI / schema / event type] | [Retry, fallback, fail fast] |
133
- </dependency-inventory>
134
-
135
- <data-ownership>
136
- ## Data Ownership
137
-
138
- This subsystem owns the following data stores and schemas. Other subsystems MUST NOT
139
- write directly — they interact through this subsystem's API or events.
140
-
141
- | Store | Type | Schema / Namespace | Key Entities |
142
- |-------|------|--------------------|--------------|
143
- | [Table/collection/topic] | [Postgres/Mongo/Kafka] | [Schema name or prefix] | [Primary entities stored] |
144
-
145
- **Data NOT owned here:** [Any data this subsystem reads but doesn't own, with note of true owner]
146
- </data-ownership>
147
-
148
- <subsystem-architectural-decisions>
149
- ## Subsystem Architectural Decisions
150
-
151
- Decisions specific to this subsystem. System-wide decisions live in system-architecture.md.
152
-
153
- | Decision | Rationale |
154
- |----------|-----------|
155
- | [e.g., CQRS for this service] | [High read/write asymmetry — separate models] |
156
- | [e.g., Repository pattern over direct ORM] | [Testability, ability to swap data store] |
157
- </subsystem-architectural-decisions>
158
- </template>
159
-
160
- <guidelines>
161
-
162
- **ALL visual representations of architecture, dependencies, flows, or relationships MUST be ```mermaid fenced code blocks. NO ASCII arrows (->), NO dependency trees, NO PlantUML. Only mermaid. The ONLY ASCII exception is file trees.**
163
-
164
- **Architectural Pattern — How to Detect:**
165
-
166
- Examine folder structure, namespaces, class names, and dependency directions. Match against
167
- these signals — the first clear match wins. When signals overlap, note the hybrid.
168
-
169
- - **N-Tier / Simple Layered** — Folders named `Controllers/`, `Services/` (or `BLL/`),
170
- `Repositories/` (or `DAL/`). Direct downward dependencies: controller → service → repo.
171
- No interface inversion — concrete classes reference each other directly.
172
-
173
- - **MVC** — Framework-scaffolded `Models/`, `Views/`, `Controllers/` (or `Pages/` for
174
- Razor Pages). Route handlers return views or JSON directly. Thin or no service layer.
175
-
176
- - **Clean Architecture** — Explicit `Domain/`, `Application/`, `Infrastructure/`,
177
- `Presentation/` (or `Web/`, `API/`) projects or folders. Domain has zero outgoing
178
- dependencies. Application references Domain only. Infrastructure implements interfaces
179
- defined in Application or Domain. Dependency rule strictly inward.
180
-
181
- - **Onion Architecture** — Similar signals to Clean but layered as concentric rings:
182
- `Core/` (domain model + domain services + application services), `Infrastructure/`,
183
- optional `UI/`. Interfaces (ports) defined in Core; implementations in outer rings.
184
-
185
- - **Hexagonal / Ports & Adapters** — Explicit `ports/` or `interfaces/` alongside
186
- `adapters/` or `infrastructure/`. Primary adapters (HTTP, CLI) on one side; secondary
187
- adapters (DB, messaging) on the other. Domain core has no framework imports.
188
-
189
- - **Vertical Slice / Feature-First** — Feature-named top-level folders:
190
- `Features/CreateOrder/`, `Features/ListOrders/`. Each slice contains its own handler,
191
- validator, model, and tests. No shared service layer across features. Often uses a
192
- mediator (MediatR, similar) — look for `IRequest`/`IRequestHandler` or equivalent.
193
-
194
- - **CQRS** — Separate `Commands/` and `Queries/` (or `Read/` and `Write/`) directories.
195
- Distinct models for reads vs. writes. May be combined with Event Sourcing
196
- (`Events/`, `EventStore`, `Projections/`).
197
-
198
- **Architectural Pattern — Diagram shapes per pattern:**
199
-
200
- Use the reference below to choose the right diagram structure. Replace the default
201
- Clean Architecture diagram in the template with the one matching the detected pattern.
202
-
203
- *N-Tier:*
204
- ```
205
- flowchart TD
206
- ctrl["Controller / Presenter"] --> svc["Service / Business Logic"]
207
- svc --> repo["Repository / DAO"]
208
- repo --> db[("Data Store")]
209
- ```
210
-
211
- *Clean Architecture / Onion:*
212
- ```
213
- flowchart TD
214
- subgraph Presentation; api["Controller / Handler"]; end
215
- subgraph Application; uc["Use Case / App Service"]; end
216
- subgraph Domain; ent["Entity / Aggregate"]; port["Port Interface"]; end
217
- subgraph Infrastructure; impl["Repository Impl"]; adapter["External Adapter"]; end
218
- api --> uc
219
- uc --> ent
220
- uc --> port
221
- impl -.->|implements| port
222
- adapter -.->|implements| port
223
- ```
224
-
225
- *Hexagonal / Ports & Adapters:*
226
- ```
227
- flowchart LR
228
- subgraph Primary["Primary Adapters (Driving)"]
229
- http["HTTP Controller"]
230
- cli["CLI Handler"]
231
- end
232
- subgraph Core["Domain Core"]
233
- domain["Domain Logic"]
234
- inport["Input Port"]
235
- outport["Output Port"]
236
- end
237
- subgraph Secondary["Secondary Adapters (Driven)"]
238
- dbrepo["DB Repository"]
239
- msgclient["Messaging Client"]
240
- end
241
- http --> inport
242
- cli --> inport
243
- inport --> domain
244
- domain --> outport
245
- outport -.->|implements| dbrepo
246
- outport -.->|implements| msgclient
247
- ```
248
-
249
- *Vertical Slice / Feature-First:*
250
- ```
251
- flowchart LR
252
- subgraph SliceA["Feature: [Name A]"]
253
- ha["Handler A"] --> va["Validator A"]
254
- ha --> dba[("DB")]
255
- end
256
- subgraph SliceB["Feature: [Name B]"]
257
- hb["Handler B"] --> vb["Validator B"]
258
- hb --> dbb[("DB")]
259
- end
260
- entry["Entry / Mediator"] --> ha
261
- entry --> hb
262
- ```
263
-
264
- *CQRS:*
265
- ```
266
- flowchart TD
267
- entry["Entry / Mediator"]
268
- subgraph Commands
269
- ch["Command Handler"] --> domain["Domain / Aggregate"]
270
- domain --> writedb[("Write Store")]
271
- end
272
- subgraph Queries
273
- qh["Query Handler"] --> readdb[("Read Store / Projection")]
274
- end
275
- entry --> ch
276
- entry --> qh
277
- ```
278
-
279
- **Subsystem Context:**
280
- - One-line responsibility — NOT a paragraph. If you need more words, the boundary is wrong
281
- - System context table: only show DIRECT inbound/outbound. No transitive dependencies
282
- - Keep it brief — the full system view is in system-architecture.md
283
-
284
- **L3 Component Diagram:**
285
- - Layered top-to-bottom (entry → application → domain → infrastructure → data)
286
- - Each box = a logical component, NOT a file or class
287
- - Use `flowchart TD` for layered architectures (Clean Architecture, DDD) or `flowchart LR`
288
- for pipeline/stream-processing subsystems
289
- - Do NOT show method calls — this is component-level, not code-level
290
- - Component table: key files must be actual paths within the subsystem
291
-
292
- **Internal Flows:**
293
- - 1-3 flows maximum. Choose flows a NEW DEVELOPER must understand to add a feature
294
- - Component-level only — no method names, no line numbers, no class details
295
- - Sequence diagram participants = components from the L3 diagram, not files
296
- - If more than 3 flows are needed, this subsystem likely has multiple bounded operations —
297
- consider separate docs per operation or split the subsystem
298
-
299
- **Dependency Inventory:**
300
- - Inbound: every caller of this subsystem, even if it's just one other subsystem
301
- - Outbound: every dependency this subsystem calls — including data stores, caches, queues
302
- - "Failure Handling" for outbound: what happens when that dependency is unavailable?
303
-
304
- **Data Ownership:**
305
- - Strict — document who OWNS the data, not just who reads it
306
- - Include ALL data stores: relational tables, document collections, cache keys, message topics
307
- - "Data NOT owned here" prevents confusion when a subsystem reads across ownership boundaries
308
-
309
- **Subsystem Architectural Decisions:**
310
- - Only decisions that deviate from system-wide defaults or are significant within the subsystem
311
- - Skip obvious choices (e.g., don't document "we use async/await" in a Node.js service)
312
- - Decision + Rationale only. No status tracking, no dates
313
-
314
- **What does NOT belong here:**
315
- - Physical file layout (that's subsystem-structure.md)
316
- - System-wide tech stack (that's system-architecture.md)
317
- - L1/L2 diagrams (that's system-architecture.md)
318
- - Code-level detail like class signatures, method contracts (L4 — in code comments/docs)
319
-
320
- </guidelines>
321
-
322
- <evolution>
323
-
324
- Update when this subsystem's internal architecture changes.
325
-
326
- **Update triggers:**
327
- - Architectural pattern changed (e.g., N-Tier refactored to Clean Architecture)
328
- - New component layer added (e.g., adding CQRS, adding a cache layer)
329
- - New inbound integration (new caller, new event type consumed)
330
- - New outbound dependency (new API called, new data store added)
331
- - Data ownership changes (new table, new schema, new topic)
332
- - New subsystem-specific architectural decision made
333
- - Core internal flow fundamentally changed (not just a new step in an existing flow)
334
-
335
- **NOT an update trigger:**
336
- - New feature following existing patterns
337
- - Bug fixes or refactoring within existing components
338
- - New API endpoint within existing handler
339
- - New fields on existing entities
340
-
341
- </evolution>
342
-
343
- </subsystem-architecture>
1
+ <subsystem-architecture>
2
+ <purpose>
3
+ Template for `.docs/wiki/subsystems/[subsystem-name]/architecture.md` — the internal
4
+ architecture view of a single subsystem. Captures component structure (C4 L3), internal
5
+ flows, dependency contracts, data ownership, and subsystem-specific decisions.
6
+
7
+ Complements system-architecture.md (which shows system-wide L1/L2 views).
8
+ Complements subsystem-structure.md (which shows physical file/folder layout).
9
+
10
+ One instance per subsystem — each gets its own architecture doc.
11
+
12
+ A "subsystem" is any cohesive code unit with a clear responsibility boundary —
13
+ whether deployed as a microservice, a monolith module, or a library package.
14
+ </purpose>
15
+
16
+ <template>
17
+ <subsystem-context>
18
+ ## [Subsystem Name]
19
+
20
+ **Responsibility:** [One-line — what this subsystem owns and does]
21
+ **Root:** `[path from project root]`
22
+
23
+ ### System Context
24
+
25
+ How this subsystem connects to the rest of the system:
26
+
27
+ | Relationship | Counterpart | Pattern | What Flows |
28
+ |-------------|-------------|---------|------------|
29
+ | Inbound | [Caller subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
30
+ | Outbound | [Callee subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
31
+ </subsystem-context>
32
+
33
+ <architectural-pattern>
34
+ ## Architectural Pattern
35
+
36
+ **Pattern:** [N-Tier / Clean Architecture / Onion / Hexagonal / Vertical Slice / CQRS / MVC / Simple Layered / Other]
37
+ **Detected from:** [e.g., "Domain/, Application/, Infrastructure/ folder hierarchy", "IRepository interfaces in core project", "Feature-first directory layout with per-slice handlers"]
38
+
39
+ [1-2 sentences: how the pattern manifests in this subsystem — what the layers are called,
40
+ how dependencies flow, and any notable deviations from the canonical pattern.]
41
+ </architectural-pattern>
42
+
43
+ <c4-l3-component>
44
+ ## L3: Internal Components
45
+
46
+ Shape this diagram to match the detected architectural pattern. Use the reference diagrams
47
+ in the guidelines section. Below is the Clean Architecture default — replace with the
48
+ appropriate structure for the actual pattern.
49
+
50
+ ```mermaid
51
+ flowchart TD
52
+ subgraph Entry["Entry Point(s)"]
53
+ api["[API Layer]<br/><small>[Router/Controller/Handler]</small>"]
54
+ end
55
+
56
+ subgraph App["Application Layer"]
57
+ svc["[Service / Use Case]<br/><small>[Orchestrates domain]</small>"]
58
+ end
59
+
60
+ subgraph Domain["Domain"]
61
+ entity["[Domain Entity / Aggregate]<br/><small>[Core business logic]</small>"]
62
+ end
63
+
64
+ subgraph Infra["Infrastructure"]
65
+ repo["[Repository]<br/><small>[Data access]</small>"]
66
+ client["[External Client]<br/><small>[3rd-party / other subsystem]</small>"]
67
+ end
68
+
69
+ subgraph Data["Data"]
70
+ db[("Data Store")]
71
+ end
72
+
73
+ api --> svc
74
+ svc --> entity
75
+ svc --> repo
76
+ svc --> client
77
+ repo --> db
78
+ ```
79
+
80
+ ### Component Responsibilities
81
+
82
+ | Component | Responsibility | Key Files |
83
+ |-----------|---------------|-----------|
84
+ | [API Layer] | [Receives and validates requests, maps to use cases] | `[path]` |
85
+ | [Service] | [Orchestrates domain logic and infrastructure] | `[path]` |
86
+ | [Domain] | [Business rules, entities, value objects] | `[path]` |
87
+ | [Repository] | [Persists and retrieves domain objects] | `[path]` |
88
+ | [External Client] | [Communicates with external system/subsystem] | `[path]` |
89
+ </c4-l3-component>
90
+
91
+ <internal-flows>
92
+ ## Key Internal Flows
93
+
94
+ The flows that define this subsystem's core operations.
95
+
96
+ ### Flow: [Flow Name]
97
+
98
+ [One sentence: what this achieves and when it triggers.]
99
+
100
+ ```mermaid
101
+ sequenceDiagram
102
+ participant Caller as [Caller / Entry]
103
+ participant Svc as [Service]
104
+ participant Domain as [Domain]
105
+ participant Repo as [Repository]
106
+ participant DB as [Data Store]
107
+
108
+ Caller->>Svc: [Request / command]
109
+ Svc->>Domain: [What is passed]
110
+ Domain-->>Svc: [Result / validated object]
111
+ Svc->>Repo: [Persist / query]
112
+ Repo->>DB: [SQL / query]
113
+ DB-->>Repo: [Result]
114
+ Repo-->>Svc: [Domain object]
115
+ Svc-->>Caller: [Response]
116
+ ```
117
+ </internal-flows>
118
+
119
+ <dependency-inventory>
120
+ ## Dependency Inventory
121
+
122
+ ### Inbound (Who calls this subsystem)
123
+
124
+ | Caller | Call Type | Contract | Notes |
125
+ |--------|-----------|----------|-------|
126
+ | [Subsystem / External] | [HTTP GET /path, Event: topic-name] | [OpenAPI / schema / event type] | [e.g., "authenticated calls only"] |
127
+
128
+ ### Outbound (What this subsystem calls)
129
+
130
+ | Dependency | Call Type | Contract | Failure Handling |
131
+ |------------|-----------|----------|-----------------|
132
+ | [Subsystem / External] | [HTTP / gRPC / SQL / event publish] | [OpenAPI / schema / event type] | [Retry, fallback, fail fast] |
133
+ </dependency-inventory>
134
+
135
+ <data-ownership>
136
+ ## Data Ownership
137
+
138
+ This subsystem owns the following data stores and schemas. Other subsystems MUST NOT
139
+ write directly — they interact through this subsystem's API or events.
140
+
141
+ | Store | Type | Schema / Namespace | Key Entities |
142
+ |-------|------|--------------------|--------------|
143
+ | [Table/collection/topic] | [Postgres/Mongo/Kafka] | [Schema name or prefix] | [Primary entities stored] |
144
+
145
+ **Data NOT owned here:** [Any data this subsystem reads but doesn't own, with note of true owner]
146
+ </data-ownership>
147
+
148
+ <subsystem-architectural-decisions>
149
+ ## Subsystem Architectural Decisions
150
+
151
+ Decisions specific to this subsystem. System-wide decisions live in system-architecture.md.
152
+
153
+ | Decision | Rationale |
154
+ |----------|-----------|
155
+ | [e.g., CQRS for this service] | [High read/write asymmetry — separate models] |
156
+ | [e.g., Repository pattern over direct ORM] | [Testability, ability to swap data store] |
157
+ </subsystem-architectural-decisions>
158
+ </template>
159
+
160
+ <guidelines>
161
+
162
+ **ALL visual representations of architecture, dependencies, flows, or relationships MUST be ```mermaid fenced code blocks. NO ASCII arrows (->), NO dependency trees, NO PlantUML. Only mermaid. The ONLY ASCII exception is file trees.**
163
+
164
+ **Architectural Pattern — How to Detect:**
165
+
166
+ Examine folder structure, namespaces, class names, and dependency directions. Match against
167
+ these signals — the first clear match wins. When signals overlap, note the hybrid.
168
+
169
+ - **N-Tier / Simple Layered** — Folders named `Controllers/`, `Services/` (or `BLL/`),
170
+ `Repositories/` (or `DAL/`). Direct downward dependencies: controller → service → repo.
171
+ No interface inversion — concrete classes reference each other directly.
172
+
173
+ - **MVC** — Framework-scaffolded `Models/`, `Views/`, `Controllers/` (or `Pages/` for
174
+ Razor Pages). Route handlers return views or JSON directly. Thin or no service layer.
175
+
176
+ - **Clean Architecture** — Explicit `Domain/`, `Application/`, `Infrastructure/`,
177
+ `Presentation/` (or `Web/`, `API/`) projects or folders. Domain has zero outgoing
178
+ dependencies. Application references Domain only. Infrastructure implements interfaces
179
+ defined in Application or Domain. Dependency rule strictly inward.
180
+
181
+ - **Onion Architecture** — Similar signals to Clean but layered as concentric rings:
182
+ `Core/` (domain model + domain services + application services), `Infrastructure/`,
183
+ optional `UI/`. Interfaces (ports) defined in Core; implementations in outer rings.
184
+
185
+ - **Hexagonal / Ports & Adapters** — Explicit `ports/` or `interfaces/` alongside
186
+ `adapters/` or `infrastructure/`. Primary adapters (HTTP, CLI) on one side; secondary
187
+ adapters (DB, messaging) on the other. Domain core has no framework imports.
188
+
189
+ - **Vertical Slice / Feature-First** — Feature-named top-level folders:
190
+ `Features/CreateOrder/`, `Features/ListOrders/`. Each slice contains its own handler,
191
+ validator, model, and tests. No shared service layer across features. Often uses a
192
+ mediator (MediatR, similar) — look for `IRequest`/`IRequestHandler` or equivalent.
193
+
194
+ - **CQRS** — Separate `Commands/` and `Queries/` (or `Read/` and `Write/`) directories.
195
+ Distinct models for reads vs. writes. May be combined with Event Sourcing
196
+ (`Events/`, `EventStore`, `Projections/`).
197
+
198
+ **Architectural Pattern — Diagram shapes per pattern:**
199
+
200
+ Use the reference below to choose the right diagram structure. Replace the default
201
+ Clean Architecture diagram in the template with the one matching the detected pattern.
202
+
203
+ *N-Tier:*
204
+ ```
205
+ flowchart TD
206
+ ctrl["Controller / Presenter"] --> svc["Service / Business Logic"]
207
+ svc --> repo["Repository / DAO"]
208
+ repo --> db[("Data Store")]
209
+ ```
210
+
211
+ *Clean Architecture / Onion:*
212
+ ```
213
+ flowchart TD
214
+ subgraph Presentation; api["Controller / Handler"]; end
215
+ subgraph Application; uc["Use Case / App Service"]; end
216
+ subgraph Domain; ent["Entity / Aggregate"]; port["Port Interface"]; end
217
+ subgraph Infrastructure; impl["Repository Impl"]; adapter["External Adapter"]; end
218
+ api --> uc
219
+ uc --> ent
220
+ uc --> port
221
+ impl -.->|implements| port
222
+ adapter -.->|implements| port
223
+ ```
224
+
225
+ *Hexagonal / Ports & Adapters:*
226
+ ```
227
+ flowchart LR
228
+ subgraph Primary["Primary Adapters (Driving)"]
229
+ http["HTTP Controller"]
230
+ cli["CLI Handler"]
231
+ end
232
+ subgraph Core["Domain Core"]
233
+ domain["Domain Logic"]
234
+ inport["Input Port"]
235
+ outport["Output Port"]
236
+ end
237
+ subgraph Secondary["Secondary Adapters (Driven)"]
238
+ dbrepo["DB Repository"]
239
+ msgclient["Messaging Client"]
240
+ end
241
+ http --> inport
242
+ cli --> inport
243
+ inport --> domain
244
+ domain --> outport
245
+ outport -.->|implements| dbrepo
246
+ outport -.->|implements| msgclient
247
+ ```
248
+
249
+ *Vertical Slice / Feature-First:*
250
+ ```
251
+ flowchart LR
252
+ subgraph SliceA["Feature: [Name A]"]
253
+ ha["Handler A"] --> va["Validator A"]
254
+ ha --> dba[("DB")]
255
+ end
256
+ subgraph SliceB["Feature: [Name B]"]
257
+ hb["Handler B"] --> vb["Validator B"]
258
+ hb --> dbb[("DB")]
259
+ end
260
+ entry["Entry / Mediator"] --> ha
261
+ entry --> hb
262
+ ```
263
+
264
+ *CQRS:*
265
+ ```
266
+ flowchart TD
267
+ entry["Entry / Mediator"]
268
+ subgraph Commands
269
+ ch["Command Handler"] --> domain["Domain / Aggregate"]
270
+ domain --> writedb[("Write Store")]
271
+ end
272
+ subgraph Queries
273
+ qh["Query Handler"] --> readdb[("Read Store / Projection")]
274
+ end
275
+ entry --> ch
276
+ entry --> qh
277
+ ```
278
+
279
+ **Subsystem Context:**
280
+ - One-line responsibility — NOT a paragraph. If you need more words, the boundary is wrong
281
+ - System context table: only show DIRECT inbound/outbound. No transitive dependencies
282
+ - Keep it brief — the full system view is in system-architecture.md
283
+
284
+ **L3 Component Diagram:**
285
+ - Layered top-to-bottom (entry → application → domain → infrastructure → data)
286
+ - Each box = a logical component, NOT a file or class
287
+ - Use `flowchart TD` for layered architectures (Clean Architecture, DDD) or `flowchart LR`
288
+ for pipeline/stream-processing subsystems
289
+ - Do NOT show method calls — this is component-level, not code-level
290
+ - Component table: key files must be actual paths within the subsystem
291
+
292
+ **Internal Flows:**
293
+ - 1-3 flows maximum. Choose flows a NEW DEVELOPER must understand to add a feature
294
+ - Component-level only — no method names, no line numbers, no class details
295
+ - Sequence diagram participants = components from the L3 diagram, not files
296
+ - If more than 3 flows are needed, this subsystem likely has multiple bounded operations —
297
+ consider separate docs per operation or split the subsystem
298
+
299
+ **Dependency Inventory:**
300
+ - Inbound: every caller of this subsystem, even if it's just one other subsystem
301
+ - Outbound: every dependency this subsystem calls — including data stores, caches, queues
302
+ - "Failure Handling" for outbound: what happens when that dependency is unavailable?
303
+
304
+ **Data Ownership:**
305
+ - Strict — document who OWNS the data, not just who reads it
306
+ - Include ALL data stores: relational tables, document collections, cache keys, message topics
307
+ - "Data NOT owned here" prevents confusion when a subsystem reads across ownership boundaries
308
+
309
+ **Subsystem Architectural Decisions:**
310
+ - Only decisions that deviate from system-wide defaults or are significant within the subsystem
311
+ - Skip obvious choices (e.g., don't document "we use async/await" in a Node.js service)
312
+ - Decision + Rationale only. No status tracking, no dates
313
+
314
+ **What does NOT belong here:**
315
+ - Physical file layout (that's subsystem-structure.md)
316
+ - System-wide tech stack (that's system-architecture.md)
317
+ - L1/L2 diagrams (that's system-architecture.md)
318
+ - Code-level detail like class signatures, method contracts (L4 — in code comments/docs)
319
+
320
+ </guidelines>
321
+
322
+ <evolution>
323
+
324
+ Update when this subsystem's internal architecture changes.
325
+
326
+ **Update triggers:**
327
+ - Architectural pattern changed (e.g., N-Tier refactored to Clean Architecture)
328
+ - New component layer added (e.g., adding CQRS, adding a cache layer)
329
+ - New inbound integration (new caller, new event type consumed)
330
+ - New outbound dependency (new API called, new data store added)
331
+ - Data ownership changes (new table, new schema, new topic)
332
+ - New subsystem-specific architectural decision made
333
+ - Core internal flow fundamentally changed (not just a new step in an existing flow)
334
+
335
+ **NOT an update trigger:**
336
+ - New feature following existing patterns
337
+ - Bug fixes or refactoring within existing components
338
+ - New API endpoint within existing handler
339
+ - New fields on existing entities
340
+
341
+ </evolution>
342
+
343
+ </subsystem-architecture>