@comfanion/workflow 4.38.4-dev.1 → 4.39.0-dev.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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/src/build-info.json +2 -2
  3. package/src/opencode/skills/acceptance-criteria/SKILL.md +58 -176
  4. package/src/opencode/skills/architecture-design/SKILL.md +86 -576
  5. package/src/opencode/skills/archiving/SKILL.md +60 -140
  6. package/src/opencode/skills/coding-standards/SKILL.md +113 -434
  7. package/src/opencode/skills/coding-standards/what-to-document.md +512 -0
  8. package/src/opencode/skills/database-design/SKILL.md +94 -778
  9. package/src/opencode/skills/database-design/indexing.md +187 -0
  10. package/src/opencode/skills/database-design/migrations.md +239 -0
  11. package/src/opencode/skills/database-design/schema-design.md +319 -0
  12. package/src/opencode/skills/doc-todo/SKILL.md +35 -27
  13. package/src/opencode/skills/epic-writing/SKILL.md +156 -244
  14. package/src/opencode/skills/epic-writing/template.md +11 -1
  15. package/src/opencode/skills/methodologies/SKILL.md +91 -354
  16. package/src/opencode/skills/methodologies/define.md +336 -0
  17. package/src/opencode/skills/methodologies/diagnose.md +374 -0
  18. package/src/opencode/skills/methodologies/empathize.md +253 -0
  19. package/src/opencode/skills/methodologies/ideate.md +458 -0
  20. package/src/opencode/skills/prd-writing/SKILL.md +162 -366
  21. package/src/opencode/skills/prd-writing/template.md +178 -48
  22. package/src/opencode/skills/requirements-gathering/SKILL.md +102 -117
  23. package/src/opencode/skills/requirements-gathering/template.md +97 -17
  24. package/src/opencode/skills/sprint-planning/SKILL.md +76 -225
  25. package/src/opencode/skills/sprint-planning/template.yaml +8 -0
  26. package/src/opencode/skills/story-writing/SKILL.md +76 -210
  27. package/src/opencode/skills/story-writing/template.md +10 -1
  28. package/src/opencode/skills/test-design/SKILL.md +78 -84
  29. package/src/opencode/skills/test-design/test-strategy.md +279 -0
  30. package/src/opencode/skills/test-design/unit-tests-mocking.md +247 -0
  31. package/src/opencode/skills/test-design/unit-tests-patterns.md +181 -0
  32. package/src/opencode/skills/test-design/unit-tests.md +117 -0
  33. package/src/opencode/skills/unit-writing/SKILL.md +119 -377
  34. package/src/opencode/skills/module-documentation/SKILL.md +0 -224
  35. package/src/opencode/skills/module-documentation/template.md +0 -139
  36. /package/src/opencode/skills/test-design/{template-integration.md → templates/template-integration.md} +0 -0
  37. /package/src/opencode/skills/test-design/{template-module.md → templates/template-module.md} +0 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: architecture-design
3
- description: Use when designing new system architecture, defining module boundaries, choosing architectural patterns (CQRS, Event Sourcing), or making technology decisions
3
+ description: Design system architecture, define module boundaries, choose architectural patterns (Hexagonal, DDD, CQRS, Event Sourcing), and document technology decisions. Use when designing architecture, defining modules, choosing patterns, or when user mentions "architecture", "system design", "module boundaries", "DDD", "CQRS", "hexagonal", or "technology stack".
4
4
  license: MIT
5
5
  compatibility: opencode
6
6
  metadata:
@@ -11,238 +11,41 @@ metadata:
11
11
 
12
12
  # Architecture Design Skill
13
13
 
