@educa-corp/sdd-framework 0.2.4 → 0.2.6

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 (152) hide show
  1. package/commands/generate-architecture.md +706 -0
  2. package/commands/generate-architecture.tmpl +194 -0
  3. package/commands/generate-code.md +35 -9
  4. package/commands/generate-code.tmpl +35 -9
  5. package/commands/generate-tech-docs.md +259 -246
  6. package/commands/generate-tech-docs.tmpl +21 -0
  7. package/core/FRAMEWORK_VERSION +1 -1
  8. package/core/commands/generate-architecture.md +706 -0
  9. package/core/commands/generate-code.md +35 -9
  10. package/core/commands/generate-tech-docs.md +259 -246
  11. package/core/skills/setup-ai-first/SKILL.md +12 -4
  12. package/core/templates/architecture.template.md +392 -111
  13. package/core/templates/tech-design.template.md +238 -246
  14. package/docs/01-getting-started/installation.md +47 -112
  15. package/docs/01-getting-started/quickstart.md +58 -72
  16. package/docs/01-getting-started/what-is-sdd.md +75 -0
  17. package/docs/02-concepts/architecture.md +109 -0
  18. package/docs/02-concepts/glossary.md +87 -0
  19. package/docs/02-concepts/overview.md +93 -0
  20. package/docs/02-concepts/pipeline-steps/00-setup.md +102 -0
  21. package/docs/02-concepts/pipeline-steps/01-discovery.md +129 -0
  22. package/docs/02-concepts/pipeline-steps/02-specification.md +130 -0
  23. package/docs/02-concepts/pipeline-steps/03-design-spec.md +90 -0
  24. package/docs/02-concepts/pipeline-steps/04-bdd.md +120 -0
  25. package/docs/02-concepts/pipeline-steps/05-tech-docs.md +101 -0
  26. package/docs/02-concepts/pipeline-steps/06-code.md +119 -0
  27. package/docs/02-concepts/pipeline-steps/07-dev-selftest.md +92 -0
  28. package/docs/02-concepts/pipeline-steps/08-qc-automation.md +102 -0
  29. package/docs/02-concepts/pipeline-steps/09-validate-traces.md +104 -0
  30. package/docs/02-concepts/pipeline-steps/10-feedback-loop.md +105 -0
  31. package/docs/02-concepts/pipeline-steps/README.md +92 -0
  32. package/docs/02-concepts/roles-and-hitl.md +73 -0
  33. package/docs/02-concepts/traceability.md +94 -0
  34. package/docs/03-guides/architect.md +98 -0
  35. package/docs/03-guides/developer.md +76 -0
  36. package/docs/03-guides/product-owner.md +68 -0
  37. package/docs/03-guides/tester-qa.md +70 -0
  38. package/docs/04-reference/commands.md +105 -0
  39. package/docs/04-reference/configuration.md +94 -0
  40. package/docs/04-reference/model-selection.md +68 -0
  41. package/docs/04-reference/modules.md +74 -0
  42. package/docs/04-reference/trace-schema.md +93 -0
  43. package/docs/README.md +29 -40
  44. package/docs/explain/00-setup-ai-first.md +77 -0
  45. package/docs/explain/00b-generate-architecture.md +76 -0
  46. package/docs/explain/01-define-product.md +79 -0
  47. package/docs/explain/02-generate-prd.md +78 -0
  48. package/docs/explain/03-refine-prd.md +86 -0
  49. package/docs/explain/04-review-context.md +100 -0
  50. package/docs/explain/05-generate-design-spec.md +73 -0
  51. package/docs/explain/06-generate-bdd.md +77 -0
  52. package/docs/explain/07-generate-tech-docs.md +71 -0
  53. package/docs/explain/08-review-tech-docs.md +79 -0
  54. package/docs/explain/09-generate-code.md +78 -0
  55. package/docs/explain/10-review-code.md +70 -0
  56. package/docs/explain/11-map-testids.md +69 -0
  57. package/docs/explain/12-dev-gen-test.md +66 -0
  58. package/docs/explain/13-dev-run-test.md +69 -0
  59. package/docs/explain/14-dev-smoke-test.md +67 -0
  60. package/docs/explain/15-qc-analyze.md +68 -0
  61. package/docs/explain/16-qc-plan.md +61 -0
  62. package/docs/explain/17-qc-design-test.md +61 -0
  63. package/docs/explain/18-qc-review.md +59 -0
  64. package/docs/explain/19-qc-run-test.md +67 -0
  65. package/docs/explain/20-qc-report.md +61 -0
  66. package/docs/explain/21-validate-traces.md +68 -0
  67. package/docs/explain/22-generate-spec-manifest.md +60 -0
  68. package/docs/explain/23-fix-bug.md +69 -0
  69. package/docs/explain/24-debug.md +61 -0
  70. package/docs/explain/25-report-bug.md +65 -0
  71. package/docs/explain/26-propose-scenario.md +63 -0
  72. package/docs/explain/27-learn.md +65 -0
  73. package/docs/explain/28-sync.md +70 -0
  74. package/docs/explain/29-update-framework.md +65 -0
  75. package/docs/explain/README.md +134 -0
  76. package/package.json +1 -1
  77. package/skills/setup-ai-first/SKILL.md +12 -4
  78. package/skills/setup-ai-first/SKILL.tmpl +12 -4
  79. package/templates/architecture.template.md +392 -111
  80. package/templates/tech-design.template.md +238 -246
  81. package/docs/01-getting-started/README.md +0 -19
  82. package/docs/01-getting-started/core-concepts.md +0 -102
  83. package/docs/02-guides/README.md +0 -26
  84. package/docs/02-guides/bdd-input-checklist.md +0 -68
  85. package/docs/02-guides/developer/README.md +0 -49
  86. package/docs/02-guides/developer/bdd-and-trace.md +0 -126
  87. package/docs/02-guides/developer/commands.md +0 -76
  88. package/docs/02-guides/developer/pr-checklist.md +0 -16
  89. package/docs/02-guides/developer/scenarios.md +0 -460
  90. package/docs/02-guides/developer/workflow.md +0 -121
  91. package/docs/02-guides/prd-input-checklist.md +0 -94
  92. package/docs/02-guides/product-owner/README.md +0 -81
  93. package/docs/02-guides/product-owner/commands.md +0 -30
  94. package/docs/02-guides/product-owner/handoff-checklist.md +0 -42
  95. package/docs/02-guides/product-owner/prd-writing-rules.md +0 -45
  96. package/docs/02-guides/product-owner/scenarios.md +0 -438
  97. package/docs/02-guides/tech-docs-input-checklist.md +0 -109
  98. package/docs/02-guides/tester/README.md +0 -75
  99. package/docs/02-guides/tester/bug-reporting.md +0 -117
  100. package/docs/02-guides/tester/qc-automation.md +0 -165
  101. package/docs/02-guides/tester/reading-specs.md +0 -79
  102. package/docs/02-guides/tester/scenarios.md +0 -186
  103. package/docs/02-guides/tester/spec-manifest.md +0 -130
  104. package/docs/02-guides/tester/test-checklist.md +0 -31
  105. package/docs/02-guides/tester/workflow.md +0 -77
  106. package/docs/03-concepts/README.md +0 -20
  107. package/docs/03-concepts/architecture.md +0 -248
  108. package/docs/03-concepts/mechanisms-explained.md +0 -124
  109. package/docs/03-concepts/pipeline.md +0 -278
  110. package/docs/03-concepts/traceability.md +0 -152
  111. package/docs/04-operations/README.md +0 -33
  112. package/docs/04-operations/bug-flow.md +0 -364
  113. package/docs/04-operations/publishing.md +0 -154
  114. package/docs/04-operations/sync-and-update.md +0 -522
  115. package/docs/05-reference/README.md +0 -34
  116. package/docs/05-reference/command-cheatsheet.md +0 -147
  117. package/docs/05-reference/commands.md +0 -234
  118. package/docs/05-reference/model-selection.md +0 -74
  119. package/docs/05-reference/modules.md +0 -110
  120. package/docs/05-reference/trace-schema.md +0 -154
  121. package/docs/06-commands/README.md +0 -75
  122. package/docs/06-commands/explain-debug.md +0 -32
  123. package/docs/06-commands/explain-define-product.md +0 -43
  124. package/docs/06-commands/explain-dev-gen-test.md +0 -28
  125. package/docs/06-commands/explain-dev-run-test.md +0 -24
  126. package/docs/06-commands/explain-dev-smoke-test.md +0 -25
  127. package/docs/06-commands/explain-fix-bug.md +0 -28
  128. package/docs/06-commands/explain-generate-bdd.md +0 -45
  129. package/docs/06-commands/explain-generate-code.md +0 -53
  130. package/docs/06-commands/explain-generate-design-spec.md +0 -54
  131. package/docs/06-commands/explain-generate-prd.md +0 -45
  132. package/docs/06-commands/explain-generate-spec-manifest.md +0 -20
  133. package/docs/06-commands/explain-generate-tech-docs.md +0 -56
  134. package/docs/06-commands/explain-learn.md +0 -21
  135. package/docs/06-commands/explain-map-testids.md +0 -28
  136. package/docs/06-commands/explain-propose-scenario.md +0 -24
  137. package/docs/06-commands/explain-qc-analyze.md +0 -22
  138. package/docs/06-commands/explain-qc-design-test.md +0 -20
  139. package/docs/06-commands/explain-qc-plan.md +0 -21
  140. package/docs/06-commands/explain-qc-report.md +0 -23
  141. package/docs/06-commands/explain-qc-review.md +0 -24
  142. package/docs/06-commands/explain-qc-run-test.md +0 -27
  143. package/docs/06-commands/explain-refine-prd.md +0 -51
  144. package/docs/06-commands/explain-report-bug.md +0 -24
  145. package/docs/06-commands/explain-review-code.md +0 -45
  146. package/docs/06-commands/explain-review-context.md +0 -68
  147. package/docs/06-commands/explain-review-tech-docs.md +0 -45
  148. package/docs/06-commands/explain-setup-ai-first.md +0 -25
  149. package/docs/06-commands/explain-sync.md +0 -24
  150. package/docs/06-commands/explain-update-framework.md +0 -22
  151. package/docs/06-commands/explain-validate-traces.md +0 -25
  152. package/docs/t-sample.md +0 -826
