@educa-corp/sdd-framework 0.2.5 → 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.
@@ -606,308 +606,300 @@ Ghi/mở rộng `{output_path}` dùng template dưới đây, chỉ sinh **nội
606
606
 
607
607
  <!--
608
608
  ════════════════════════════════════════════════════════════════════════════
609
- TEMPLATE: Technical Design Document (per-PRD, full-stack, merged)
610
- 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
611
611
  ════════════════════════════════════════════════════════════════════════════
612
612
 
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.
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ụ.
640
636
  -->
641
637
 
642
- # {Feature Area} — {PRD Title} Technical Design Document
638
+ # {Feature Area} — Tài liệu Thiết kế Kỹ thuật: {PRD Title}
643
639
 
644
- <!-- @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. -->
645
641
  ---
646
642
  @trace.id: {TICKET-ID}
647
643
  @trace.domain: {domain}
648
644
  @trace.prd: {TICKET-ID}
649
645
  @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.}
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ố.}
654
650
  @trace.api_source: {existing | —}
655
651
  @trace.revision: 1
656
652
  @trace.status: draft
657
653
  @trace.generated_at: {YYYY-MM-DD}
658
654
  ---
659
655
 
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.
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ó.
661
657
 
662
- ## 1. Overview
658
+ ## 1. Tổng quan (Overview)
663
659
 
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. -->
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. -->
667
663
 
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.}
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.}
670
666
 
671
- ### Goals
667
+ ### Mục tiêu (Goals)
672
668
 
673
- <!-- Bullet the technical goalsderived from PRD goals, phrased as what the
674
- 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. -->
675
671
 
676
- - {Goal 1}
677
- - {Goal 2}
672
+ - {Mục tiêu 1}
673
+ - {Mục tiêu 2}
678
674
 
679
- ### Business Actors
675
+ ### Tác nhân nghiệp vụ (Business Actors)
680
676
 
681
- | Actor | Description | Channel |
677
+ | Tác nhân | tả | Kênh |
682
678
  |-------|-------------|---------|
683
- | {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} |
684
680
 
685
681
  ---
686
682
 
687
- ## 2. Architecture Overview
683
+ ## 2. Tổng quan Kiến trúc (Architecture Overview)
688
684
 
689
- ### 2.1 High-level Architecture
685
+ ### 2.1 Kiến trúc tổng thể (High-level Architecture)
690
686
 
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). -->
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). -->
695
690
 
696
691
  ```
697
- {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}
698
693
  ```
699
694
 
700
- > **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ó.}
701
696
 
702
- ### 2.2 Communication Patterns
697
+ ### 2.2 Mẫu giao tiếp (Communication Patterns)
703
698
 
704
- | Pattern | Usage | Scope (UC/SC) |
699
+ | Mẫu | Dùng cho | Phạm vi (UC/SC) |
705
700
  |---------|-------|---------------|
706
701
  | {Client → Gateway → API} | {auth / action} | {UC1} |
707
- | {API → External API} | {what it fetches, cache TTL} | {UC1-SC…} |
702
+ | {API → API ngoài} | {lấy gì, cache TTL} | {UC1-SC…} |
708
703
 
709
704
  ---
710
705
 
711
- ## 3. Data Model
706
+ ## 3. Mô hình Dữ liệu (Data Model)
712
707
 
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. -->
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. -->
716
711
 
717
- ### 3.1 Entity Design
712
+ ### 3.1 Thiết kế Entity (Entity Design)
718
713
 
719
- #### {EntityName} ({DB entity | API-sourced POCO})
714
+ #### {EntityName} ({DB entity | POCO nguồn-API})
720
715
 
721
- {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.}
722
717
 
723
- | Field | Type | Usage in {TICKET-ID} |
718
+ | Field | Kiểu | Dùng trong {TICKET-ID} |
724
719
  |-------|------|----------------------|
