@educa-corp/sdd-framework 0.2.5 → 0.2.7

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