@@ -463,6 +463,25 @@ Lưu `input_features`, `platforms_present`, danh sách scenario theo từng UC,
463
463
 
464
464
  ---
465
465
 
466
+ ## Bước 0.5 — [ARCH] Nạp Architecture Context (nếu có)
467
+
468
+ Tech-design chắt lọc kiến trúc hệ thống thành API contract + client design, nên đây là **nơi duy nhất** trong pipeline nạp `architecture.md` (SSOT cross-cutting sinh bởi `/generate-architecture`). Không nạp toàn cục ở context-loader — chỉ lệnh này cần nó ở mức sâu.
469
+
470
+ 1. **Phân giải path:** `{paths.specs_dir}/architecture.md` (mặc định `specs/architecture.md`). Chế độ umbrella: context-loader đã trỏ `specs_dir`/`service_root` về service đang active → dùng `architecture.md` của chính service đó (kiến trúc là code-level, per-service).
471
+ 2. **Nếu file KHÔNG tồn tại** → bỏ qua âm thầm, đặt `arch = none`. Vẫn dựa vào CLAUDE.md §2 (layers/rules) + core-entities như trước. (Gợi ý mềm một lần trong report cuối: "Chưa có architecture.md — cân nhắc chạy `/generate-architecture` để tech-design bám kiến trúc hệ thống.")
472
+ 3. **Nếu tồn tại** → đọc **có chọn lọc theo tier** (mỗi mục có marker `<!-- tier: core|conditional|ops -->`):
473
+ - **Nạp** thân các mục **`core` + `conditional`** — đây là phần ảnh hưởng code/API/data: layer boundaries + dependency direction, phân loại/nguồn dữ liệu, injection rules, luồng xác thực, response API chuẩn, caching/sharding/messaging, multi-tenant/identity-resolution.
474
+ - **BỎ QUA** các mục **`ops`** (Observability, Triển khai & DevOps, Chiến lược kiểm thử, NFR) — không đổi thiết kế API/data-model, chỉ làm nhiễu context.
475
+ - Các section §2–§4 (data model, API contract, integration) PHẢI nhất quán với phần đã nạp — KHÔNG tự suy khác.
476
+ 4. **Mục đang STUB (`<!-- status: stub -->`):** nếu một UC trong batch **chạm** tới một concern mà mục tương ứng còn stub (vd UC có tenant scoping nhưng §Multi-tenant là stub) → **cảnh báo mềm** trong report: *"§{Mục} chưa tài liệu hoá trong architecture.md — chạy `/generate-architecture --section={slug}` để tech-design chính xác hơn."* Vẫn tiếp tục dựa vào CLAUDE.md.
477
+ 5. **Trust-gate — đọc frontmatter `verified_by`:**
478
+ - `verified_by: AI-draft` (hoặc trống) → nội dung do AI dựng từ config/tài liệu/code, CHƯA ai verify. Vẫn dùng làm tham chiếu nhưng **cảnh báo** trong report: *"⚠️ architecture.md còn là AI-draft chưa verify — tech-design có thể kế thừa giả định sai. Nên để Tech Lead verify (đổi `verified_by`) trước khi chốt."* Khi mâu thuẫn với CLAUDE.md/BDD thì ưu tiên CLAUDE.md/BDD.
479
+ - `verified_by: {người thật}` → coi là ràng buộc kiến trúc chính thức.
480
+
481
+ Lưu `arch` (`none` | `ai-draft` | `verified`) để dùng ở các bước sinh section và report.
482
+
483
+ ---
484
+
466
485
  ## Bước 1 — Chế độ Fresh vs Append
467
486
 
468
487
  Kiểm tra `output_path` đã tồn tại chưa.
@@ -587,308 +606,300 @@ Ghi/mở rộng `{output_path}` dùng template dưới đây, chỉ sinh **nội
587
606
 
588
607
  <!--
589
608
  ════════════════════════════════════════════════════════════════════════════
590
- TEMPLATE: Technical Design Document (per-PRD, full-stack, merged)
591
- Used by: /generate-tech-docs
609
+ TEMPLATE: Tài liệu Thiết kế Kỹ thuật (per-PRD, full-stack, gộp)
610
+ Dùng bởi: /generate-tech-docs
592
611
  ════════════════════════════════════════════════════════════════════════════
593
612
 