725
- | `{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} |
726
721
 
727
- <!-- Repeat per entity. If the feature has meaningful state transitions, add a
728
- 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. -->
729
724
 
730
- **State transitions (if any):**
725
+ **Chuyển trạng thái (nếu ):**
731
726
 
732
727
  ```
733
- {state A}: {condition} → {outcome / UI signal}
734
- {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ả}
735
730
  ```
736
731
 
737
- **Constraints:**
738
- - {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}
739
734
 
740
- ### 3.2 Entity Relationships
735
+ ### 3.2 Quan hệ Entity (Entity Relationships)
741
736
 
742
737
  ```
743
- {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}
744
739
  ```
745
740
 
746
- ### 3.3 Data Source Boundaries
741
+ ### 3.3 Ranh giới Nguồn dữ liệu (Data Source Boundaries)
747
742
 
748
- <!-- Crisp statement of what THIS PRD reads vs writes, and what is delegated
749
- 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. -->
750
745
 
751
- **{TICKET-ID} scope: {READ … / WRITE …}.**
746
+ **Phạm vi {TICKET-ID}: {ĐỌC … / GHI …}.**
752
747
 
753
- | Responsibility | In scope? | Handled by |
748
+ | Trách nhiệm | Trong phạm vi? | Do ai xử lý |
754
749
  |----------------|-----------|-----------|
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} |
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} |
759
754
 
760
755
  ### 3.4 Multi-tenant & Sharding
761
756
 
762
- <!-- 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". -->
763
758
 
764
- - {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}
765
760
 
766
761
  ---
767
762
 
768
- ## 4. API Contracts
763
+ ## 4. Hợp đồng API (API Contracts)
769
764
 
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). -->
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ó). -->
780
774
 
781
775
 
782
776
  ### 4.1 Endpoints
783
777
 
784
778
  ```
785
- {METHOD} {/path} # NEW | REUSE ({source}) — {one-line purpose}
779
+ {METHOD} {/path} # NEW | REUSE ({nguồn}) — {mục đích một dòng}
786
780
  ```
787
781
 
788
- ### 4.2 Request/Response Models
782
+ ### 4.2 Model Request/Response (Request/Response Models)
789
783
 
790
- <!-- Show DTO shapes in the stack's idiom. Note which fields come from DB vs
791
- external API. -->
784
+ <!-- Thể hiện shape DTO theo idiom của stack. Ghi field nào đến từ DB vs API ngoài. -->
792
785
 
793
786
  ```{lang}
794
- {DTO definitions with per-field source comments}
787
+ {định nghĩa DTO kèm comment nguồn từng field}
795
788
  ```
796
789
 
797
- ### 4.3 Validation & Error Codes
790
+ ### 4.3 Validation & Mã lỗi (Validation & Error Codes)
798
791
 
799
- **Validation rules:**
792
+ **Quy tắc validation:**
800
793
 
801
794
  ```{lang}
