@torus-engineering/tas-kit 1.6.0 → 1.8.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 (71) hide show
  1. package/.claude/commands/tas-adr.md +33 -29
  2. package/.claude/commands/tas-api-test.md +95 -0
  3. package/.claude/commands/tas-bug.md +113 -109
  4. package/.claude/commands/tas-design.md +37 -33
  5. package/.claude/commands/tas-dev.md +128 -115
  6. package/.claude/commands/tas-e2e-mobile.md +155 -0
  7. package/.claude/commands/tas-e2e-web.md +163 -0
  8. package/.claude/commands/tas-e2e.md +102 -0
  9. package/.claude/commands/tas-epic.md +35 -31
  10. package/.claude/commands/tas-feature.md +47 -43
  11. package/.claude/commands/tas-fix.md +51 -47
  12. package/.claude/commands/tas-functest-mobile.md +144 -0
  13. package/.claude/commands/tas-functest-web.md +192 -0
  14. package/.claude/commands/tas-functest.md +76 -0
  15. package/.claude/commands/tas-plan.md +200 -184
  16. package/.claude/commands/tas-prd.md +37 -33
  17. package/.claude/commands/tas-review.md +111 -104
  18. package/.claude/commands/tas-sad.md +43 -39
  19. package/.claude/commands/tas-security.md +81 -80
  20. package/.claude/commands/tas-story.md +91 -87
  21. package/.claude/commands/tas-verify.md +51 -41
  22. package/.claude/rules/common/post-review-agent.md +49 -39
  23. package/.claude/rules/common/testing.md +24 -0
  24. package/.claude/rules/common/token-logging.md +27 -0
  25. package/.claude/rules/csharp/api-testing.md +171 -0
  26. package/.claude/rules/csharp/patterns.md +10 -0
  27. package/.claude/rules/python/patterns.md +10 -0
  28. package/.claude/rules/typescript/patterns.md +10 -0
  29. package/.claude/rules/web/performance.md +9 -0
  30. package/.claude/skills/api-design/SKILL.md +3 -1
  31. package/.claude/skills/{backend-patterns → js-backend-patterns}/SKILL.md +2 -1
  32. package/.claude/skills/tas-implementation-complete/SKILL.md +99 -97
  33. package/.claude/skills/tas-tdd/SKILL.md +123 -82
  34. package/.claude/skills/token-logger/SKILL.md +19 -0
  35. package/.tas/templates/E2E-Execution-Report.md +198 -0
  36. package/.tas/templates/E2E-Mobile-Spec.md +130 -0
  37. package/.tas/templates/E2E-Report.md +174 -0
  38. package/.tas/templates/E2E-Scenario.md +180 -0
  39. package/.tas/templates/E2E-Web-Spec.md +164 -0
  40. package/.tas/templates/Feature.md +55 -55
  41. package/.tas/templates/Func-Test-Script.md +254 -0
  42. package/.tas/templates/Func-Test-Spec.md +187 -0
  43. package/.tas/templates/SAD.md +274 -64
  44. package/.tas/templates/Story.md +90 -88
  45. package/bin/cli.js +56 -49
  46. package/lib/deleted-files.json +33 -0
  47. package/lib/install.js +213 -114
  48. package/package.json +34 -34
  49. package/.claude/agents/README.md +0 -83
  50. package/.claude/agents/ado-agent.md +0 -39
  51. package/.claude/agents/code-architect.md +0 -62
  52. package/.claude/agents/code-simplifier.md +0 -53
  53. package/.claude/agents/comment-analyzer.md +0 -59
  54. package/.claude/agents/conversation-analyzer.md +0 -57
  55. package/.claude/agents/docs-lookup.md +0 -55
  56. package/.claude/agents/harness-optimizer.md +0 -62
  57. package/.claude/agents/loop-operator.md +0 -56
  58. package/.claude/agents/performance-optimizer.md +0 -78
  59. package/.claude/agents/pr-test-analyzer.md +0 -68
  60. package/.claude/agents/pytorch-build-resolver.md +0 -76
  61. package/.claude/agents/refactor-cleaner.md +0 -70
  62. package/.claude/agents/seo-specialist.md +0 -75
  63. package/.claude/agents/silent-failure-hunter.md +0 -69
  64. package/.claude/agents/type-design-analyzer.md +0 -75
  65. package/.claude/rules/common/agents.md +0 -65
  66. package/.claude/rules/common/coding-style.md +0 -90
  67. package/.claude/rules/common/development-workflow.md +0 -44
  68. package/.claude/rules/common/git-workflow.md +0 -24
  69. package/.claude/rules/common/performance.md +0 -55
  70. package/.claude/skills/agent-harness-construction/SKILL.md +0 -77
  71. package/.claude/skills/agent-introspection-debugging/SKILL.md +0 -157