14
- ## When to Use
15
-
16
- Use this skill when you need to:
17
- - Design new system architecture
18
- - Define module/service boundaries
19
- - Create data ownership model
20
- - Design integration points
21
- - Choose architectural patterns (CQRS, Event Sourcing, Saga)
22
- - Make technology trade-off decisions
23
- - Document architectural decisions
24
-
25
- ## Reference
26
-
27
- Always check project standards: `@CLAUDE.md`
28
-
29
- ## Template
30
-
31
- Use template at: `@.opencode/skills/architecture-design/template.md`
32
-
33
- ## CRITICAL: Adapt Depth to Project Size
34
-
35
- **BEFORE writing architecture, read PRD's Project Classification section!**
36
-
37
- Your architecture document size should match project size:
38
-
39
- | Project Size | Target Lines | Diagrams | ADRs | Focus |
40
- |--------------|--------------|----------|------|-------|
41
- | **TOY** | 200-500 | C4 Context + Container | None | Core components only |
42
- | **SMALL** | 500-1000 | + C4 Component | 2-3 major decisions | Clear module boundaries |
43
- | **MEDIUM** | 1000-2000 | + Sequences + ER | 5-10 significant | Complete system design |
44
- | **LARGE** | 2000-4000 | + Deployment + State | 10-20 all decisions | Multiple files OK |
45
- | **ENTERPRISE** | 4000+ | All diagrams | 20+ per domain | Per-domain files |
46
-
47
- **Examples:**
48
-
49
- **TOY (Tetris - 350 lines):**
50
- ```
51
- Executive Summary (50 lines)
52
- System Context diagram (ASCII)
53
- 3 Modules: GameEngine, Renderer, ScoreManager
54
- Data Model: GameState object (no DB)
55
- Tech Stack: HTML5 Canvas, Vanilla JS
56
- ```
57
-
58
- **SMALL (Blog - 800 lines):**
59
- ```
60
- Executive Summary
61
- Decision Summary (pattern choice)
62
- C4 Context + Container + Component
63
- 5 Modules: Auth, Posts, Comments, Media, Admin
64
- ER Diagram (users, posts, comments)
65
- 2-3 ADRs (why SQLite, why server-side rendering)
66
- ```
67
-
68
- **MEDIUM (E-commerce - 1500 lines):**
69
- ```
70
- Full C4 model
71
- 8 Modules across 3 domains
72
- Complete ER diagram
73
- Sequence diagrams for checkout flow
74
- 5-10 ADRs
75
- Integration points documented
76
- ```
77
-
78
- **Don't over-engineer small projects!** If PRD says "toy", keep it under 500 lines.
79
-
80
- ---
81
-
82
- ## Module/Unit Breakdown by Size
83
-
84
- **CRITICAL:** Read PRD's Project Classification to determine module strategy.
85
-
86
- | Project Size | Module Strategy | Structure |
87
- |--------------|-----------------|-----------|
88
- | **TOY** | No modules | Flat components (GameEngine, Renderer, ScoreManager) |
89
- | **SMALL** | No modules | Flat components (AuthService, PostService, CommentService) |
90
- | **MEDIUM** | **YES - Modules** | 3-5 modules (OrderModule, InventoryModule, PaymentModule) |
91
- | **LARGE** | **YES - Domains** | 5-10 domains (OrderDomain, PaymentDomain, UserDomain) |
92
- | **ENTERPRISE** | **YES - Bounded Contexts** | 10+ contexts with subdomains |
93
-
94
- **For MEDIUM+ projects:**
95
-
96
- 1. **Identify Modules from PRD:**
97
- - Read PRD's Executive Summary → "Key Domains"
98
- - Each domain = Module in architecture
99
- - Example: PRD lists "Order Management, Inventory, Payment" → 3 modules
100
-
101
- 2. **Document Each Module:**
102
- - Create section per module in architecture.md
103
- - Define module boundaries (what's in, what's out)
104
- - Define module's internal services
105
- - Define module's data ownership
106
- - Define module's API (what other modules can call)
107
-
108
- 3. **Create Unit Documentation:**
109
- - For each module, create `docs/units/module-name/index.md`
110
- - Use `unit-writing` skill
111
- - Include: data model, API spec, events (if event-driven)
112
-
113
- 4. **Module Communication:**
114
- - Document how modules interact
115
- - Synchronous (REST/GraphQL) or Asynchronous (events)
116
- - Integration diagram showing module dependencies
117
-
118
- **Example - MEDIUM E-commerce (3 modules):**
119
-
120
- ```markdown
121
- ## Modules Overview
122
-
123
- ### Order Management Module
124
-
125
- **Purpose:** Handles order lifecycle from creation to fulfillment
126
-
127
- **Internal Services:**
128
- - OrderService: CRUD operations
129
- - OrderWorkflowService: Status transitions
130
- - OrderValidationService: Business rules
131
-
132
- **Data Ownership:**
133
- - orders table
134
- - order_items table
135
- - order_history table
136
-
137
- **API (exposed to other modules):**
138
- - `POST /orders` - Create order
139
- - `GET /orders/{id}` - Get order details
140
- - `PUT /orders/{id}/status` - Update status
141
-
142
- **Events Published:**
143
- - OrderCreated
144
- - OrderPaid
145
- - OrderShipped
146
-
147
- → Unit: `docs/units/order-management/`
148
-
149
- ### Payment Module
150
- ...
151
-
152
- ### Inventory Module
153
- ...
154
- ```
155
-
156
- **TOY/SMALL projects - NO modules:**
157
- Just list components/services in flat structure.
158
-
159
- ## Architecture Document Structure (v2)
160
-
161
- ### 1. Executive Summary
162
-
163
- Brief prose with:
164
- - What the system is
165
- - Architecture pattern + why chosen
166
- - Key domains with module counts
167
- - Critical business rules
168
- - Scale targets
169
-
170
- ### 2. Decision Summary
171
-
172
- | Category | Decision | Rationale |
173
- |----------|----------|-----------|
174
- | Architecture | {{pattern}} | {{why_chosen}} |
175
- | Database | {{db_choice}} | {{why_chosen}} |
176
-
177
- *Choose pattern based on project needs — see "Architecture Style Selection" below*
178
-
179
- ### 3. System Context
180
-
181
- ASCII diagram showing:
182
- - External systems
183
- - Main system boundary
184
- - Internal modules
185
- - Storage layer
186
-
187
- ### 4. Modules Overview
188
-
189
- For each domain, then each module:
190
-
191
- ```markdown
192
- ### {{Domain}} ({{N}} modules)
193
-
194
- #### {{Module}}
195
-
196
- **Purpose:** {{single_responsibility}}
197
-
198
- **Internal Services:**
199
-
200
- | Service | Responsibilities | Storage |
201
- |---------|-----------------|---------|
202
-
203
- **Database Schema:**
204
- ```
205
- table_name # field descriptions
206
- ```
207
-
208
- **Events:**
209
- - **Produces:** Event1, Event2
210
- - **Consumes:** Event3
211
-
212
- **Notes:**
213
- - Important details
214
- ```
215
-
216
- ### 5. Data Architecture
217
-
218
- | Module | Primary DB | Cache | Other |
219
- |--------|-----------|-------|-------|
220
-
221
- With entity relations diagram.
222
-
223
- ### 6. Integration
224
-
225
- External systems table + internal communication table.
226
-
227
- ### 7. Cross-Cutting Concerns
228
-
229
- - Security (AuthN, AuthZ)
230
- - Observability (Logging, Metrics, Tracing)
231
- - Error Handling table
232
-
233
- ### 8. NFR Compliance
234
-
235
- | NFR | Requirement | How Addressed |
236
- |-----|-------------|---------------|
237
-
238
- ### 9. References
239
-
240
- ```
241
- → PRD: `docs/prd.md`
242
- → ADRs: `docs/architecture/adr/`
243
- ```
244
-
245
- ## Unit Documentation
14
+ ```xml
15
+ <architecture_design>
16
+ <definition>Design system architecture, define module boundaries, choose patterns</definition>
17
+
18
+ <TOY lines="200-500" diagrams="C4 Context+Container" adrs="None">Core components only</TOY>
19
+ <SMALL lines="500-1000" diagrams="+C4 Component" adrs="2-3">Clear module boundaries</SMALL>
20
+ <MEDIUM lines="1000-2000" diagrams="+Sequences+ER" adrs="5-10">Complete system design</MEDIUM>
21
+ <LARGE lines="2000-4000" diagrams="+Deployment+State" adrs="10-20">Multiple files OK</LARGE>
22
+ <ENTERPRISE lines="4000+" diagrams="All" adrs="20+">Per-domain files</ENTERPRISE>
23
+ </depth_by_size>
24
+
25
+ <modules>
26
+ <TOY>No modules - flat components</TOY>
27
+ <SMALL>No modules - flat services</SMALL>
28
+ <MEDIUM>YES - 3-5 modules (Purpose, Services, Data, API, Events)</MEDIUM>
29
+ <LARGE>YES - 5-10 domains</LARGE>
30
+ <ENTERPRISE>YES - 10+ bounded contexts</ENTERPRISE>
31
+ </modules>
32
+
33
+ <structure>
34
+ <executive_summary>What system is, pattern choice, key domains, scale</executive_summary>
35
+ <decision_summary>Table: Category | Decision | Rationale</decision_summary>
36
+ <system_context>C4 Context diagram (ASCII)</system_context>
37
+ <modules_overview>Per domain/module: Purpose, Services, Data, Events</modules_overview>
38
+ <data_architecture>Table: Module | DB | Cache | ER diagram</data_architecture>
39
+ <integration>External systems, internal communication</integration>
40
+ <cross_cutting>Security, Observability, Error Handling</cross_cutting>
41
+ <nfr_compliance>Table: NFR | Requirement | How Addressed</nfr_compliance>
42
+ <references>Links to PRD, ADRs, Units</references>
43
+ </structure>
44
+
45
+ <unit_documentation>
46
+ <MEDIUM_plus>Create docs/units/module-name/ for each module</MEDIUM_plus>
47
+ <use_skill>unit-writing</use_skill>
48
+ </unit_documentation>
246
49
 
247
50
  For each module/domain/entity, create separate Unit document.
248
51
 
@@ -254,365 +57,72 @@ Reference in architecture:
254
57
  → Unit: `Task`
255
58
  ```