802
- {validation rules, in the stack's idiom (e.g. FluentValidation / class-validator)}
795
+ {quy tắc validation, theo idiom stack (vd FluentValidation / class-validator)}
803
796
  ```
804
797
 
805
- | Code | HTTP Status | Description | Trace |
798
+ | Code | HTTP Status | tả | Trace |
806
799
  |------|-------------|-------------|-------|
807
- | `{ERROR_CODE}` | {4xx/5xx} | {when it fires} | {UC1-SC…} |
800
+ | `{ERROR_CODE}` | {4xx/5xx} | {khi nào phát sinh} | {UC1-SC…} |
808
801
 
809
- ### 4.4 Handler Logic (key endpoints)
802
+ ### 4.4 Logic Handler (endpoint chính)
810
803
 
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. -->
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. -->
814
806
 
815
807
  **{HandlerName}:**
816
- 1. {step}
817
- 2. {step — transaction boundary if any}
808
+ 1. {bước}
809
+ 2. {bướcranh giới transaction nếu }
818
810
 
819
- ### 4.5 UI Component Mapping — {platform} ({framework})
811
+ ### 4.5 Ánh xạ Component UI (UI Component Mapping) — {platform} ({framework})
820
812
 
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. -->
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. -->
834
826
 
835
- > **Source:** {Figma file + node id, from design-spec}
836
- > **Stack:** {framework, state primitive, component library}
837
- > <!-- @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} -->
838
830
 
839
- #### 4.5.1 Component Hierarchy — {Screen} ({UC})
831
+ #### 4.5.1 Cây Component (Component Hierarchy) — {Screen} ({UC})
840
832
 
841
- <!-- 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 …). -->
842
834
 
843
835
  ```
844
- {component tree — container vs presentational, conditional children}
836
+ {cây component — container vs presentational, con có điều kiện}
845
837
  ```
846
838
 
847
- #### 4.5.2 Component File Mapping
839
+ #### 4.5.2 Ánh xạ file Component (Component File Mapping)
848
840
 
849
- | Component | Path | Type | Purpose |
841
+ | Component | Path | Loại | Trách nhiệm |
850
842
  |-----------|------|------|---------|
851
- | `{Component}` | `{path}` | {Feature/Child} | {responsibility} |
843
+ | `{Component}` | `{path}` | {Feature/Child} | {trách nhiệm} |
852
844
 
853
- #### 4.5.3 State Management ({state primitive})
845
+ #### 4.5.3 Quản lý State (State Management) ({state primitive})
854
846
 
855
- <!-- State shape derived from System BDD Then-clauses + response shapes from §4.2.
856
- 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. -->
857
849
 
858
850
  ```{lang}
859
- {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)}
860
852
  ```
861
853
 
862
- #### 4.5.4 API Integration Layer (port/adapter)
854
+ #### 4.5.4 Tầng tích hợp API (API Integration Layer port/adapter)
863
855
 
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. -->
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. -->
867
859
 
868
- | Client method | Endpoint (§4.1) | Request map | Response → model | Error → UI |
860
+ | Method client | Endpoint (§4.1) | Map request | Response → model | Lỗi → UI |
869
861
  |---------------|-----------------|-------------|------------------|-----------|
870
862
  | {svc.getX()} | {GET /…} | {params} | {DTO → ViewModel} | {4xx → state/toast} |
871
863
 
872
- #### 4.5.5 Figma → Design System Mapping
864
+ #### 4.5.5 Ánh xạ Figma → Design System
873
865
 
874
- | Figma element | Design system class/token | Notes |
866
+ | Element Figma | Class/token design system | Ghi chú |
875
867
  |---------------|---------------------------|-------|
876
- | {element} | {class / token} | {size, color, state} |
868
+ | {element} | {class / token} | {size, màu, state} |
877
869
 
878
- #### 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)
879
871
 
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). -->
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). -->
889
881
 
890
- | 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) |
891
883
  |---------|---------|----------------------|--------|---------------------|
892
- | `{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} |
893
885
 
894
886
  ---
895
887
 
896
- ## 5. Key Flows (Sequence Diagrams)
888
+ ## 5. Luồng chính (Key Flows Sequence Diagrams)
897
889
 
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. -->
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. -->
905
897
 
906
- ### 5.A System flows
898
+ ### 5.A Luồng System
907
899
 
908
- <!-- 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/. -->
909
901
 
910
- #### 5.A.1 {name} (system · {UC}-SC…)
902
+ #### 5.A.1 {tên} (system · {UC}-SC…)
911
903
 
912
904
  ```mermaid
913
905
  sequenceDiagram
@@ -915,147 +907,147 @@ sequenceDiagram
915
907
  {…}
916
908
  ```
917
909
 
918
- ### 5.B Web flows
910
+ ### 5.B Luồng Web
919
911
 
920
- <!-- 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/. -->
921
913
 
922
- #### 5.B.1 {name} (web · {UC}-SC…)
914
+ #### 5.B.1 {tên} (web · {UC}-SC…)
923
915
 
924
916
  ```mermaid
925
917
  sequenceDiagram
926
918
  {…}
927
919
  ```