@@ -0,0 +1,187 @@
1
+ ---
2
+ created_date:
3
+ updated_date:
4
+ executor:
5
+ status: Draft
6
+ story_id:
7
+ feature_id:
8
+ epic_id:
9
+ platform: # mobile | web | backend
10
+ ---
11
+
12
+ # Functional Test Specification: {Story Name}
13
+
14
+ **Epic**: [{Epic_ID}]({Epic_LINK})
15
+ **Feature**: [{Feature_ID}]({FEATURE_LINK})
16
+ **Story**: [{Story_ID}]({STORY_LINK})
17
+ **Platform**: {{platform}}
18
+ **Author**: @[executor]
19
+ **Created**: [created_date]
20
+ **Status**: [status] (Draft | Ready | Implemented | Verified)
21
+
22
+ ---
23
+
24
+ ## Test Case Naming Convention
25
+
26
+ > Functional Tests dung type code **FT** theo format chuẩn TAS
27
+
28
+ ### Format
29
+ ```
30
+ {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_{NUMBER}_{MODIFIER}
31
+ ```
32
+
33
+ ### Example
34
+ ```
35
+ AL_E002_F002_S001_FT_001_H - Functional Test Happy path
36
+ AL_E002_F002_S001_FT_002_N - Functional Test Negative
37
+ AL_E002_F002_S001_FT_003_E - Functional Test Edge case
38
+ ```
39
+
40
+ ### Modifier Codes
41
+
42
+ | Code | Modifier | Description |
43
+ |------|----------|-------------|
44
+ | H | Happy | Positive test - success scenario |
45
+ | N | Negative | Negative test - failure scenario |
46
+ | E | Edge | Edge case - boundary conditions |
47
+ | S | Security | Security test |
48
+ | P | Performance | Performance test |
49
+
50
+ ---
51
+
52
+ ## Overview
53
+
54
+ > Brief description of what this functional test suite validates for the Story
55
+
56
+ **Scope**: {What user functionality is being tested}
57
+ **Target Users**: {Clinical / Organic / Both}
58
+
59
+ ---
60
+
61
+ ## AC to Functional Test Mapping
62
+
63
+ > QUAN TRONG: Moi FT case PHAI reference AC-ID de dam bao traceability.
64
+ > Khi AC thay doi, grep theo AC-ID de biet FT nao can update.
65
+
66
+ | AC ID | AC Description (Given/When/Then) | FT Test ID | Test Scenario | Modifier | Priority | Status |
67
+ |-------|----------------------------------|------------|---------------|----------|----------|--------|
68
+ | AC-1 | {Given...When...Then...} | {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_001_H | {Happy path description} | Happy | P0 | Draft |
69
+ | AC-1 | {Given...When...Then...} | {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_002_N | {Negative scenario} | Negative | P0 | Draft |
70
+ | AC-1 | {Given...When...Then...} | {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_003_E | {Edge case} | Edge | P1 | Draft |
71
+ | AC-2 | {Given...When...Then...} | {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_004_H | {Happy path description} | Happy | P0 | Draft |
72
+
73
+ ### Coverage Requirements
74
+ - Each AC MUST have at minimum **1 Happy path (H)** test
75
+ - Each AC SHOULD have **1 Negative (N)** test if error scenarios exist
76
+ - Each AC MAY have **1 Edge case (E)** test if boundary conditions apply
77
+
78
+ ---
79
+
80
+ ## Test Scenarios
81
+
82
+ ### FT_001_H: {Title - Happy Path}
83
+ - **AC Reference**: AC-1
84
+ - **Preconditions**:
85
+ - {List preconditions}
86
+ - **Test Data**:
87
+ - {Hardcoded values used in test}
88
+ - {Env-specific: from test-data.{env}.json}
89
+ - {Credentials: from .env via process.env}
90
+ - **Steps**:
91
+ 1. **Given** {initial state}
92
+ 2. **When** {user action}
93
+ 3. **Then** {expected outcome}
94
+ - **Expected Result**: {Detailed expected behavior}
95
+
96
+ ### FT_002_N: {Title - Negative Scenario}
97
+ - **AC Reference**: AC-1
98
+ - **Preconditions**:
99
+ - {List preconditions}
100
+ - **Test Data**:
101
+ - {Invalid/error data}
102
+ - **Steps**:
103
+ 1. **Given** {initial state}
104
+ 2. **When** {user performs invalid action}
105
+ 3. **Then** {expected error handling}
106
+ - **Expected Result**: {Error message, recovery option}
107
+
108
+ ### FT_003_E: {Title - Edge Case}
109
+ - **AC Reference**: AC-1
110
+ - **Preconditions**:
111
+ - {Boundary condition setup}
112
+ - **Test Data**:
113
+ - {Boundary values}
114
+ - **Steps**:
115
+ 1. **Given** {boundary state}
116
+ 2. **When** {boundary action}
117
+ 3. **Then** {graceful handling}
118
+ - **Expected Result**: {Handled gracefully without crash}
119
+
120
+ ---
121
+
122
+ ## Test Data Requirements
123
+
124
+ | Data Item | Value | Source | Environment-Specific | Notes |
125
+ |-----------|-------|--------|---------------------|-------|
126
+ | User Email | test@example.com | test-data.{env}.json | Yes | Different per env |
127
+ | User Password | (from .env) | process.env.TEST_USER_PASSWORD | Yes | NEVER hardcode |
128
+ | {Entity} ID | {value} | test-data.{env}.json | Yes | Pre-seeded |
129
+ | {Static Data} | {value} | Hardcoded in test | No | Same all envs |
130
+
131
+ ### Environment Data Files
132
+ - **Dev**: `apps/{platform}/e2e/data/test-data.dev.json`
133
+ - **Staging**: `apps/{platform}/e2e/data/test-data.staging.json`
134
+ - **Prod**: `apps/{platform}/e2e/data/test-data.prod.json` (smoke tests only)
135
+
136
+ ### Credentials
137
+ > NEVER put passwords/tokens in JSON files or test code.
138
+ > Always use `.env` via `process.env`.
139
+
140
+ ---
141
+
142
+ ## Platform-Specific Implementation
143
+
144
+ {{#if platform === "mobile"}}
145
+ ### Mobile (Detox)
146
+ - **Script Location**: `apps/mobile/e2e/features/{epic-slug}/{feature-slug}/{story-slug}.func.e2e.ts`
147
+ - **Test IDs**: Import from `apps/mobile/e2e/test-ids.ts`
148
+ - **Data Loader**: Import from `apps/mobile/e2e/helpers/data-loader.ts`
149
+ - **Test Helpers**: Import from `apps/mobile/e2e/helpers/test-utils.ts`
150
+ - **Run Command**: `yarn functest:mobile:{feature-slug}`
151
+ {{/if}}
152
+ {{#if platform === "web"}}
153
+ ### Web (Playwright)
154
+ - **Script Location**: `apps/web/e2e/features/{epic-slug}/{feature-slug}/{story-slug}.func.spec.ts`
155
+ - **Selectors**: Use `data-testid` attributes
156
+ - **Data Loader**: Import from `apps/web/e2e/helpers/data-loader.ts`
157
+ - **Test Helpers**: Import from `apps/web/e2e/helpers/test-utils.ts`
158
+ - **Run Command**: `yarn functest:web:{feature-slug}`
159
+ - **Viewports**: Test mobile (375px), tablet (768px), desktop (1280px)
160
+ {{/if}}
161
+
162
+ ---
163
+
164
+ ## Traceability
165
+
166
+ > This section enables impact analysis when requirements change.
167
+
168
+ ### How to find impacted tests when AC changes:
169
+ 1. Note the AC-ID that changed (e.g., AC-1)
170
+ 2. Search this document's "AC to Functional Test Mapping" table
171
+ 3. All FT Test IDs in rows matching that AC-ID need review
172
+ 4. Find corresponding script files using the FT Test ID as describe block name
173
+
174
+ ### Reverse traceability (test to requirement):
175
+ Each test script `describe` block includes the AC-ID in comments:
176
+ ```typescript
177
+ // AC Reference: AC-1
178
+ describe('{PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_FT_001_H', () => { ... });
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Changelog
184
+
185
+ | Date | Changes | Author |
186
+ |------|---------|--------|
187
+ | [created_date] | Initial functional test spec created | @[executor] |
@@ -1,64 +1,274 @@
1
- # Solution Architecture Document (SAD)
2
-
3
- > **Version:** 1.0
4
- > **Last Updated:** [Date]
5
- > **Author:** [SE name]
6
-
7
- ---
8
-
9
- ## 1. Executive Summary
10
- ### 1.1 Purpose
11
- ### 1.2 Scope
12
- ### 1.3 Key Objectives
13
-
14
- ## 2. Architecture Vision
15
- ### 2.1 Vision Statement
16
- ### 2.2 Architecture Principles
17
- ### 2.3 Constraints & Assumptions
18
-
19
- ## 3. Business Requirements
20
- ### 3.1 Business Problem
21
- ### 3.2 Stakeholders
22
- ### 3.3 Functional Requirements
23
- ### 3.4 Non-Functional Requirements
24
-
25
- ## 4. Technology Baseline
26
- ### 4.1 Current State
27
- ### 4.2 Technology Stack
28
- ### 4.3 Dependencies
29
-
30
- ## 5. System Context (C4 Level 1)
31
- <!-- Dùng Mermaid flow diagram, :::mermaid wrapper, không dùng () -->
32
-
33
- ## 6. Logical View (C4 Level 2 - Container)
34
- <!-- Dùng Mermaid flow diagram -->
35
-
36
- ## 7. Component View (C4 Level 3)
37
- <!-- Dùng Mermaid flow diagram -->
38
-
39
- ## 8. Data Architecture & ERD
40
- <!-- Dùng Mermaid erDiagram -->
41
-
42
- ## 9. Integration & Data Flow
43
- <!-- Dùng Mermaid sequenceDiagram -->
44
-
45
- ## 10. Security Architecture
46
-
47
- ## 11. Deployment View
48
- <!-- Dùng Mermaid flow diagram -->
49
-
50
- ## 12. Non-Functional Requirements
51
-
52
- ## 13. Architectural Decisions
53
- | ID | Decision | Status | Date | Rationale |
54
- |----|----------|--------|------|-----------|
55
-
56
- ## 14. Risks & Mitigation
57
- | Risk | Impact | Probability | Mitigation |
58
- |------|--------|-------------|------------|
59
-
60
- ---
61
-
62
- ## Changelog
63
- | Date | Version | Changes | Author |
64
- |------|---------|---------|--------|
1
+ # Solution Architecture Document (SAD)
2
+
3
+ > **Version:** 1.0
4
+ > **Last Updated:** [Date]
5
+ > **Author:** [SE name]
6
+
7
+ ---
8
+
9
+ ## 1. Executive Summary
10
+
11
+ <!-- MANDATORY. Viết cho người đọc không có technical background.
12
+ Bắt buộc:
13
+ - 1.1 Purpose: Tại sao SAD này tồn tại, vấn đề gì cần giải quyết
14
+ - 1.2 Scope: Hệ thống nào, ranh giới nào được/không được cover
15
+ - 1.3 Key Objectives: 3-5 mục tiêu kiến trúc cụ thể, đo lường được
16
+ Format: Prose ngắn, tối đa 1 trang tổng cộng -->
17
+
18
+ ### 1.1 Purpose
19
+ ### 1.2 Scope
20
+ ### 1.3 Key Objectives
21
+
22
+ ---
23
+
24
+ ## 2. Architecture Vision
25
+
26
+ <!-- MANDATORY.
27
+ Bắt buộc:
28
+ - 2.1 Vision Statement: 1-2 câu mô tả "kiến trúc này hướng tới điều gì"
29
+ - 2.2 Architecture Principles: 4-8 nguyên tắc dẫn dắt quyết định thiết kế
30
+ (vd: Stateless services, API-first, Defense in depth, Fail fast)
31
+ - 2.3 Constraints & Assumptions: Ràng buộc kỹ thuật/tổ chức, giả định đang được chấp nhận
32
+ Format: Bullet list cho principles và constraints -->
33
+
34
+ ### 2.1 Vision Statement
35
+ ### 2.2 Architecture Principles
36
+ ### 2.3 Constraints & Assumptions
37
+
38
+ ---
39
+
40
+ ## 3. Business Requirements
41
+
42
+ <!-- MANDATORY.
43
+ Bắt buộc:
44
+ - 3.1 Business Problem: Mô tả bài toán kinh doanh cần giải quyết
45
+ - 3.2 Stakeholders: Bảng stakeholder (role, concerns, influence)
46
+ - 3.3 Functional Requirements: Danh sách FR-xxx, mỗi item có ID để trace
47
+ - 3.4 Non-Functional Requirements: Danh sách NFR với metric cụ thể
48
+ (vd: Latency P99 < 300ms, Availability 99.9%, RPS 5000)
49
+ Nên có: Priority (Must/Should/Could) cho mỗi requirement
50
+ Format: Table hoặc numbered list với ID (FR-001, NFR-001) -->
51
+
52
+ ### 3.1 Business Problem
53
+ ### 3.2 Stakeholders
54
+ ### 3.3 Functional Requirements
55
+ ### 3.4 Non-Functional Requirements
56
+
57
+ ---
58
+
59
+ ## 4. Technology Baseline
60
+
61
+ <!-- MANDATORY.
62
+ Bắt buộc:
63
+ - 4.1 Current State: Hệ thống hiện tại (nếu là greenfield thì ghi rõ)
64
+ - 4.2 Technology Stack: Bảng layer → technology → version → rationale
65
+ (Frontend / Backend / Database / Infrastructure / Messaging / Monitoring)
66
+ - 4.3 Dependencies: External services, third-party APIs, shared platforms
67
+ Nên có: Diagram current-state nếu là migration/modernization
68
+ Format: Table cho Technology Stack -->
69
+
70
+ ### 4.1 Current State
71
+ ### 4.2 Technology Stack
72
+ ### 4.3 Dependencies
73
+
74
+ ---
75
+
76
+ ## 5. System Context (C4 Level 1)
77
+
78
+ <!-- MANDATORY. Trả lời: "Hệ thống này nằm ở đâu trong hệ sinh thái?"
79
+ Bắt buộc:
80
+ - Mermaid flowchart: hệ thống ở giữa, xung quanh là users và external systems
81
+ - Chú thích mỗi external system: tên, vai trò, protocol giao tiếp
82
+ Không cần: chi tiết nội bộ của hệ thống (để C4 Level 2)
83
+ Format: Mermaid flowchart (dùng :::mermaid wrapper, không dùng () trong node label)
84
+
85
+ Ví dụ:
86
+ :::mermaid
87
+ flowchart TD
88
+ U[fa:fa-user End User] -- |HTTPS| SYS[Your System]
89
+ SYS -- |REST| EXT1[Payment Gateway]
90
+ SYS -- |SMTP| EXT2[Email Service]
91
+ ADMIN[fa:fa-user Admin] -- |HTTPS| SYS
92
+ ::: -->
93
+
94
+ ---
95
+
96
+ ## 6. Logical View (C4 Level 2 — Container)
97
+
98
+ <!-- MANDATORY. Trả lời: "Hệ thống gồm những container nào?"
99
+ Bắt buộc:
100
+ - Mermaid flowchart: tất cả containers (web app, API, DB, cache, queue, ...)
101
+ - Mỗi container: tên, technology, vai trò chính
102
+ - Luồng tương tác giữa containers với protocol/label
103
+ Nên có: Phân nhóm theo bounded context nếu hệ thống lớn
104
+ Format: Mermaid flowchart với subgraph để nhóm theo domain
105
+
106
+ Ví dụ node: WebApp["Web App\n(Next.js / Vercel)"] -->
107
+
108
+ ---
109
+
110
+ ## 7. Component View (C4 Level 3)
111
+
112
+ <!-- CONDITIONAL — Bắt buộc nếu hệ thống có độ phức tạp cao hoặc team mới.
113
+ Trả lời: "Bên trong mỗi container có components nào?"
114
+ Hướng dẫn:
115
+ - Mỗi container phức tạp → một subsection riêng (7.1, 7.2, ...)
116
+ - Container đơn giản (chỉ proxy, static file, thin wrapper) → bỏ qua
117
+ - Không cần drill vào mọi container — chỉ những container có internal logic đáng kể
118
+ Mỗi subsection bắt buộc:
119
+ - Mermaid flowchart liệt kê components bên trong container đó
120
+ - Mỗi component: tên, trách nhiệm chính, interface exposed
121
+ - Dependency direction giữa components (tránh circular)
122
+ Format: Mermaid flowchart với subgraph bao ngoài (tên container), nodes là components
123
+
124
+ Ví dụ:
125
+ :::mermaid
126
+ flowchart TD
127
+ subgraph API["API Service (NestJS)"]
128
+ Router[Route Handler] -- AuthMW[Auth Middleware]
129
+ AuthMW -- Controller[Order Controller]
130
+ Controller -- Service[Order Service]
131
+ Service -- Repo[Order Repository]
132
+ Service -- Queue[Queue Publisher]
133
+ end
134
+ ::: -->
135
+
136
+ ### 7.1 [Container Name]
137
+
138
+ <!-- Bắt buộc: Mermaid component diagram như hướng dẫn trên.
139
+ Nên có: Mô tả ngắn vai trò của container này trước diagram. -->
140
+
141
+ ### 7.2 [Container Name]
142
+
143
+ <!-- Thêm subsection cho mỗi container phức tạp. Xóa subsection này nếu không cần. -->
144
+
145
+ ---
146
+
147
+ ## 8. Data Architecture & ERD
148
+
149
+ <!-- MANDATORY nếu hệ thống có persistence layer.
150
+ Bắt buộc:
151
+ - ERD: entities, attributes (chỉ key fields), relationships với cardinality
152
+ - Data flow overview: data đi từ đâu đến đâu, transform ở đâu
153
+ Nên có:
154
+ - Data classification: PII / Sensitive / Internal / Public cho mỗi entity
155
+ - Retention policy nếu có compliance requirement
156
+ - Sharding/partitioning strategy nếu data scale lớn
157
+ Format: Mermaid erDiagram cho ERD -->
158
+
159
+ ---
160
+
161
+ ## 9. Integration & Data Flow
162
+
163
+ <!-- MANDATORY nếu hệ thống tích hợp với external services hoặc có async flows.
164
+ Bắt buộc:
165
+ - Sequence diagram cho mỗi critical flow (auth, payment, order, ...)
166
+ - Async flows: queue/event-driven patterns phải được diagram rõ
167
+ Nên có: Error/retry flows cho critical paths
168
+ Format: Mermaid sequenceDiagram, một diagram per flow -->
169
+
170
+ ### 9.1 API Design Principles
171
+
172
+ <!-- MANDATORY nếu hệ thống expose API (internal hoặc external).
173
+ Bắt buộc:
174
+ - API Style: REST / GraphQL / gRPC / Event-driven — và lý do chọn
175
+ - Versioning strategy: URL path (/v1/) vs header vs query param
176
+ - Authentication scheme: Bearer JWT / API Key / OAuth2 / mTLS
177
+ - Standard error format: HTTP status codes, error body structure
178
+ Nên có:
179
+ - Rate limiting approach (per-user, per-IP, tiered)
180
+ - Pagination convention (cursor vs offset)
181
+ - Idempotency handling cho mutating operations
182
+ Không đưa vào đây: endpoint list, request/response schema chi tiết
183
+ → Những thứ đó thuộc API Contract document riêng (viết khi implement)
184
+ Format: Bullet list hoặc table ngắn gọn -->
185
+
186
+ ---
187
+
188
+ ## 10. Security Architecture
189
+
190
+ <!-- MANDATORY. Đây là architectural concern, không phải implementation detail.
191
+ Bắt buộc:
192
+ - Threat Model: attack surfaces, trust boundaries, top threats (dùng STRIDE nếu cần)
193
+ - Identity & Auth Flow: AuthN/AuthZ mechanism, token lifecycle, privilege escalation path
194
+ - Data Classification: PII / Sensitive / Internal / Public — handling rules per class
195
+ - Network Security Zones: public / DMZ / private / data tier và rules giữa các zones
196
+ - Encryption: at-rest (algorithm, key management) và in-transit (TLS version, cert strategy)
197
+ Nên có:
198
+ - Secrets management approach (Vault, AWS SSM, env vars strategy)
199
+ - Audit logging scope: what events must be logged, retention
200
+ - Compliance requirements: GDPR, PCI-DSS, SOC2, ... nếu applicable
201
+ Format:
202
+ - Threat model: table (Threat | Vector | Mitigation)
203
+ - Auth flow: Mermaid sequenceDiagram
204
+ - Network zones: Mermaid flowchart với subgraph per zone -->
205
+
206
+ ---
207
+
208
+ ## 11. NFR Strategies
209
+
210
+ <!-- MANDATORY. Mỗi NFR-xxx trong Section 3.4 phải có strategy tương ứng ở đây (reference bằng ID).
211
+ Bắt buộc — cover các categories sau nếu có NFR liên quan:
212
+ - Performance: caching strategy (L1/L2/CDN), DB indexing, query optimization approach
213
+ - Scalability: horizontal vs vertical, stateless design, queue-based decoupling
214
+ - Availability: redundancy model (Active-Active/Active-Passive), failover mechanism, SLA target
215
+ - Resilience: circuit breaker, retry with backoff, bulkhead, timeout policy
216
+ - Observability: structured logging, distributed tracing, metrics & alerting thresholds
217
+ Nên có:
218
+ - Capacity planning baseline: expected load, growth projection, scale trigger points
219
+ - DR strategy: RPO/RTO targets, backup frequency, restore procedure overview
220
+ Format: Table với cột NFR ID để trace ngược về Section 3.4
221
+ | NFR ID | Category | Target | Strategy | Notes |
222
+ |--------|----------|--------|----------|-------|
223
+ | NFR-001 | Latency | P99 < 300ms | Redis cache L2, read replicas | Cache TTL 5m |
224
+ | NFR-002 | Availability | 99.9% | Active-Active, 2 AZs | Health check interval 10s | -->
225
+
226
+ ---
227
+
228
+ ## 12. Deployment Topology
229
+
230
+ <!-- MANDATORY. Trả lời: "Các components chạy ở đâu trong infrastructure?"
231
+ Bắt buộc:
232
+ - Infrastructure diagram: regions, AZs, VPC/subnets, load balancers, entry points
233
+ - Component-to-infrastructure mapping: service X → ECS Fargate, DB → RDS Multi-AZ, ...
234
+ - Traffic entry points: CDN → ALB → API Gateway → Service flow
235
+ - Environment matrix: dev / staging / prod — sự khác nhau về scale, config, isolation
236
+ Nên có:
237
+ - Network topology: public subnet / private subnet / data subnet và routing rules
238
+ - CI/CD pipeline overview: build → test → deploy flow và approval gates
239
+ - Container orchestration config nếu dùng K8s/ECS (namespace, resource limits)
240
+ Format:
241
+ - Mermaid flowchart với subgraph per environment tier hoặc per network zone
242
+ - Environment matrix: table (Component | Dev | Staging | Prod) -->
243
+
244
+ ---
245
+
246
+ ## 13. Architectural Decisions
247
+
248
+ <!-- MANDATORY. Ghi lại mọi quyết định kiến trúc quan trọng và lý do.
249
+ Bắt buộc: Mỗi ADR entry gồm Decision, Status, Date, Rationale
250
+ Nên có: Alternatives considered và tại sao không chọn
251
+ Format: Table — thêm row mỗi khi có quyết định mới
252
+ Status values: Proposed | Accepted | Deprecated | Superseded -->
253
+
254
+ | ID | Decision | Status | Date | Rationale |
255
+ |----|----------|--------|------|-----------|
256
+
257
+ ---
258
+
259
+ ## 14. Risks & Mitigation
260
+
261
+ <!-- MANDATORY.
262
+ Bắt buộc: Risk, Impact (H/M/L), Probability (H/M/L), Mitigation action
263
+ Nên có: Owner và review date cho mỗi risk
264
+ Format: Table, sắp xếp theo Impact × Probability giảm dần -->
265
+
266
+ | Risk | Impact | Probability | Mitigation | Owner |
267
+ |------|--------|-------------|------------|-------|
268
+
269
+ ---
270
+
271
+ ## Changelog
272
+
273
+ | Date | Version | Changes | Author |
274
+ |------|---------|---------|--------|