594
- SCOPE MODEL
595
- - ONE document per PRD (not per UC). It covers EVERY use case of the PRD in a
596
- single merged, full-stack design: backend (API, data model, DB) AND client
597
- (components, state, API-integration) side by side, joined by cross-tier
598
- sequence diagrams. This is the "construction blueprint" any developer opens
599
- to implement the whole feature.
600
- - INPUT is the BDD feature files of the PRD (web/ · app/ · system/), NOT the
601
- PRD prose. The PRD is loaded only for Overview/Goals/Actors context.
602
-
603
- INCREMENTAL / APPEND
604
- - When new BDD is added to the same PRD later, this document is EXTENDED, not
605
- regenerated: add the new UC's sections + sequence diagrams, update the
606
- UC Coverage matrix (§10) and the Changelog. Never clobber existing content
607
- or hand edits.
608
-
609
- FILLING RULES
610
- - Replace every {…} placeholder with real content. Delete guidance comments.
611
- - TERMINOLOGY: obey the project dictionary 100%
612
- (specs/domain-knowledge/business-dictionary.md). Status/enum values
613
- core-entities.md (Enum Registry). Entities core-entities.md.
614
- - Keep code/DTO/DB samples in the project's stack idiom (see the active module
615
- stack-profile). The C#/Angular snippets below are ILLUSTRATIVE swap for
616
- the real stack.
617
- - A section that does not apply to this PRD: keep the heading and write
618
- "N/A — {reason}" rather than deleting it, so the shape stays predictable.
619
- - Every sequence diagram / API / rule should be traceable back to a scenario:
620
- reference the SC id (e.g. UC1-SC3) it serves.
613
+ HÌNH PHẠM VI
614
+ - MỘT tài liệu cho mỗi PRD (không phải per-UC). bao phủ MỌI use case của PRD
615
+ trong một thiết kế full-stack gộp: backend (API, hình dữ liệu, DB) client
616
+ (component, state, tích hợp API) đặt cạnh nhau, nối bằng sequence diagram xuyên
617
+ tầng. Đây "bản vẽ thi công" bất kỳ dev nào mở ra để implement cả feature.
618
+ - ĐẦU VÀO các file BDD của PRD (web/ · app/ · system/), KHÔNG phải văn xuôi PRD.
619
+ PRD chỉ nạp để lấy bối cảnh Overview/Goals/Actors.
620
+
621
+ TĂNG DẦN / APPEND
622
+ - Khi BDD mới được thêm vào cùng PRD về sau, tài liệu này được MỞ RỘNG, không sinh
623
+ lại: thêm section + sequence diagram của UC mới, cập nhật ma trận Độ phủ UC (§10)
624
+ Changelog. KHÔNG bao giờ đè nội dung sẵn hay chỉnh tay.
625
+
626
+ QUY TẮC ĐIỀN
627
+ - Thay MỌI placeholder {…} bằng nội dung thật. Xoá các comment hướng dẫn.
628
+ - THUẬT NGỮ: tuân 100% từ điển dự án (specs/domain-knowledge/business-dictionary.md).
629
+ Giá trị status/enum core-entities.md (Enum Registry). Entity core-entities.md.
630
+ - Giữ code/DTO/DB mẫu theo idiom stack của dự án (xem stack-profile của module đang
631
+ dùng). Snippet C#/Angular bên dưới chỉ MANG TÍNH MINH HOẠ — thay bằng stack thật.
632
+ - Section không áp dụng cho PRD này: GIỮ heading và viết "N/A — {lý do}" thay vì
633
+ xoá, để cấu trúc luôn nhất quán, dễ đoán.
634
+ - Mọi sequence diagram / API / rule phải truy vết được về một scenario: tham chiếu
635
+ id SC (vd UC1-SC3) mà nó phục vụ.
621
636
  -->
622
637
 
623
- # {Feature Area} — {PRD Title} Technical Design Document
638
+ # {Feature Area} — Tài liệu Thiết kế Kỹ thuật: {PRD Title}
624
639
 
625
- <!-- @trace block (PRD-level). ucs = every UC covered by this doc; append ids as UCs are added. -->
640
+ <!-- Khối @trace (cấp PRD). ucs = mọi UC doc này phủ; nối thêm id khi thêm UC. GIỮ NGUYÊN key @trace.* — máy đọc. -->
626
641
  ---
627
642
  @trace.id: {TICKET-ID}
628
643
  @trace.domain: {domain}
629
644
  @trace.prd: {TICKET-ID}
630
645
  @trace.ucs: {TICKET-ID}-UC1, {TICKET-ID}-UC2{, …}
631
- @trace.service: {service — from BDD header @trace.service}
632
- @trace.module: {module(s) involvede.g. dotnet, angular}
633
- @trace.platforms: {system | web | app — whichever BDD folders exist}
634
- @trace.bdd_version: {per-platform map e.g. system=1.5, web=1.9, app=1.7; only platforms present. Each feature carries its own bdd_version; do not flatten to one number.}
646
+ @trace.service: {service — từ header BDD @trace.service}
647
+ @trace.module: {module liên quan vd dotnet, angular}
648
+ @trace.platforms: {system | web | app — tuỳ thư mục BDD nào tồn tại}
649
+ @trace.bdd_version: {map theo từng platform — vd system=1.5, web=1.9, app=1.7; chỉ platform có mặt. Mỗi feature mang bdd_version riêng; đừng gộp về một số.}
635
650
  @trace.api_source: {existing | —}
636
651
  @trace.revision: 1
637
652
  @trace.status: draft
638
653
  @trace.generated_at: {YYYY-MM-DD}
639
654
  ---
640
655
 
641
- > **Related docs:** {link sibling PRDs / tech-designs this depends on, e.g. [OTHER-TICKET](../{other-slug}/tech-docs/{OTHER-TICKET}-tech-design.md)}. Delete if none.
656
+ > **Tài liệu liên quan:** {link các PRD / tech-design anh em mà doc này phụ thuộc, vd [OTHER-TICKET](../{other-slug}/tech-docs/{OTHER-TICKET}-tech-design.md)}. Xoá nếu không có.
642
657
 
643
- ## 1. Overview
658
+ ## 1. Tổng quan (Overview)
644
659
 
645
- <!-- 2–4 sentences: what this feature does, who uses it, the key technical shape
646
- (data sources, primary side effects). Name where data comes from (DB vs
647
- external API) and the main write. Source: PRD + system BDD. -->
660
+ <!-- 2–4 câu: feature làm gì, ai dùng, hình dạng kỹ thuật cốt lõi (nguồn dữ liệu,
661
+ side effect chính). Nêu dữ liệu đến từ đâu (DB vs API ngoài) và thao tác ghi
662
+ chính. Nguồn: PRD + system BDD. -->
648
663
 
649
- {What the feature does, its main actor, and the core technical mechanism. State
650
- which data is owned (DB) vs sourced live (external API), and the primary write.}
664
+ {Feature làm gì, tác nhân chính, chế kỹ thuật cốt lõi. Nêu rõ dữ liệu nào được
665
+ sở hữu (DB) vs lấy live (API ngoài), thao tác ghi chính.}
651
666
 
652
- ### Goals
667
+ ### Mục tiêu (Goals)
653
668
 
654
- <!-- Bullet the technical goalsderived from PRD goals, phrased as what the
655
- system must guarantee. -->
669
+ <!-- Liệt mục tiêu kỹ thuật suy từ mục tiêu PRD, diễn đạt thành thứ hệ thống
670
+ phải đảm bảo. -->
656
671
 
657
- - {Goal 1}
658
- - {Goal 2}
672
+ - {Mục tiêu 1}
673
+ - {Mục tiêu 2}
659
674
 
660
- ### Business Actors
675
+ ### Tác nhân nghiệp vụ (Business Actors)
661
676
 
662
- | Actor | Description | Channel |
677
+ | Tác nhân | tả | Kênh |
663
678
  |-------|-------------|---------|
664
- | {Actor} | {role & permission} | {entry path, e.g. App → Widget → Portal → API} |
679
+ | {Actor} | {vai trò & quyền} | {đường vào, vd App → Widget → Portal → API} |
665
680
 
666
681
  ---
667
682
 
668
- ## 2. Architecture Overview
683
+ ## 2. Tổng quan Kiến trúc (Architecture Overview)
669
684
 