928
920
 
929
- ### 5.C App flows
921
+ ### 5.C Luồng App
930
922
 
931
- <!-- 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/. -->
932
924
 
933
- #### 5.C.1 {name} (app · {UC}-SC…)
925
+ #### 5.C.1 {tên} (app · {UC}-SC…)
934
926
 
935
927
  ```mermaid
936
928
  sequenceDiagram
937
929
  {…}
938
930
  ```
939
931
 
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})". -->
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})". -->
942
934
 
943
- **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):**
944
936
 
945
- | Step | State transition | Verified by (platform · SC) |
937
+ | Bước | Chuyển trạng thái | Verify bởi (platform · SC) |
946
938
  |------|------------------|-----------------------------|
947
- | {step} | {beforeafter} | {web · UC1-SC…} |
939
+ | {bước} | {trướcsau} | {web · UC1-SC…} |
948
940
 
949
941
  ---
950
942
 
951
- ## 6. Integration Points
943
+ ## 6. Điểm tích hợp (Integration Points)
952
944
 
953
- | Integration | Direction | Method | Description |
945
+ | Tích hợp | Chiều | Phương thức | tả |
954
946
  |-------------|-----------|--------|-------------|
955
- | {Client → API} | Outbound (client) | {REST/Bearer} | {what} |
956
- | {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} |
957
949
 
958
950
  ### 6.1 Event Bus / Messaging
959
951
 
960
- <!-- 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ó. -->
961
953
 
962
- {events, or N/A}
954
+ {events, hoặc N/A}
963
955
 
964
- ### 6.2 Cross-Service Dependencies
956
+ ### 6.2 Phụ thuộc Cross-Service (Cross-Service Dependencies)
965
957
 
966
- | Dependent service | What's needed | Contract | Status |
958
+ | Service phụ thuộc | Cần | Contract | Trạng thái |
967
959
  |-------------------|---------------|----------|--------|
968
- | {service} | {need} | {endpoint} | {✅ Exists / ⚠️ pending} |
960
+ | {service} | {cần} | {endpoint} | {✅ / ⚠️ pending} |
969
961
 
970
962
  ---
971
963
 
972
- ## 7. Security & Authorization
964
+ ## 7. Bảo mật & Phân quyền (Security & Authorization)
973
965
 
974
- ### 7.1 Authentication
966
+ ### 7.1 Xác thực (Authentication)
975
967
 
976
- {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.}
977
969
 
978
- ### 7.2 Authorization Rules
970
+ ### 7.2 Quy tắc Phân quyền (Authorization Rules)
979
971
 
980
- | Action | Required role/permission | Description | Trace |
972
+ | Action | Role/quyền yêu cầu | tả | Trace |
981
973
  |--------|--------------------------|-------------|-------|
982
- | {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} |
983
975
 
984
976
  ---
985
977
 
986
- ## 8. Error Handling & Edge Cases
978
+ ## 8. Xử lý lỗi & Trường hợp biên (Error Handling & Edge Cases)
987
979
 
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. -->
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. -->
990
982
 
991
- | Scenario | Strategy | Details | Trace |
983
+ | Scenario | Chiến lược | Chi tiết | Trace |
992
984
  |----------|----------|---------|-------|
993
- | {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…} |
994
986
 
995
987
  ---
996
988
 
997
- ## 9. Design Decisions
989
+ ## 9. Quyết định Thiết kế (Design Decisions)
998
990
 
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. -->
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ế. -->
1002
994
 
1003
- | # | Decision | Rationale | Alternatives considered |
995
+ | # | Quyết định | do | Phương án đã cân nhắc |
1004
996
  |---|----------|-----------|-------------------------|
1005
- | 1 | **{decision}** | {why} | {altwhy rejected} |
997
+ | 1 | **{quyết định}** | {vì sao} | {phương án sao loại} |
1006
998
 