256
59
 
257
- ## Architecture Style Selection
258
-
259
- **Choose based on project context no default!**
260
-
261
- ### Style Comparison
262
-
263
- | Style | Best For | Team Size | Complexity |
264
- |-------|----------|-----------|------------|
265
- | **Layered** | Simple CRUD apps, MVPs | 1-3 devs | Low |
266
- | **Hexagonal** | Testable business logic, many integrations | 3-10 devs | Medium |
267
- | **Clean Architecture** | Complex domain, long-term maintainability | 5+ devs | Medium-High |
268
- | **Microservices** | Independent scaling, multiple teams | 10+ devs | High |
269
- | **Vertical Slices** | Feature teams, rapid iteration | Any | Medium |
270
-
271
- ### Layered Architecture
272
-
273
- ```
274
- ┌─────────────────────────────┐
275
- │ Presentation │ ← Controllers, Views
276
- ├─────────────────────────────┤
277
- │ Application │ ← Services, DTOs
278
- ├─────────────────────────────┤
279
- │ Domain │ ← Entities, Business Logic
280
- ├─────────────────────────────┤
281
- │ Infrastructure │ ← DB, External APIs
282
- └─────────────────────────────┘
283
-
284
- Dependencies: Top → Bottom (each layer depends on layer below)
285
- ```
286
-
287
- **Use when:** Simple CRUD, small team, fast delivery needed
288
- **Avoid when:** Complex business rules, many external integrations
289
-
290
- ### Hexagonal (Ports & Adapters)
291
-
292
- ```
293
- ┌─────────────────────────────────────────────────────┐
294
- │ Infrastructure │
295
- │ ┌───────────────────────────────────────────────┐ │
296
- │ │ Application │ │
297
- │ │ ┌─────────────────────────────────────────┐ │ │
298
- │ │ │ Domain │ │ │
299
- │ │ │ (Business Logic - NO dependencies!) │ │ │
300
- │ │ └─────────────────────────────────────────┘ │ │
301
- │ │ Use Cases (Orchestration) │ │
302
- │ └───────────────────────────────────────────────┘ │
303
- │ Adapters (HTTP, DB, Kafka, External) │
304
- └─────────────────────────────────────────────────────┘
305
-
306
- Dependencies: Outside → Inside (Infrastructure → Application → Domain)
307
- ```
308
-
309
- **Use when:** Many integrations, need to swap implementations, testability critical
310
- **Avoid when:** Simple apps, overhead not justified
311
-
312
- ### Clean Architecture
313
-
314
- ```
315
- ┌─────────────────────────────────────────────────────┐
316
- │ Frameworks & Drivers │
317
- │ ┌───────────────────────────────────────────────┐ │
318
- │ │ Interface Adapters │ │
319
- │ │ ┌───────────────────────────────────────┐ │ │
320
- │ │ │ Application Business │ │ │
321
- │ │ │ ┌─────────────────────────────────┐ │ │ │
322
- │ │ │ │ Enterprise Business Rules │ │ │ │
323
- │ │ │ │ (Entities) │ │ │ │
324
- │ │ │ └─────────────────────────────────┘ │ │ │
325
- │ │ │ (Use Cases) │ │ │
326
- │ │ └───────────────────────────────────────┘ │ │
327
- │ │ Controllers, Gateways, Presenters │ │
328
- │ └───────────────────────────────────────────────┘ │
329
- │ Web, DB, UI, External │
330
- └─────────────────────────────────────────────────────┘
331
-
332
- Dependency Rule: Source code dependencies point INWARD only
333
- ```
334
-
335
- **Use when:** Complex domain, multiple UIs, long-term project
336
- **Avoid when:** MVP, tight deadlines
337
-
338
- ### Vertical Slices
339
-
340
- ```
341
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
342
- │ Feature A │ │ Feature B │ │ Feature C │
343
- │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │
344
- │ │ Handler │ │ │ │ Handler │ │ │ │ Handler │ │
345
- │ │ Logic │ │ │ │ Logic │ │ │ │ Logic │ │
346
- │ │ Data │ │ │ │ Data │ │ │ │ Data │ │
347
- │ └─────────┘ │ │ └─────────┘ │ │ └─────────┘ │
348
- └─────────────┘ └─────────────┘ └─────────────┘
349
- │ │ │
350
- └───────────────┴───────────────┘
351
- Shared Kernel
352
- ```
353
-
354
- **Use when:** Feature teams, CQRS, rapid delivery
355
- **Avoid when:** Heavy cross-feature dependencies
356
-
357
- ---
358
-
359
- ## Module Boundaries
360
-
361
- Regardless of architecture style, each module must have:
362
-
363
- - **Single responsibility** - One business capability
364
- - **Explicit data ownership** - Clear which entities it owns
365
- - **Defined interfaces** - API contracts for communication
366
- - **Loose coupling** - Communicate via events/APIs, not direct imports
367
-
368
- **Communication patterns:**
369
-
370
- | Pattern | Use When | Example |
371
- |---------|----------|---------|
372
- | Direct call (in-process) | Same deployment, sync needed | Service → Repository |
373
- | REST/gRPC | Cross-service, request-response | Order → Inventory check |
374
- | Events (Kafka/RabbitMQ) | Async, decoupled, eventual consistency | OrderPlaced → Notification |
375
- | Shared DB (avoid) | Legacy, temporary | — migrate away |
376
-
377
- ---
378
-
379
- ## Architectural Patterns
380
-
381
- ### Pattern Selection Matrix
382
-
383
- | Pattern | Use When | Avoid When |
384
- |---------|----------|------------|
385
- | **Modular Monolith** | MVP, small team, unclear boundaries | High scale needs, multiple teams |
386
- | **Microservices** | Clear boundaries, independent scaling | Small team, shared data |
387
- | **CQRS** | Different read/write models, complex queries | Simple CRUD |
388
- | **Event Sourcing** | Audit trail critical, temporal queries | Simple state, storage concerns |
389
- | **Saga** | Distributed transactions, compensation needed | Single DB, simple workflows |
390
-
391
- ### CQRS (Command Query Responsibility Segregation)
392
-
393
- ```
394
- ┌─────────────┐ ┌─────────────┐
395
- │ Command │ │ Query │
396
- │ (Write) │ │ (Read) │
397
- └──────┬──────┘ └──────┬──────┘
398
- │ │
399
- ▼ ▼
400
- ┌─────────────┐ ┌─────────────┐
401
- │ Write Model │ │ Read Model │
402
- │ (normalized)│ │(denormalized│
403
- └──────┬──────┘ └──────┬──────┘
404
- │ Sync/Event │
405
- └────────────────────┘
406
- ```
407
-
408
- **When to use:**
409
- - Read/write ratio > 10:1
410
- - Complex query requirements
411
- - Different consistency needs
412
-
413
- **Trade-offs:**
414
- | Benefit | Cost |
415
- |---------|------|
416
- | Optimized read performance | Eventual consistency |
417
- | Independent scaling | Data sync complexity |
418
- | Simpler query logic | More infrastructure |
419
-
420
- ### Event Sourcing
421
-
422
- ```
423
- ┌──────────┐ ┌──────────┐ ┌──────────┐
424
- │ Command │───►│ Event │───►│ State │
425
- │ │ │ Store │ │ (derived)│
426
- └──────────┘ └──────────┘ └──────────┘
427
-
428
- ▼ Replay
429
- ┌──────────┐
430
- │Projection│
431
- └──────────┘
432
- ```
433
-
434
- **When to use:**
435
- - Full audit trail required
436
- - Temporal queries ("state at time X")
437
- - Complex domain with many state transitions
438
-
439
- **Trade-offs:**
440
- | Benefit | Cost |
441
- |---------|------|
442
- | Complete audit history | Storage growth |
443
- | Time-travel queries | Query complexity |
444
- | Event replay for debugging | Schema evolution |
445
-
446
- ### Saga Pattern (Distributed Transactions)
447
-
448
- ```
449
- ┌────────┐ ┌────────┐ ┌────────┐
450
- │ Step 1 │───►│ Step 2 │───►│ Step 3 │
451
- └────────┘ └────────┘ └────────┘
452
- │ │ │
453
- ▼ ▼ ▼
454
- Compensate 1 Compensate 2 Compensate 3
455
- ▲ ▲ │
456
- └─────────────┴─────────────┘
457
- (on failure)
458
- ```
459
-
460
- **Types:**
461
- | Type | Coordination | Use When |
462
- |------|--------------|----------|
463
- | Choreography | Events | Simple flows, few services |
464
- | Orchestration | Central orchestrator | Complex flows, many services |
465
-
466
- **Example: Order Saga**
467
- 1. Reserve inventory → (compensate: release inventory)
468
- 2. Charge payment → (compensate: refund)
469
- 3. Ship order → (compensate: cancel shipment)
470
-
471
- ### Resilience Patterns
472
-
473
- | Pattern | Problem Solved | Implementation |
474
- |---------|----------------|----------------|
475
- | **Circuit Breaker** | Cascading failures | Open after N failures, half-open retry |
476
- | **Retry with Backoff** | Transient failures | Exponential backoff + jitter |
477
- | **Bulkhead** | Resource exhaustion | Isolate thread pools/connections |
478
- | **Timeout** | Hanging requests | Set max wait time |
479
- | **Fallback** | Service unavailable | Default response, cached data |
480
-
481
- **Circuit Breaker States:**
482
- ```
483
- success
484
- ┌───────────────┐
485
- │ │
486
- ▼ N failures │
487
- ┌────────┐ ┌────────┐
488
- │ CLOSED │────►│ OPEN │
489
- └────────┘ └────────┘
490
- ▲ │
491
- │ timeout ▼
492
- │ ┌─────────┐
493
- └──────────│HALF-OPEN│
494
- success └─────────┘
60
+ <architecture_styles>
61
+ <Layered best_for="Simple CRUD, MVPs" team="1-3" complexity="Low"/>
62
+ <Hexagonal best_for="Testable logic, many integrations" team="3-10" complexity="Medium"/>
63
+ <Clean best_for="Complex domain, long-term" team="5+" complexity="Medium-High"/>
64
+ <Microservices best_for="Independent scaling, multiple teams" team="10+" complexity="High"/>
65
+ <Vertical_Slices best_for="Feature teams, rapid iteration" team="Any" complexity="Medium"/>
66
+ </architecture_styles>
67
+
68
+ <CQRS use_when="Read/write ratio >10:1, complex queries" avoid="Simple CRUD"/>
69
+ <Event_Sourcing use_when="Audit trail, temporal queries" avoid="Simple state"/>
70
+ <Saga use_when="Distributed transactions" types="Choreography, Orchestration"/>
71
+ <Resilience>Circuit Breaker, Retry, Bulkhead, Timeout, Fallback</Resilience>
72
+ </patterns>
73
+
74
+ <module_boundaries>
75
+ <single_responsibility>One business capability</single_responsibility>
76
+ <data_ownership>Clear entity ownership</data_ownership>
77
+ <interfaces>API contracts</interfaces>
78
+ <communication>Direct call, REST/gRPC, Events (avoid Shared DB)</communication>
79
+ </module_boundaries>
80
+
81
+ <traceability>
82
+ <after_architecture>Update requirements.md with Module/Arch § columns</after_architecture>
83
+ </traceability>
84
+ </architecture_design>
495
85
  ```