670
- ### 2.1 High-level Architecture
685
+ ### 2.1 Kiến trúc tổng thể (High-level Architecture)
671
686
 
672
- <!-- ASCII (or mermaid) topology showing the systems this feature touches:
673
- client → gateway → service(s) → data stores / external APIs. Keep it to the
674
- components THIS PRD actually exercises. Source: architecture.md /
675
- project-context.yaml (services, stack). -->
687
+ <!-- ASCII (hoặc mermaid) topology thể hiện các hệ thống feature này chạm tới:
688
+ client → gateway → service(s) → data store / API ngoài. Chỉ giữ các component
689
+ PRD NÀY thực sự dùng. Nguồn: architecture.md / project-context.yaml (services, stack). -->
676
690
 
677
691
  ```
678
- {ASCII or mermaid diagram of the components this feature touches}
692
+ {Sơ đồ ASCII hoặc mermaid các component feature này chạm tới}
679
693
  ```
680
694
 
681
- > **Note:** {call out which data is fetched live from an external API vs stored in the owned DB, and any cache layer + TTL.}
695
+ > **Lưu ý:** {chỉ ra dữ liệu nào lấy live từ API ngoài vs lưu trong DB sở hữu, lớp cache + TTL nếu có.}
682
696
 
683
- ### 2.2 Communication Patterns
697
+ ### 2.2 Mẫu giao tiếp (Communication Patterns)
684
698
 
685
- | Pattern | Usage | Scope (UC/SC) |
699
+ | Mẫu | Dùng cho | Phạm vi (UC/SC) |
686
700
  |---------|-------|---------------|
687
701
  | {Client → Gateway → API} | {auth / action} | {UC1} |
688
- | {API → External API} | {what it fetches, cache TTL} | {UC1-SC…} |
702
+ | {API → API ngoài} | {lấy gì, cache TTL} | {UC1-SC…} |
689
703
 
690
704
  ---
691
705
 
692
- ## 3. Data Model
706
+ ## 3. Mô hình Dữ liệu (Data Model)
693
707
 
694
- <!-- Source: core-entities.md (owned entities) + BDD Then-clauses (state) + PRD.
695
- Distinguish OWNED entities (in the DB) from API-SOURCED models (fetched
696
- live, not persisted). List only fields this PRD reads or writes. -->
708
+ <!-- Nguồn: core-entities.md (entity sở hữu) + mệnh đề Then của BDD (state) + PRD.
709
+ Phân biệt entity SỞ HỮU (trong DB) với model NGUỒN-API (lấy live, không lưu).
710
+ Chỉ liệt field PRD này đọc hoặc ghi. -->
697
711
 
698
- ### 3.1 Entity Design
712
+ ### 3.1 Thiết kế Entity (Entity Design)
699
713
 
700
- #### {EntityName} ({DB entity | API-sourced POCO})
714
+ #### {EntityName} ({DB entity | POCO nguồn-API})
701
715
 
702
- {One line: what it represents, and whether it is persisted or fetched live.}
716
+ {Một dòng: biểu diễn gì, được lưu hay lấy live.}
703
717
 
704
- | Field | Type | Usage in {TICKET-ID} |
718
+ | Field | Kiểu | Dùng trong {TICKET-ID} |
705
719
  |-------|------|----------------------|
706
- | `{field}` | `{type}` | {how this feature uses itread/write, which SC} |
720
+ | `{field}` | `{type}` | {feature này dùng thế nàođọc/ghi, SC nào} |
707
721
 
708
- <!-- Repeat per entity. If the feature has meaningful state transitions, add a
709
- small state table/diagram like below. -->
722
+ <!-- Lặp lại cho mỗi entity. Nếu feature chuyển trạng thái đáng kể, thêm bảng/sơ đồ
723
+ state nhỏ như dưới. -->
710
724
 
711
- **State transitions (if any):**
725
+ **Chuyển trạng thái (nếu ):**
712
726
 
713
727
  ```
714
- {state A}: {condition} → {outcome / UI signal}
715
- {state B}: {condition} → {outcome}
728
+ {state A}: {điều kiện} → {kết quả / tín hiệu UI}
729
+ {state B}: {điều kiện} → {kết quả}
716
730
  ```
717
731
 
718
- **Constraints:**
719
- - {invariant enforced in application/DB logic, e.g. exactly one primary per tenant}
732
+ **Ràng buộc:**
733
+ - {invariant enforce tầng application/DB, vd đúng một primary cho mỗi tenant}
720
734
 
721
- ### 3.2 Entity Relationships
735
+ ### 3.2 Quan hệ Entity (Entity Relationships)
722
736
 
723
737
  ```
724
- {relationship diagramcardinalities, join keys, which fields are read-only vs owned}
738
+ { đồ quan hệ cardinality, khoá join, field nào read-only vs sở hữu}
725
739
  ```
726
740
 
727
- ### 3.3 Data Source Boundaries
741
+ ### 3.3 Ranh giới Nguồn dữ liệu (Data Source Boundaries)
728
742
 
729
- <!-- Crisp statement of what THIS PRD reads vs writes, and what is delegated
730
- elsewhere. Prevents scope bleed. -->
743
+ <!-- Phát biểu gọn PRD NÀY đọc vs ghi gì, cái gì được uỷ thác nơi khác.
744
+ Chống lem phạm vi. -->
731
745
 
732
- **{TICKET-ID} scope: {READ … / WRITE …}.**
746
+ **Phạm vi {TICKET-ID}: {ĐỌC … / GHI …}.**
733
747
 
734
- | Responsibility | In scope? | Handled by |
748
+ | Trách nhiệm | Trong phạm vi? | Do ai xử lý |
735
749
  |----------------|-----------|-----------|
736
- | {read merged list} | ✅ Yes | {endpoint / service} |
737
- | {write X flag} | ✅ Yes | {service} |
738
- | {base data} | ❌ Read-only | {external API + cache} |
739
- | {other module concern} | ❌ No | {module/team} |
750
+ | {đọc list đã gộp} | ✅ | {endpoint / service} |
751
+ | {ghi cờ X} | ✅ | {service} |
752
+ | {dữ liệu gốc} | ❌ Read-only | {API ngoài + cache} |
753
+ | {mối lo module khác} | ❌ Không | {module/team} |
740
754
 
741
755
  ### 3.4 Multi-tenant & Sharding
742
756
 
743
- <!-- Only if the project is multi-tenant. Else write "N/A — single tenant". -->
757
+ <!-- Chỉ khi dự án multi-tenant. Nếu không, viết "N/A — single tenant". -->
744
758
 
745
- - {tenant key on entities, query-filter isolation, shard resolution from architecture.md}
759
+ - {khoá tenant trên entity, cách ly bằng query-filter, phân giải shard — từ architecture.md}
746
760
 
747
761
  ---
748
762
 
749
- ## 4. API Contracts
763
+ ## 4. Hợp đồng API (API Contracts)
750
764
 