1007
- ### NFR-to-Design Mapping
999
+ ### Ánh xạ NFR → Thiết kế (NFR-to-Design Mapping)
1008
1000
 
1009
- | NFR category | PRD requirement | Design decision |
1001
+ | Nhóm NFR | Yêu cầu PRD | Quyết định thiết kế |
1010
1002
  |--------------|-----------------|-----------------|
1011
- | {e.g. Multi-tenant isolation} | {requirement} | {mechanism} |
1003
+ | {vd Cách ly multi-tenant} | {yêu cầu} | {cơ chế} |
1012
1004
 
1013
1005
  ---
1014
1006
 
1015
- ## 10. UC Coverage
1007
+ ## 10. Độ phủ UC (UC Coverage)
1016
1008
 
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. -->
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. -->
1026
1018
 
1027
- | UC | Feature | Platforms | Sections covered | Status |
1019
+ | UC | Feature | Platforms | Section phủ | Trạng thái |
1028
1020
  |----|---------|-----------|------------------|--------|
1029
1021
  | {TICKET-ID}-UC1 | {title} | {system, web, app} | §… | ✅ Covered |
1030
1022
 
1031
- ### UC1 Scenario Coverage
1023
+ ### Độ phủ Scenario UC1
1032
1024
 
1033
- <!-- One row per (platform, SC). Same SC number on different platforms = different
1034
- 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. -->
1035
1027
 
1036
1028
  | Platform | Scenario | Section | Business rule |
1037
1029
  |----------|----------|---------|---------------|
1038
- | system | {UC}-SC1: {name} | §5.A.1 | {BR…} |
1039
- | 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…} |
1040
1032
 
1041
- <!-- Repeat a scenario-coverage block per UC. -->
1033
+ <!-- Lặp một khối scenario-coverage cho mỗi UC. -->
1042
1034
 
1043
1035
  ---
1044
1036
 
1045
- ## 11. Cross-cutting & Assumptions (Out-of-Scope Reference)
1037
+ ## 11. Cross-cutting & Giả định (Tham chiếu ngoài phạm vi)
1046
1038
 
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. -->
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. -->
1051
1043
 
1052
- ### 11.1 {Concern}
1044
+ ### 11.1 {Mối lo}
1053
1045
 
1054
- > {Quote the BDD/PRD line that scopes it out.}
1046
+ > {Trích câu BDD/PRD đã scope ra ngoài.}
1055
1047
 
1056
- {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.}
1057
1049
 
1058
- **Owned by:** {team / module}. See {link}.
1050
+ **Sở hữu bởi:** {team / module}. Xem {link}.
1059
1051
 
1060
1052
  ---
1061
1053
 
@@ -1088,9 +1080,9 @@ sequenceDiagram
1088
1080
 
1089
1081
  ---
1090
1082
 
1091
- ## Figma Design References
1083
+ ## Tham chiếu Thiết kế Figma (Figma Design References)
1092
1084
 
1093
- <!-- @figma.url: {node-level figma url per screen} -->
1085
+ <!-- @figma.url: {url figma cấp node cho mỗi màn hình} -->
1094
1086
  - {Screen}: [Figma — {frame}]({url})
1095
1087
  - Exported: {YYYY-MM-DD}
1096
1088
 
@@ -1098,10 +1090,10 @@ sequenceDiagram
1098
1090
 
1099
1091
  ## Changelog
1100
1092
 
1101
- | Revision | Date | Changes |
1093
+ | Revision | Ngày | Thay đổi |
1102
1094
  |----------|------|---------|
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}" -->
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}" -->
1105
1097
 
1106
1098
 
1107
1099
  ---
@@ -1119,6 +1111,8 @@ Trước khi finalize/append doc, **tự phản biện bản nháp** qua 4 cổn
1119
1111
  **Cổng 2 — GAP-or-FLAG (trung thực, không bịa).**
1120
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á.
1121
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
+
1122
1116
  **Cổng 3 — CATALOG (không hard-code).**
1123
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.
1124
1118