496
86
 
497
87
  ---
498
88
 
499
- ## Trade-off Analysis
500
-
501
- ### Decision Matrix Template
502
-
503
- When choosing between options, use weighted scoring:
504
-
505
- | Criteria | Weight | Option A | Option B | Option C |
506
- |----------|--------|----------|----------|----------|
507
- | Performance | 30% | 4 (1.2) | 3 (0.9) | 5 (1.5) |
508
- | Complexity | 25% | 3 (0.75) | 5 (1.25) | 2 (0.5) |
509
- | Team expertise | 20% | 5 (1.0) | 3 (0.6) | 2 (0.4) |
510
- | Maintainability | 15% | 4 (0.6) | 4 (0.6) | 3 (0.45) |
511
- | Cost | 10% | 3 (0.3) | 4 (0.4) | 5 (0.5) |
512
- | **Total** | | **3.85** | **3.75** | **3.35** |
513
-
514
- *Scores: 1-5, higher is better*
515
-
516
- ### Common Trade-offs
517
-
518
- | Decision | Option A | Option B | Key Factor |
519
- |----------|----------|----------|------------|
520
- | Monolith vs Microservices | Simple ops, shared DB | Independent deploy, complexity | Team size, scale needs |
521
- | SQL vs NoSQL | ACID, complex queries | Flexible schema, horizontal scale | Data structure, consistency |
522
- | Sync vs Async | Simple, immediate | Resilient, decoupled | Latency tolerance |
523
- | REST vs gRPC | Universal, cacheable | Performance, streaming | Client types |
524
- | Polling vs Webhooks | Simple, reliable | Real-time, efficient | Latency requirements |
525
-
526
- ---
527
-
528
- ## Quality Attribute Scenarios
529
-
530
- ### Performance Scenario Template
89
+ ## Example: MEDIUM E-commerce Architecture
531
90
 