751
- <!-- Backend contract. For greenfield: design endpoints from BDD scenarios. For
752
- brownfield (@trace.api_source = existing): reverse-document the live API
753
- as-is and note gaps vs BDD expectations. Mark REUSE vs NEW explicitly.
754
- CLIENT-ONLY PRD (no system/ BDD this feature owns no backend): do NOT
755
- fabricate a BE contract. §4.1 then lists the endpoints the client CONSUMES
756
- (external / third-party / another team's / existing), marked "consumed
757
- (external)", reverse-documented from the client BDD Then-clauses + PRD;
758
- fill §4.2/§4.3 only if the shape is known. If the feature makes no network
759
- calls at all write "N/A client-only, no backend". §4.5.4 maps client
760
- methods to whatever §4.1 lists (or none). -->
765
+ <!-- Contract backend. Greenfield: thiết kế endpoint từ scenario BDD. Brownfield
766
+ (@trace.api_source = existing): reverse-document API đang chạy as-is và ghi chú
767
+ gap so với kỳ vọng BDD. Đánh dấu REUSE vs NEW rõ ràng.
768
+ PRD CHỈ-CLIENT (không có BDD system/ — feature này không sở hữu backend): ĐỪNG
769
+ bịa contract BE. §4.1 khi đó liệt các endpoint mà client TIÊU THỤ (ngoài /
770
+ bên thứ ba / của team khác / có sẵn), đánh dấu "consumed (external)",
771
+ reverse-document từ mệnh đề Then của BDD client + PRD; chỉ điền §4.2/§4.3 nếu
772
+ biết shape. Nếu feature không gọi mạng cả viết "N/A — client-only, no backend".
773
+ §4.5.4 ánh xạ method client tới bất cứ §4.1 liệt kê (hoặc không có). -->
761
774
 
762
775
 
763
776
  ### 4.1 Endpoints
764
777
 
765
778
  ```
766
- {METHOD} {/path} # NEW | REUSE ({source}) — {one-line purpose}
779
+ {METHOD} {/path} # NEW | REUSE ({nguồn}) — {mục đích một dòng}
767
780
  ```
768
781
 
769
- ### 4.2 Request/Response Models
782
+ ### 4.2 Model Request/Response (Request/Response Models)
770
783
 
771
- <!-- Show DTO shapes in the stack's idiom. Note which fields come from DB vs
772
- external API. -->
784
+ <!-- Thể hiện shape DTO theo idiom của stack. Ghi field nào đến từ DB vs API ngoài. -->
773
785
 
774
786
  ```{lang}
775
- {DTO definitions with per-field source comments}
787
+ {định nghĩa DTO kèm comment nguồn từng field}
776
788
  ```
777
789
 
778
- ### 4.3 Validation & Error Codes
790
+ ### 4.3 Validation & Mã lỗi (Validation & Error Codes)
779
791
 
780
- **Validation rules:**
792
+ **Quy tắc validation:**
781
793
 
782
794
  ```{lang}
783
- {validation rules, in the stack's idiom (e.g. FluentValidation / class-validator)}
795
+ {quy tắc validation, theo idiom stack (vd FluentValidation / class-validator)}
784
796
  ```
785
797
 
786
- | Code | HTTP Status | Description | Trace |
798
+ | Code | HTTP Status | tả | Trace |
787
799
  |------|-------------|-------------|-------|
788
- | `{ERROR_CODE}` | {4xx/5xx} | {when it fires} | {UC1-SC…} |
800
+ | `{ERROR_CODE}` | {4xx/5xx} | {khi nào phát sinh} | {UC1-SC…} |
789
801
 
790
- ### 4.4 Handler Logic (key endpoints)
802
+ ### 4.4 Logic Handler (endpoint chính)
791
803
 
792
- <!-- For non-trivial writes, spell out the ordered steps (validation →
793
- transaction → commit/rollback → return). Keeps the sequence diagram and
794
- the code aligned. -->
804
+ <!-- Với các thao tác ghi không tầm thường, viết các bước thứ tự (validation →
805
+ transaction → commit/rollback → return). Giữ sequence diagram và code khớp nhau. -->
795
806
 
796
807
  **{HandlerName}:**
797
- 1. {step}
798
- 2. {step — transaction boundary if any}
808
+ 1. {bước}
809
+ 2. {bướcranh giới transaction nếu }
799
810
 
800
- ### 4.5 UI Component Mapping — {platform} ({framework})
811
+ ### 4.5 Ánh xạ Component UI (UI Component Mapping) — {platform} ({framework})
801
812
 
802
- <!-- CLIENT design, GROUPED BY PLATFORM: one "### 4.5 … — {platform}" section per
803
- client platform present in the BDD (a web group, an app group). Do NOT title
804
- this heading by screenscreens/UCs live in the sub-blocks below.
805
- Inside a platform group:
806
- • §4.5.1 Component Hierarchy repeat the sub-block per screen/UC:
807
- "#### 4.5.1.x {Screen} — {UC}". A PRD with many screens/UCsmany sub-blocks
808
- in the SAME platform group (never a second 4.5 group for the same platform).
809
- • §4.5.2–§4.5.5 — likewise per screen/UC where they differ.
810
- • §4.5.6 Test Selectors — ONE shared table for the whole platform group; its
811
- "Serves SC" column carries (UC · SC) so per-UC consumers filter their rows.
812
- Append: new platform → new "### 4.5 — {platform}" group; new screen/UC in an
813
- existing platform → add a sub-block + rows to §4.5.6 (don't duplicate the group).
814
- Omit §4.5 entirely for a backend-only PRD. -->
813
+ <!-- Thiết kế CLIENT, NHÓM THEO PLATFORM: một section "### 4.5 … — {platform}" cho mỗi
814
+ platform client trong BDD (một nhóm web, một nhóm app). ĐỪNG đặt tên heading
815
+ này theo màn hìnhmàn hình/UC nằm các sub-block bên dưới.
816
+ Bên trong một nhóm platform:
817
+ • §4.5.1 Cây Component — lặp sub-block theo màn hình/UC:
818
+ "#### 4.5.1.x {Screen} — {UC}". Một PRD nhiều màn hình/UCnhiều sub-block
819
+ trong CÙNG nhóm platform (không bao giờ tạo nhóm 4.5 thứ hai cho cùng platform).
820
+ • §4.5.2–§4.5.5 — tương tự theo màn hình/UC chỗ chúng khác nhau.
821
+ • §4.5.6 Test Selectors — MỘT bảng dùng chung cho cả nhóm platform; cột
822
+ "Phục vụ SC" mang (UC · SC) để consumer per-UC lọc row của mình.
823
+ Append: platform mới nhóm "### 4.5 — {platform}" mới; màn hình/UC mới trong
824
+ platform đã có thêm sub-block + row vào §4.5.6 (đừng lặp nhóm).
825
+ Bỏ hẳn §4.5 với PRD backend-only. -->
815
826
 
816
- > **Source:** {Figma file + node id, from design-spec}
817
- > **Stack:** {framework, state primitive, component library}
818
- > <!-- @figma.url: {node-level figma url} -->
827
+ > **Nguồn:** {file Figma + node id, từ design-spec}
828
+ > **Stack:** {framework, state primitive, thư viện component}
829
+ > <!-- @figma.url: {url figma cấp node} -->
819
830
 
820
- #### 4.5.1 Component Hierarchy — {Screen} ({UC})
831
+ #### 4.5.1 Cây Component (Component Hierarchy) — {Screen} ({UC})
821
832
 
822
- <!-- Repeat this sub-block per screen/UC in this platform group (4.5.1.a, 4.5.1.b …). -->
833
+ <!-- Lặp sub-block này theo màn hình/UC trong nhóm platform này (4.5.1.a, 4.5.1.b …). -->
823
834
 
824
835
  ```
825
- {component tree — container vs presentational, conditional children}
836
+ {cây component — container vs presentational, con có điều kiện}
826
837
  ```
827
838
 
828
- #### 4.5.2 Component File Mapping
839
+ #### 4.5.2 Ánh xạ file Component (Component File Mapping)
829
840
 
830
- | Component | Path | Type | Purpose |
841
+ | Component | Path | Loại | Trách nhiệm |
831
842
  |-----------|------|------|---------|
832
- | `{Component}` | `{path}` | {Feature/Child} | {responsibility} |
843
+ | `{Component}` | `{path}` | {Feature/Child} | {trách nhiệm} |
833
844
 
834
- #### 4.5.3 State Management ({state primitive})
845
+ #### 4.5.3 Quản lý State (State Management) ({state primitive})
835
846
 
836
- <!-- State shape derived from System BDD Then-clauses + response shapes from §4.2.
837
- Show derived/computed values and their inputs. -->
847
+ <!-- Shape state suy từ mệnh đề Then của System BDD + shape response từ §4.2.
848
+ Thể hiện giá trị dẫn xuất/tính toán input của chúng. -->
838
849
 
839
850
  ```{lang}
840
- {state declarations with source comments (which BDD field / BE field each maps to)}
851
+ {khai báo state kèm comment nguồn (mỗi cái map tới field BDD / field BE nào)}
841
852
  ```
842
853
 
843
- #### 4.5.4 API Integration Layer (port/adapter)
854
+ #### 4.5.4 Tầng tích hợp API (API Integration Layer port/adapter)
844
855
 
845
- <!-- Modal/route config + API-integration map: each client service methoda
846
- REAL endpoint from §4.1 (do not invent endpoints). Error → UI state per SC.
847
- This table is what /generate-code --phase=integration reads to wire the real adapter. -->
856
+ <!-- Cấu hình modal/route + bản đồ tích hợp API: mỗi method service clientmột
857
+ endpoint THẬT từ §4.1 (đừng bịa endpoint). Lỗistate UI theo từng SC.
858
+ Bảng này thứ /generate-code --phase=integration đọc để wire adapter thật. -->
848
859
 
849
- | Client method | Endpoint (§4.1) | Request map | Response → model | Error → UI |
860
+ | Method client | Endpoint (§4.1) | Map request | Response → model | Lỗi → UI |
850
861
  |---------------|-----------------|-------------|------------------|-----------|
851
862
  | {svc.getX()} | {GET /…} | {params} | {DTO → ViewModel} | {4xx → state/toast} |
852
863
 
853
- #### 4.5.5 Figma → Design System Mapping
864
+ #### 4.5.5 Ánh xạ Figma → Design System
854
865
 
855
- | Figma element | Design system class/token | Notes |
866
+ | Element Figma | Class/token design system | Ghi chú |
856
867
  |---------------|---------------------------|-------|
857
- | {element} | {class / token} | {size, color, state} |
868
+ | {element} | {class / token} | {size, màu, state} |
858
869
 
859
- #### 4.5.6 Test Selectors — element IDs for actionable elements (QC contract)
870
+ #### 4.5.6 Test Selectors — id element cho phần tử action (hợp đồng QC)
860
871
 
861
- <!-- Stable test-id per interactive element so QC locates directly (no runtime
862
- scan). Convention: {uc-lower}-{screen}-{element}-{type}; DO NOT embed
863
- scenario numbers. Attribute per platform: web data-testid · RN testID ·
864
- Flutter Key/Semantics · iOS accessibilityIdentifier. Reuse the same id
865
- VALUE across web/app for the same logical element.
866
- ONE shared table for the whole platform group (covers every screen/UC of this
867
- platform). The "Serves SC" column carries (UC · SC) so a per-UC consumer
868
- (generate-code / qc) filters to its own rows via §10. This §4.5 group is
869
- already platform-scoped, so the platform is implicit (web block → web · SC). -->
872
+ <!-- Test-id ổn định cho mỗi element tương tác để QC định vị trực tiếp (không scan
873
+ runtime). Quy ước: {uc-lower}-{screen}-{element}-{type}; ĐỪNG nhúng số scenario.
874
+ Attribute theo platform: web data-testid · RN testID · Flutter Key/Semantics ·
875
+ iOS accessibilityIdentifier. Dùng lại CÙNG giá trị id trên web/app cho cùng một
876
+ element logic.
877
+ MỘT bảng dùng chung cho cả nhóm platform (phủ mọi màn hình/UC của platform này).
878
+ Cột "Phục vụ SC" mang (UC · SC) để consumer per-UC (generate-code / qc) lọc row
879
+ của mình qua §10. Nhóm §4.5 này vốn đã theo platform, nên platform là ngầm định
880
+ (khối web → web · SC). -->
870
881
 
871
- | Test-ID | Element | Component (§4.5.1.x) | Action | Serves SC (UC · SC) |
882
+ | Test-ID | Element | Component (§4.5.1.x) | Action | Phục vụ SC (UC · SC) |
872
883
  |---------|---------|----------------------|--------|---------------------|
873
- | `{uc}-{screen}-{element}-{type}` | {Submit button} | {Component} | {submit} | {UC1 · SC1, UC1 · SC3} |
884
+ | `{uc}-{screen}-{element}-{type}` | {Nút submit} | {Component} | {submit} | {UC1 · SC1, UC1 · SC3} |
874
885
 
875
886
  ---
876
887
 
877
- ## 5. Key Flows (Sequence Diagrams)
888
+ ## 5. Luồng chính (Key Flows Sequence Diagrams)
878
889
 
879
- <!-- ONE mermaid sequence diagram per meaningful scenario. Participants span tiers:
880
- client component → service → API → external API → DB.
881
- ⚠ SC ids are unique only within (UC × platform): `{UC}-SC1` on `system` and
882
- `{UC}-SC1` on `web` are DIFFERENT scenarios. So group flows into PLATFORM LANES
883
- (5.A system · 5.B web · 5.C app) and ALWAYS pair the SC with its platform,
884
- e.g. "(web · UC1-SC1)". Never write a bare "UC1-SC1" hereit is ambiguous.
885
- Only include the lanes whose BDD exists in this PRD. -->
890
+ <!-- MỘT mermaid sequence diagram cho mỗi scenario đáng kể. Participant xuyên tầng:
891
+ component client → service → API → API ngoài → DB.
892
+ id SC chỉ duy nhất trong phạm vi (UC × platform): `{UC}-SC1` `system`
893
+ `{UC}-SC1` `web` HAI scenario KHÁC nhau. Nên gom luồng vào các LANE PLATFORM
894
+ (5.A system · 5.B web · 5.C app) LUÔN ghi kèm platform với SC, vd
895
+ "(web · UC1-SC1)". Đừng bao giờ viết "UC1-SC1" trơ ở đây hồ.
896
+ Chỉ đưa các lane BDD tồn tại trong PRD này. -->
886
897
 
887
- ### 5.A System flows
898
+ ### 5.A Luồng System
888
899
 
889
- <!-- One diagram per system-BDD scenario. Skip this lane if no system/ BDD. -->
900
+ <!-- Một diagram cho mỗi scenario system-BDD. Bỏ lane này nếu không BDD system/. -->
890
901
 
891
- #### 5.A.1 {name} (system · {UC}-SC…)
902
+ #### 5.A.1 {tên} (system · {UC}-SC…)
892
903
 
893
904
  ```mermaid
894
905
  sequenceDiagram
@@ -896,147 +907,147 @@ sequenceDiagram
896
907
  {…}
897
908
  ```
898
909
 
899
- ### 5.B Web flows
910
+ ### 5.B Luồng Web
900
911
 
901
- <!-- One diagram per web-BDD scenario. Skip this lane if no web/ BDD. -->
912
+ <!-- Một diagram cho mỗi scenario web-BDD. Bỏ lane này nếu không BDD web/. -->
902
913
 
903
- #### 5.B.1 {name} (web · {UC}-SC…)
914
+ #### 5.B.1 {tên} (web · {UC}-SC…)
904
915
 
905
916
  ```mermaid
906
917
  sequenceDiagram
907
918
  {…}
908
919
  ```
909
920
 
910
- ### 5.C App flows
921
+ ### 5.C Luồng App
911
922
 
912
- <!-- One diagram per app-BDD scenario. Skip this lane if no app/ BDD. -->
923
+ <!-- Một diagram cho mỗi scenario app-BDD. Bỏ lane này nếu không BDD app/. -->
913
924
 
914
- #### 5.C.1 {name} (app · {UC}-SC…)
925
+ #### 5.C.1 {tên} (app · {UC}-SC…)
915
926
 
916
927
  ```mermaid
917
928
  sequenceDiagram
918
929
  {…}
919
930
  ```
920
931
 
921
- <!-- Number within each lane: 5.A.1, 5.A.2 … / 5.B.1 … / 5.C.1 …. For a scenario
922
- whose effect crosses into another module, note "(covered by {OTHER-UC})". -->
932
+ <!-- Đánh số trong từng lane: 5.A.1, 5.A.2 … / 5.B.1 … / 5.C.1 …. Với scenario
933
+ hiệu ứng lấn sang module khác, ghi "(covered by {OTHER-UC})". -->
923
934
 
924
- **Key integration points (optional table per flow):**
935
+ **Điểm tích hợp chính (bảng tuỳ chọn cho mỗi luồng):**
925
936
 
926
- | Step | State transition | Verified by (platform · SC) |
937
+ | Bước | Chuyển trạng thái | Verify bởi (platform · SC) |
927
938
  |------|------------------|-----------------------------|
928
- | {step} | {beforeafter} | {web · UC1-SC…} |
939
+ | {bước} | {trướcsau} | {web · UC1-SC…} |
929
940
 
930
941
  ---
931
942
 
932
- ## 6. Integration Points
943
+ ## 6. Điểm tích hợp (Integration Points)
933
944
 
934
- | Integration | Direction | Method | Description |
945
+ | Tích hợp | Chiều | Phương thức | tả |
935
946
  |-------------|-----------|--------|-------------|
936
- | {Client → API} | Outbound (client) | {REST/Bearer} | {what} |
937
- | {API → External} | Outbound (server) | {REST + header} | {what, cache TTL} |
947
+ | {Client → API} | Outbound (client) | {REST/Bearer} | {} |
948
+ | {API → Ngoài} | Outbound (server) | {REST + header} | {gì, cache TTL} |
938
949
 
939
950
  ### 6.1 Event Bus / Messaging
940
951
 
941
- <!-- Kafka/queue events produced/consumed by this feature. "N/A — no events" if none. -->
952
+ <!-- Event Kafka/queue feature này produce/consume. "N/A — no events" nếu không có. -->
942
953
 
943
- {events, or N/A}
954
+ {events, hoặc N/A}
944
955
 
945
- ### 6.2 Cross-Service Dependencies
956
+ ### 6.2 Phụ thuộc Cross-Service (Cross-Service Dependencies)
946
957
 
947
- | Dependent service | What's needed | Contract | Status |
958
+ | Service phụ thuộc | Cần | Contract | Trạng thái |
948
959
  |-------------------|---------------|----------|--------|
949
- | {service} | {need} | {endpoint} | {✅ Exists / ⚠️ pending} |
960
+ | {service} | {cần} | {endpoint} | {✅ / ⚠️ pending} |
950
961
 
951
962
  ---
952
963
 
953
- ## 7. Security & Authorization
964
+ ## 7. Bảo mật & Phân quyền (Security & Authorization)
954
965
 
955
- ### 7.1 Authentication
966
+ ### 7.1 Xác thực (Authentication)
956
967
 
957
- {Auth flow + token type/TTL. Source: PRD auth + project rules.}
968
+ {Luồng auth + loại token/TTL. Nguồn: auth PRD + rule dự án.}
958
969
 
959
- ### 7.2 Authorization Rules
970
+ ### 7.2 Quy tắc Phân quyền (Authorization Rules)
960
971
 
961
- | Action | Required role/permission | Description | Trace |
972
+ | Action | Role/quyền yêu cầu | tả | Trace |
962
973
  |--------|--------------------------|-------------|-------|
963
- | {action} | {role} | {how enforced, where} | {UC1-SC… / out of scope} |
974
+ | {action} | {role} | {enforce thế nào, ở đâu} | {UC1-SC… / ngoài phạm vi} |
964
975
 
965
976
  ---
966
977
 
967
- ## 8. Error Handling & Edge Cases
978
+ ## 8. Xử lý lỗi & Trường hợp biên (Error Handling & Edge Cases)
968
979
 
969
- <!-- One row per error / edge / negative scenario in the BDD. This must line up
970
- with §4.3 error codes and the §5 error sequence diagrams. -->
980
+ <!-- Một row cho mỗi scenario lỗi / biên / âm trong BDD. Phải khớp với mã lỗi §4.3
981
+ các sequence diagram lỗi §5. -->
971
982
 
972
- | Scenario | Strategy | Details | Trace |
983
+ | Scenario | Chiến lược | Chi tiết | Trace |
973
984
  |----------|----------|---------|-------|
974
- | {condition} | {approach} | {behavior, message, side effect} | {UC1-SC…, BR…} |
985
+ | {điều kiện} | {cách xử lý} | {hành vi, message, side effect} | {UC1-SC…, BR…} |
975
986
 
976
987
  ---
977
988
 
978
- ## 9. Design Decisions
989
+ ## 9. Quyết định Thiết kế (Design Decisions)
979
990
 
980
- <!-- The "why" behind non-obvious choices, with alternatives considered. Source:
981
- PRD alternatives/assumptions + reasoning during generation. This is what lets
982
- a reviewer trust the design. -->
991
+ <!-- Cái "vì sao" đằng sau các lựa chọn không hiển nhiên, kèm phương án đã cân nhắc.
992
+ Nguồn: alternatives/assumptions của PRD + lập luận lúc sinh. Đây thứ giúp
993
+ reviewer tin tưởng thiết kế. -->
983
994
 
984
- | # | Decision | Rationale | Alternatives considered |
995
+ | # | Quyết định | do | Phương án đã cân nhắc |
985
996
  |---|----------|-----------|-------------------------|
986
- | 1 | **{decision}** | {why} | {altwhy rejected} |
997
+ | 1 | **{quyết định}** | {vì sao} | {phương án sao loại} |
987
998
 
988
- ### NFR-to-Design Mapping
999
+ ### Ánh xạ NFR → Thiết kế (NFR-to-Design Mapping)
989
1000
 
990
- | NFR category | PRD requirement | Design decision |
1001
+ | Nhóm NFR | Yêu cầu PRD | Quyết định thiết kế |
991
1002
  |--------------|-----------------|-----------------|
992
- | {e.g. Multi-tenant isolation} | {requirement} | {mechanism} |
1003
+ | {vd Cách ly multi-tenant} | {yêu cầu} | {cơ chế} |
993
1004
 
994
1005
  ---
995
1006
 
996
- ## 10. UC Coverage
1007
+ ## 10. Độ phủ UC (UC Coverage)
997
1008
 
998
- <!-- THE APPEND ANCHOR **and the INDEX for per-UC consumers**. Every UC of the PRD
999
- gets a row; every scenario maps to the section(s) that design it.
1000
- - /generate-tech-docs uses it to detect what is already covered vs missing.
1001
- - /generate-code, /map-testids, /qc-* work on ONE UC of a PRD-level doc they
1002
- look this UC up HERE first to locate its scenariosthe sections/§5-lanes
1003
- (and thus the §4.1 endpoints its §5 flows call) that belong to it. Don't
1004
- pull another UC's endpoints/sections.
1005
- Scenario coverage is keyed by (platform, SC) because SC ids repeat across
1006
- platforms the Platform column disambiguates. -->
1009
+ <!-- ĐIỂM NEO ĐỂ APPEND ** MỤC LỤC cho consumer per-UC**. Mọi UC của PRD có một
1010
+ row; mọi scenario map tới (các) section thiết kế nó.
1011
+ - /generate-tech-docs dùng để phát hiện cái đã phủ vs còn thiếu.
1012
+ - /generate-code, /map-testids, /qc-* làm việc trên MỘT UC của doc cấp-PRD — chúng
1013
+ tra UC này ĐÂY trước để định vị scenario của nó các section/lane-§5 (và do đó
1014
+ các endpoint §4.1 luồng §5 của nó gọi) thuộc về nó. Đừng lấy
1015
+ endpoint/section của UC khác.
1016
+ Độ phủ scenario khoá theo (platform, SC) id SC lặp giữa các platform —
1017
+ cột Platform để phân biệt. -->
1007
1018
 
1008
- | UC | Feature | Platforms | Sections covered | Status |
1019
+ | UC | Feature | Platforms | Section phủ | Trạng thái |
1009
1020
  |----|---------|-----------|------------------|--------|
1010
1021
  | {TICKET-ID}-UC1 | {title} | {system, web, app} | §… | ✅ Covered |
1011
1022
 
1012
- ### UC1 Scenario Coverage
1023
+ ### Độ phủ Scenario UC1
1013
1024
 
1014
- <!-- One row per (platform, SC). Same SC number on different platforms = different
1015
- scenariosseparate rows. -->
1025
+ <!-- Một row cho mỗi (platform, SC). Cùng số SC platform khác nhau = scenario khác
1026
+ nhaurow riêng. -->
1016
1027
 
1017
1028
  | Platform | Scenario | Section | Business rule |
1018
1029
  |----------|----------|---------|---------------|
1019
- | system | {UC}-SC1: {name} | §5.A.1 | {BR…} |
1020
- | web | {UC}-SC1: {name} | §4.5 (web), §5.B.1 | {BR…} |
1030
+ | system | {UC}-SC1: {tên} | §5.A.1 | {BR…} |
1031
+ | web | {UC}-SC1: {tên} | §4.5 (web), §5.B.1 | {BR…} |
1021
1032
 
1022
- <!-- Repeat a scenario-coverage block per UC. -->
1033
+ <!-- Lặp một khối scenario-coverage cho mỗi UC. -->
1023
1034
 
1024
1035
  ---
1025
1036
 
1026
- ## 11. Cross-cutting & Assumptions (Out-of-Scope Reference)
1037
+ ## 11. Cross-cutting & Giả định (Tham chiếu ngoài phạm vi)
1027
1038
 
1028
- <!-- Upstream concerns this PRD DEPENDS ON but does not implement (admin gate,
1029
- downstream UI in another module, order snapshotting…). Keep for cross-team
1030
- context. Reference the owning UC/team + doc. Source: PRD out-of-scope +
1031
- BDD BR "out of scope" notes. -->
1039
+ <!-- Các mối lo upstream mà PRD này PHỤ THUỘC VÀO nhưng không implement (cổng admin,
1040
+ UI downstream module khác, snapshot đơn hàng…). Giữ để có bối cảnh liên team.
1041
+ Tham chiếu UC/team sở hữu + doc. Nguồn: out-of-scope của PRD + ghi chú BR
1042
+ "out of scope" trong BDD. -->
1032
1043
 
1033
- ### 11.1 {Concern}
1044
+ ### 11.1 {Mối lo}
1034
1045
 
1035
- > {Quote the BDD/PRD line that scopes it out.}
1046
+ > {Trích câu BDD/PRD đã scope ra ngoài.}
1036
1047
 
1037
- {Explanation of the boundary + a reference sequence diagram if useful.}
1048
+ {Giải thích ranh giới + một sequence diagram tham chiếu nếu hữu ích.}
1038
1049
 
1039
- **Owned by:** {team / module}. See {link}.
1050
+ **Sở hữu bởi:** {team / module}. Xem {link}.
1040
1051
 
1041
1052
  ---
1042
1053
 
@@ -1069,9 +1080,9 @@ sequenceDiagram
1069
1080
 
1070
1081
  ---
1071
1082
 
1072
- ## Figma Design References
1083
+ ## Tham chiếu Thiết kế Figma (Figma Design References)
1073
1084
 
1074
- <!-- @figma.url: {node-level figma url per screen} -->
1085
+ <!-- @figma.url: {url figma cấp node cho mỗi màn hình} -->
1075
1086
  - {Screen}: [Figma — {frame}]({url})
1076
1087
  - Exported: {YYYY-MM-DD}
1077
1088
 
@@ -1079,10 +1090,10 @@ sequenceDiagram
1079
1090
 
1080
1091
  ## Changelog
1081
1092
 
1082
- | Revision | Date | Changes |
1093
+ | Revision | Ngày | Thay đổi |
1083
1094
  |----------|------|---------|
1084
- | 1 | {YYYY-MM-DD} | Initial generation from {TICKET-ID} BDD (v{bdd_version}): {list UCs covered} |
1085
- <!-- On append: add a row per extension, e.g. "2 | {date} | Added UC3 (§5.9, §10) from new BDD v{n}" -->
1095
+ | 1 | {YYYY-MM-DD} | Sinh lần đầu từ BDD {TICKET-ID} (v{bdd_version}): {liệt UC đã phủ} |
1096
+ <!-- Khi append: thêm một row cho mỗi lần mở rộng, vd "2 | {ngày} | Thêm UC3 (§5.9, §10) từ BDD mới v{n}" -->
1086
1097
 
1087
1098
 
1088
1099
  ---
@@ -1100,6 +1111,8 @@ Trước khi finalize/append doc, **tự phản biện bản nháp** qua 4 cổn
1100
1111
  **Cổng 2 — GAP-or-FLAG (trung thực, không bịa).**
1101
1112
  Cần một type/giá trị/policy (auth, config, event, error code) mà **không có nguồn** → **không** chép hình dạng ở boundary, **không** bịa: ghi `[GAP]` hoặc `[ASSUMPTION: {owner} confirm]`. Nếu doc định thiết kế endpoint/flow mà **BDD không định nghĩa nghiệp vụ** (design vượt BDD) → khai GAP + escalate, đừng âm thầm hợp thức hoá.
1102
1113
 
1114
+ **Cổng 2b — Client integration (§4.5.4) cũng phải đủ, không chỉ contract BE.** Với MỖI client method mà một màn hình/UC cần, §4.5.4 phải map đủ: **endpoint thật ở §4.1 · nguồn field request/response · error→UI**. Bất kỳ mảnh nào không suy được từ nguồn → khai `[GAP]` + một dòng §12 (đừng để §4.5.4 khuyết một phần rồi lọt xuống `/generate-code --phase=integration` — đó chính là chỗ FE bị hỏi live). **Severity blocker (🔴)** nếu màn hình không render/hoạt động được khi thiếu mapping đó (→ giữ `@trace.status: in-review`, chặn code-gen tới khi đóng); non-blocker (🟢) nếu chỉ là chi tiết phụ đoán tạm được. Đối xứng với contract BE: front-load ẩn số client về tech-docs, đừng đẩy sang lúc wire adapter.
1115
+
1103
1116
  **Cổng 3 — CATALOG (không hard-code).**
1104
1117
  Literal & constant rải rác như luật → gom lại: **generic envelope** (đừng typed-per-thing khi PRD-BR đã đưa hợp đồng chung) + bảng catalog (vd `signal_type × source`) + constants **đặt tên**. Fail nếu còn hằng số/enum inline chưa vào catalog.
1105
1118