91
+ ```yaml
92
+ id: ARCH-001
93
+ version: 1.0
532
94
  ```
533
- Source: [Who/what triggers]
534
- Stimulus: [What happens]
535
- Environment: [Under what conditions]
536
- Artifact: [What part of system]
537
- Response: [What system does]
538
- Measure: [How to verify]
539
- ```
540
-
541
- ### Example Scenarios
542
-
543
- **Performance:**
544
- | Element | Value |
545
- |---------|-------|
546
- | Source | 1000 concurrent users |
547
- | Stimulus | Submit search query |
548
- | Environment | Normal operation |
549
- | Artifact | Search API |
550
- | Response | Return results |
551
- | Measure | 95th percentile < 200ms |
552
95
 
553
- **Availability:**
554
- | Element | Value |
555
- |---------|-------|
556
- | Source | Any user |
557
- | Stimulus | Request any API |
558
- | Environment | Peak load |
559
- | Artifact | Core services |
560
- | Response | Respond successfully |
561
- | Measure | 99.9% uptime monthly |
96
+ # Architecture Document
562
97
 
563
- **Security:**
564
- | Element | Value |
565
- |---------|-------|
566
- | Source | Unauthenticated user |
567
- | Stimulus | Access protected resource |
568
- | Environment | Normal operation |
569
- | Artifact | API Gateway |
570
- | Response | Return 401, log attempt |
571
- | Measure | 100% unauthorized blocked |
98
+ ## Executive Summary
572
99
 
573
- ### NFR Architecture Mapping
100
+ E-commerce platform using Hexagonal Architecture with 3 modules: Order, Inventory, Payment.
574
101
 
575
- | NFR Type | Architectural Tactics |
576
- |----------|----------------------|
577
- | **Performance** | Caching, CDN, read replicas, async processing |
578
- | **Scalability** | Horizontal scaling, sharding, queue-based load leveling |
579
- | **Availability** | Redundancy, health checks, circuit breakers, multi-AZ |
580
- | **Security** | Auth gateway, encryption, WAF, rate limiting |
581
- | **Maintainability** | Modular design, clear interfaces, documentation |
102
+ ## Decision Summary
582
103
 
583
- ---
104
+ | Category | Decision | Rationale |
105
+ |----------|----------|-----------|
106
+ | Architecture | Hexagonal | Testability, many integrations |
107
+ | Database | PostgreSQL | ACID, complex queries |
584
108
 
585
- ### Reference Format
109
+ ## Modules Overview
586
110
 
587
- Always use `→` prefix:
588
- ```
589
- → Unit: `catalog`
590
- → FR: `FR-001`
591
- → ADR: `ADR-001`
592
- → PRD: `docs/prd.md`
593
- ```
111
+ ### Order Management Module
594
112
 
595
- ## Validation Checklist
113
+ **Purpose:** Order lifecycle management
596
114
 
597
- Before completing:
598
- - [ ] All PRD functional areas have architectural home
599
- - [ ] All NFRs have concrete architectural support
600
- - [ ] Module boundaries are clear
601
- - [ ] Data ownership is explicit (each entity has ONE owner)
602
- - [ ] No circular dependencies between modules
603
- - [ ] Integration points are well-defined
604
- - [ ] ADRs exist for major decisions
605
- - [ ] Uses `→` reference format
606
- - [ ] Unit docs created for key modules
115
+ **Internal Services:**
116
+ - OrderService: CRUD
117
+ - OrderWorkflowService: Status transitions
607
118
 
608
- ## Output
119
+ **Data Ownership:**
120
+ - orders, order_items tables
609
121
 
610
- - Main: `docs/architecture.md`
611
- - Units: `docs/architecture/units/` or inline
612
- - ADRs: `docs/architecture/adr/`
122
+ **API:**
123
+ - POST /orders
124
+ - GET /orders/{id}
613
125
 
614
- ## Related Skills
126
+ Unit: `docs/units/order-management/`
615
127
 
616
- - `adr-writing` - For architecture decisions
617
- - `unit-writing` - For module/entity documentation
618
- - `architecture-validation` - For validation
128
+ See `template.md` for full format.