@educa-corp/sdd-framework 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build.js +113 -19
- package/bin/gate-trace.js +487 -0
- package/bin/index.js +445 -146
- package/bin/lint-trace.js +643 -0
- package/bin/self-check.js +804 -2
- package/bin/trace-schema.json +621 -10
- package/core/FRAMEWORK_VERSION +1 -1
- package/core/README.md +20 -0
- package/core/commands/amend-prd.md +518 -0
- package/core/commands/debug.md +123 -511
- package/core/commands/define-product.md +86 -510
- package/core/commands/dev-gen-test.md +86 -510
- package/core/commands/dev-run-test.md +133 -519
- package/core/commands/dev-smoke-test.md +86 -510
- package/core/commands/extend-prd.md +128 -522
- package/core/commands/fix-bug.md +118 -509
- package/core/commands/generate-architecture.md +94 -515
- package/core/commands/generate-bdd.md +128 -513
- package/core/commands/generate-code.md +119 -510
- package/core/commands/generate-design-spec.md +86 -510
- package/core/commands/generate-prd.md +89 -510
- package/core/commands/generate-spec-manifest.md +86 -510
- package/core/commands/generate-tech-docs.md +120 -512
- package/core/commands/learn.md +172 -496
- package/core/commands/map-testids.md +86 -510
- package/core/commands/propose-scenario.md +86 -510
- package/core/commands/qc-analyze.md +86 -510
- package/core/commands/qc-design-test.md +86 -510
- package/core/commands/qc-plan.md +86 -510
- package/core/commands/qc-report.md +86 -510
- package/core/commands/qc-review.md +86 -510
- package/core/commands/qc-run-test.md +115 -513
- package/core/commands/refine-prd.md +112 -522
- package/core/commands/report-bug.md +86 -510
- package/core/commands/review-code.md +123 -511
- package/core/commands/review-context.md +136 -522
- package/core/commands/review-tech-docs.md +90 -511
- package/core/commands/setup-ai-first.md +166 -138
- package/core/commands/sync.md +155 -107
- package/core/commands/update-framework.md +16 -103
- package/core/commands/validate-traces.md +426 -511
- package/core/hooks/data-guard.js +174 -83
- package/core/hooks/settings.json +2 -1
- package/core/rules/workflow.md +64 -4
- package/core/steps/capture-lesson.md +34 -1
- package/core/steps/context-loader.md +50 -8
- package/core/steps/gate.md +92 -35
- package/core/steps/report-footer.md +23 -0
- package/core/templates/README.md +24 -1
- package/core/templates/ci/trace-gate.yml +146 -0
- package/core/templates/feature.template +1 -1
- package/core/templates/hooks/pre-push +61 -0
- package/docs/02-concepts/architecture.md +61 -6
- package/docs/02-concepts/traceability.md +57 -0
- package/docs/03-guides/architect.md +63 -0
- package/docs/04-reference/commands.md +148 -134
- package/docs/04-reference/model-selection.md +32 -19
- package/docs/04-reference/trace-schema.md +39 -0
- package/docs/explain/02b-extend-prd.md +1 -1
- package/docs/explain/02c-amend-prd.md +152 -0
- package/docs/explain/21-validate-traces.md +2 -1
- package/docs/explain/27-learn.md +5 -3
- package/docs/explain/28-sync.md +25 -0
- package/docs/explain/README.md +136 -135
- package/package.json +5 -9
- package/commands/debug.md +0 -917
- package/commands/debug.tmpl +0 -257
- package/commands/define-product.md +0 -862
- package/commands/define-product.tmpl +0 -225
- package/commands/dev-gen-test.md +0 -1124
- package/commands/dev-gen-test.tmpl +0 -490
- package/commands/dev-run-test.md +0 -859
- package/commands/dev-run-test.tmpl +0 -225
- package/commands/dev-smoke-test.md +0 -798
- package/commands/dev-smoke-test.tmpl +0 -217
- package/commands/extend-prd.md +0 -907
- package/commands/extend-prd.tmpl +0 -270
- package/commands/fix-bug.md +0 -910
- package/commands/fix-bug.tmpl +0 -197
- package/commands/generate-architecture.md +0 -775
- package/commands/generate-architecture.tmpl +0 -194
- package/commands/generate-bdd.md +0 -1347
- package/commands/generate-bdd.tmpl +0 -590
- package/commands/generate-code.md +0 -1283
- package/commands/generate-code.tmpl +0 -649
- package/commands/generate-design-spec.md +0 -1161
- package/commands/generate-design-spec.tmpl +0 -524
- package/commands/generate-prd.md +0 -1143
- package/commands/generate-prd.tmpl +0 -223
- package/commands/generate-spec-manifest.md +0 -745
- package/commands/generate-spec-manifest.tmpl +0 -164
- package/commands/generate-tech-docs.md +0 -1344
- package/commands/generate-tech-docs.tmpl +0 -273
- package/commands/learn.md +0 -723
- package/commands/learn.tmpl +0 -63
- package/commands/map-testids.md +0 -662
- package/commands/map-testids.tmpl +0 -81
- package/commands/propose-scenario.md +0 -783
- package/commands/propose-scenario.tmpl +0 -202
- package/commands/qc-analyze.md +0 -693
- package/commands/qc-analyze.tmpl +0 -112
- package/commands/qc-design-test.md +0 -650
- package/commands/qc-design-test.tmpl +0 -69
- package/commands/qc-plan.md +0 -630
- package/commands/qc-plan.tmpl +0 -49
- package/commands/qc-report.md +0 -641
- package/commands/qc-report.tmpl +0 -60
- package/commands/qc-review.md +0 -634
- package/commands/qc-review.tmpl +0 -53
- package/commands/qc-run-test.md +0 -750
- package/commands/qc-run-test.tmpl +0 -116
- package/commands/refine-prd.md +0 -1074
- package/commands/refine-prd.tmpl +0 -278
- package/commands/report-bug.md +0 -729
- package/commands/report-bug.tmpl +0 -148
- package/commands/review-code.md +0 -803
- package/commands/review-code.tmpl +0 -143
- package/commands/review-context.md +0 -1323
- package/commands/review-context.tmpl +0 -527
- package/commands/review-tech-docs.md +0 -982
- package/commands/review-tech-docs.tmpl +0 -401
- package/commands/setup-ai-first.md +0 -574
- package/commands/setup-ai-first.tmpl +0 -378
- package/commands/sync.md +0 -486
- package/commands/sync.tmpl +0 -384
- package/commands/update-framework.md +0 -290
- package/commands/update-framework.tmpl +0 -188
- package/commands/validate-traces.md +0 -1435
- package/commands/validate-traces.tmpl +0 -854
- package/hooks/data-guard.js +0 -141
- package/hooks/settings.json +0 -18
- package/modules/android-compose/module.yaml +0 -13
- package/modules/android-compose/stack-profile.yaml +0 -57
- package/modules/angular/architecture-snippets/component-patterns.md +0 -187
- package/modules/angular/module.yaml +0 -6
- package/modules/angular/stack-profile.yaml +0 -38
- package/modules/context-engineering/architecture-snippets/context-design.md +0 -119
- package/modules/context-engineering/module.yaml +0 -9
- package/modules/context-engineering/stack-profile.yaml +0 -61
- package/modules/dotnet/architecture-snippets/clean-arch.md +0 -160
- package/modules/dotnet/module.yaml +0 -6
- package/modules/dotnet/stack-profile.yaml +0 -50
- package/modules/flutter/module.yaml +0 -14
- package/modules/flutter/stack-profile.yaml +0 -59
- package/modules/golang/architecture-snippets/domain-layout.md +0 -283
- package/modules/golang/module.yaml +0 -6
- package/modules/golang/stack-profile.yaml +0 -40
- package/modules/ios-swiftui/module.yaml +0 -13
- package/modules/ios-swiftui/stack-profile.yaml +0 -55
- package/modules/java-spring/architecture-snippets/layered-arch.md +0 -201
- package/modules/java-spring/module.yaml +0 -15
- package/modules/java-spring/stack-profile.yaml +0 -28
- package/modules/nextjs/architecture-snippets/app-router-patterns.md +0 -269
- package/modules/nextjs/module.yaml +0 -14
- package/modules/nextjs/stack-profile.yaml +0 -74
- package/modules/nuxt/module.yaml +0 -14
- package/modules/nuxt/stack-profile.yaml +0 -58
- package/modules/phaser-game/architecture-snippets/phaser-scene-patterns.md +0 -646
- package/modules/phaser-game/module.yaml +0 -15
- package/modules/phaser-game/stack-profile.yaml +0 -90
- package/modules/php-laravel/architecture-snippets/service-repository.md +0 -302
- package/modules/php-laravel/module.yaml +0 -15
- package/modules/php-laravel/stack-profile.yaml +0 -56
- package/modules/qc-playwright/stack-profile.yaml +0 -66
- package/modules/react/architecture-snippets/hooks-query-patterns.md +0 -254
- package/modules/react/module.yaml +0 -14
- package/modules/react/stack-profile.yaml +0 -63
- package/modules/react-native/module.yaml +0 -14
- package/modules/react-native/stack-profile.yaml +0 -56
- package/modules/vue/module.yaml +0 -14
- package/modules/vue/stack-profile.yaml +0 -65
- package/rules/data-protection.md +0 -80
- package/rules/workflow.md +0 -73
- package/scripts/init.sh +0 -49
- package/scripts/upgrade.sh +0 -94
- package/skills/code/SKILL.md +0 -19
- package/skills/code/SKILL.tmpl +0 -19
- package/skills/debug/SKILL.md +0 -19
- package/skills/debug/SKILL.tmpl +0 -19
- package/skills/design-spec/SKILL.md +0 -11
- package/skills/design-spec/SKILL.tmpl +0 -11
- package/skills/discovery/SKILL.md +0 -14
- package/skills/discovery/SKILL.tmpl +0 -14
- package/skills/prd/SKILL.md +0 -19
- package/skills/prd/SKILL.tmpl +0 -19
- package/skills/qc/qa-analyst/DOC_GAPS.template.md +0 -63
- package/skills/qc/qa-analyst/acceptance-criteria.md +0 -60
- package/skills/qc/qa-analyst/business-rules.md +0 -59
- package/skills/qc/qa-analyst/data-flow.md +0 -64
- package/skills/qc/qa-analyst/spec-breakdown.md +0 -61
- package/skills/qc/qa-designer/e2e/journey.md +0 -41
- package/skills/qc/qa-designer/exploratory/charter.md +0 -68
- package/skills/qc/qa-designer/exploratory/explore-to-functional.md +0 -43
- package/skills/qc/qa-designer/functional/api.md +0 -45
- package/skills/qc/qa-designer/functional/gui-feature.md +0 -46
- package/skills/qc/qa-designer/functional/gui-screen.md +0 -52
- package/skills/qc/qa-designer/integration/api.md +0 -42
- package/skills/qc/qa-designer/integration/db.md +0 -39
- package/skills/qc/qa-designer/integration/gui.md +0 -40
- package/skills/qc/qa-designer/integration/kafka.md +0 -40
- package/skills/qc/qa-designer/non-functional.md +0 -40
- package/skills/qc/qa-planner/test-plan.md +0 -120
- package/skills/qc/qa-reviewer/script/e2e.md +0 -87
- package/skills/qc/qa-reviewer/script/exploratory.md +0 -45
- package/skills/qc/qa-reviewer/script/functional.md +0 -101
- package/skills/qc/qa-reviewer/script/integration.md +0 -91
- package/skills/qc/qa-reviewer/script/non-functional.md +0 -126
- package/skills/qc/qa-reviewer/test-case/e2e.md +0 -73
- package/skills/qc/qa-reviewer/test-case/exploratory.md +0 -43
- package/skills/qc/qa-reviewer/test-case/functional.md +0 -76
- package/skills/qc/qa-reviewer/test-case/integration.md +0 -69
- package/skills/qc/qa-reviewer/test-case/non-functional.md +0 -73
- package/skills/qc/qa-runner/e2e.md +0 -49
- package/skills/qc/qa-runner/exploratory/session.md +0 -36
- package/skills/qc/qa-runner/functional/api.md +0 -35
- package/skills/qc/qa-runner/functional/gui-feature.md +0 -51
- package/skills/qc/qa-runner/functional/gui-screen.md +0 -55
- package/skills/qc/qa-runner/integration.md +0 -47
- package/skills/qc/qa-runner/non-functional.md +0 -49
- package/skills/qc/qa-runner/report/report.md +0 -37
- package/skills/setup-ai-first/SKILL.md +0 -19
- package/skills/setup-ai-first/SKILL.tmpl +0 -19
- package/skills/spec/SKILL.md +0 -19
- package/skills/spec/SKILL.tmpl +0 -19
- package/skills/test/SKILL.md +0 -18
- package/skills/test/SKILL.tmpl +0 -18
- package/steps/business-language.md +0 -56
- package/steps/capture-lesson.md +0 -79
- package/steps/context-loader.md +0 -385
- package/steps/gate.md +0 -94
- package/steps/report-footer.md +0 -102
- package/steps/review-fanout.md +0 -159
- package/steps/spawn-agent.md +0 -129
- package/steps/trace-mirror.md +0 -53
- package/templates/README.md +0 -47
- package/templates/architecture.template.md +0 -394
- package/templates/design-spec.template.md +0 -217
- package/templates/feature.template +0 -123
- package/templates/platform-guide.template.md +0 -145
- package/templates/prd.template.md +0 -283
- package/templates/product-definition.template.md +0 -188
- package/templates/project-context.yaml +0 -212
- package/templates/tech-design.template.md +0 -490
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
last_verified: {{YYYY-MM-DD}}
|
|
3
|
-
verified_by: {{AUTHOR}}
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# {{SYSTEM_NAME}} — Bối cảnh Kiến trúc (Architecture Context)
|
|
7
|
-
|
|
8
|
-
> Nguồn chân lý duy nhất (single source of truth) về kiến trúc hệ thống — phục vụ cả bối cảnh sinh code (AI agents) lẫn các vấn đề vận hành (triển khai, CI/CD, NFR).
|
|
9
|
-
>
|
|
10
|
-
> HƯỚNG DẪN DÙNG TEMPLATE:
|
|
11
|
-
> - Điền các `{{PLACEHOLDER}}`, xoá comment hướng dẫn (`<!-- ... -->`) sau khi điền.
|
|
12
|
-
> - Không cần điền tay: nên chạy `/generate-architecture` để tự hút từ config/tài liệu/code + phỏng vấn, rồi con người verify.
|
|
13
|
-
>
|
|
14
|
-
> PHÂN TẦNG (tier) — mỗi mục có marker `<!-- tier: core|conditional|ops -->`:
|
|
15
|
-
> - **core** — luôn điền. Kiến trúc nền mà mọi feature cần.
|
|
16
|
-
> - **conditional** — chỉ giữ nếu hệ thống thực sự có (multi-tenant, message bus, sharding…). Không dùng → để dạng STUB hoặc xoá hẳn.
|
|
17
|
-
> - **ops** — vận hành, chỉ để người đọc. AI **KHÔNG** nạp khi sinh code/tech-design.
|
|
18
|
-
>
|
|
19
|
-
> ĐIỀN DẦN: không phải điền hết một lần. Mục chưa làm để dạng STUB rồi lấp sau bằng `/generate-architecture --section=<slug>`:
|
|
20
|
-
> ```
|
|
21
|
-
> ## Multi-tenant <!-- tier: conditional --> <!-- status: stub -->
|
|
22
|
-
> > ⏳ Chưa tài liệu hoá. Chạy `/generate-architecture --section=multi-tenant` khi cần, hoặc điền tay.
|
|
23
|
-
> ```
|
|
24
|
-
|
|
25
|
-
<!-- ════════════════════ CORE (luôn điền) ════════════════════ -->
|
|
26
|
-
|
|
27
|
-
## Công nghệ sử dụng (Tech Stack) <!-- tier: core -->
|
|
28
|
-
|
|
29
|
-
| Tầng | Công nghệ | Phiên bản / Ghi chú |
|
|
30
|
-
|---|---|---|
|
|
31
|
-
| Backend | {{BACKEND_TECH}} | {{VERSION}} |
|
|
32
|
-
| Frontend | {{FRONTEND_TECH}} | {{VERSION}} |
|
|
33
|
-
| ORM / Truy cập dữ liệu | {{ORM}} | {{VERSION}} |
|
|
34
|
-
| Database | {{DATABASE}} | {{PRIMARY_STORE_NOTE}} |
|
|
35
|
-
| Caching | {{CACHE}} | {{CACHE_NOTE}} |
|
|
36
|
-
| Event Bus / Messaging | {{MESSAGING}} | {{MESSAGING_NOTE}} |
|
|
37
|
-
| API Gateway | {{GATEWAY}} | {{GATEWAY_NOTE}} |
|
|
38
|
-
| Kiểm thử | {{TEST_STACK}} | {{TEST_NOTE}} |
|
|
39
|
-
<!-- Thêm/bớt dòng theo thực tế. Cột Ghi chú nên ghi ràng buộc cụ thể AI cần biết (vd: "dùng cho mọi màn hình list", "thư viện private wrapper"). -->
|
|
40
|
-
|
|
41
|
-
## Các tầng kiến trúc (Architecture Layers) <!-- tier: core -->
|
|
42
|
-
|
|
43
|
-
Kiểu kiến trúc: `{{ARCH_STYLE}}` <!-- vd: Layered / Clean / Hexagonal / Component-based -->
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
{{LAYER_DIAGRAM}}
|
|
47
|
-
```
|
|
48
|
-
<!-- Ví dụ Clean Architecture:
|
|
49
|
-
┌──────────────────────────────────────┐
|
|
50
|
-
│ Presentation │ Controllers, Middleware
|
|
51
|
-
├──────────────────────────────────────┤
|
|
52
|
-
│ Application │ Use Cases, DTOs, Interfaces
|
|
53
|
-
├──────────────────────────────────────┤
|
|
54
|
-
│ Domain │ Entities, Value Objects, Events
|
|
55
|
-
├──────────────────────────────────────┤
|
|
56
|
-
│ Infrastructure │ ORM, Cache, Messaging
|
|
57
|
-
└──────────────────────────────────────┘
|
|
58
|
-
-->
|
|
59
|
-
|
|
60
|
-
### Chiều phụ thuộc
|
|
61
|
-
- {{OUTER}} → {{MIDDLE}} → {{INNER}} ← {{INFRASTRUCTURE}}
|
|
62
|
-
- {{INNER_LAYER}} có **zero** phụ thuộc ngoài.
|
|
63
|
-
- Infrastructure hiện thực các interface do Application/Domain định nghĩa.
|
|
64
|
-
- Tầng trong KHÔNG được phụ thuộc tầng ngoài.
|
|
65
|
-
|
|
66
|
-
## Quy ước đặt tên <!-- tier: core -->
|
|
67
|
-
|
|
68
|
-
| Thành phần | Quy ước | Ví dụ |
|
|
69
|
-
|---|---|---|
|
|
70
|
-
| Entity | {{ENTITY_CONV}} | {{EXAMPLE}} |
|
|
71
|
-
| Value Object | {{VO_CONV}} | {{EXAMPLE}} |
|
|
72
|
-
| Interface | {{INTERFACE_CONV}} | {{EXAMPLE}} |
|
|
73
|
-
| Use Case Command | {{COMMAND_CONV}} | {{EXAMPLE}} |
|
|
74
|
-
| Use Case Query | {{QUERY_CONV}} | {{EXAMPLE}} |
|
|
75
|
-
| Handler | {{HANDLER_CONV}} | {{EXAMPLE}} |
|
|
76
|
-
| DTO | {{DTO_CONV}} | {{EXAMPLE}} |
|
|
77
|
-
| Controller | {{CONTROLLER_CONV}} | {{EXAMPLE}} |
|
|
78
|
-
| DI Extension | {{DI_EXT_CONV}} | {{EXAMPLE}} |
|
|
79
|
-
| Class test | {{TEST_CLASS_CONV}} | {{EXAMPLE}} |
|
|
80
|
-
| Method test | {{TEST_METHOD_CONV}} | {{EXAMPLE}} |
|
|
81
|
-
|
|
82
|
-
> Quy ước đặt tên của frontend / từng repo → xem `.ai-project-guide.md` tương ứng.
|
|
83
|
-
|
|
84
|
-
## Định dạng response API chuẩn <!-- tier: core -->
|
|
85
|
-
|
|
86
|
-
```{{LANG}}
|
|
87
|
-
// Thành công
|
|
88
|
-
{{SUCCESS_WRAPPER}}
|
|
89
|
-
→ {{SUCCESS_JSON_SHAPE}}
|
|
90
|
-
|
|
91
|
-
// Thất bại
|
|
92
|
-
{{FAILURE_WRAPPER}}
|
|
93
|
-
→ {{FAILURE_JSON_SHAPE}}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Quy ước API <!-- tier: core -->
|
|
97
|
-
|
|
98
|
-
| Khía cạnh | Quy ước |
|
|
99
|
-
|---|---|
|
|
100
|
-
| Base URL | {{BASE_URL}} |
|
|
101
|
-
| Versioning | {{VERSIONING}} <!-- vd: URL path /v1/, theo header, query param --> |
|
|
102
|
-
| Đặt tên URL | {{URL_NAMING}} <!-- vd: kebab-case --> |
|
|
103
|
-
| Phân trang | {{PAGINATION}} <!-- vd: ?page=1&pageSize=20 → meta{...} --> |
|
|
104
|
-
| Lọc | {{FILTERING}} |
|
|
105
|
-
| Sắp xếp | {{SORTING}} |
|
|
106
|
-
| Định dạng ngày | {{DATE_FORMAT}} <!-- vd: ISO 8601 --> |
|
|
107
|
-
| Ngừng hỗ trợ (Deprecation) | {{DEPRECATION_POLICY}} |
|
|
108
|
-
|
|
109
|
-
### Các endpoint chính theo service <!-- [TUỲ CHỌN] -->
|
|
110
|
-
|
|
111
|
-
| Service | Endpoints |
|
|
112
|
-
|---|---|
|
|
113
|
-
| {{SERVICE}} | {{ENDPOINTS}} |
|
|
114
|
-
|
|
115
|
-
> Tài liệu API đầy đủ: {{API_DOCS_LOCATION}} <!-- vd: /swagger cho mỗi service -->
|
|
116
|
-
|
|
117
|
-
## Quy ước Database <!-- tier: core -->
|
|
118
|
-
|
|
119
|
-
- **Migration**: {{MIGRATION_STRATEGY}} <!-- vd: code-first mỗi service -->
|
|
120
|
-
- **Đặt tên**: {{DB_NAMING}} <!-- vd: PascalCase cho entity, snake_case cho cột -->
|
|
121
|
-
- **Soft Delete**: {{SOFT_DELETE_RULE}}
|
|
122
|
-
- **Cột audit**: {{AUDIT_COLUMNS}} <!-- vd: CreatedAt NOT NULL, ModifiedAt nullable -->
|
|
123
|
-
- **Xử lý đồng thời**: {{CONCURRENCY_MECHANISM}} <!-- vd: ROWVERSION / optimistic lock -->
|
|
124
|
-
- **Quy ước ID**: {{PK_TYPE}} <!-- vd: bigint (không dùng Guid) -->
|
|
125
|
-
|
|
126
|
-
### Quy ước Migration <!-- [TUỲ CHỌN] khi dùng SQL migration thủ công -->
|
|
127
|
-
- **Vị trí**: {{MIGRATION_LOCATION}}
|
|
128
|
-
- **Đặt tên**: {{MIGRATION_NAMING}} <!-- vd: V{YYYYMMDD}_{NN}_{description}.sql -->
|
|
129
|
-
- **Tính idempotent**: {{IDEMPOTENCY_RULE}} <!-- vd: dùng guard IF NOT EXISTS -->
|
|
130
|
-
|
|
131
|
-
<!-- ════════════════════ CONDITIONAL (chỉ giữ nếu hệ thống có) ════════════════════ -->
|
|
132
|
-
|
|
133
|
-
## Luồng dữ liệu tổng quan <!-- tier: conditional -->
|
|
134
|
-
|
|
135
|
-
<!-- Mô tả 1-2 câu bản chất luồng dữ liệu của hệ thống (vd: "hệ tổng hợp dữ liệu: master data ở hệ ngoài, config/transaction ở DB local, gộp tại runtime"). -->
|
|
136
|
-
{{DATA_FLOW_SUMMARY}}
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
{{DATA_FLOW_DIAGRAM}}
|
|
140
|
-
```
|
|
141
|
-
<!-- Vẽ ASCII: Clients → Gateway → Services → điểm composition ở Application → Infrastructure (API ngoài / DB / cache / bus).
|
|
142
|
-
Ghi rõ phương thức auth của từng client và các điểm composition quan trọng. -->
|
|
143
|
-
|
|
144
|
-
### Phân loại nguồn dữ liệu <!-- [TUỲ CHỌN] khi dữ liệu đến từ nhiều nguồn (API ngoài + DB local) -->
|
|
145
|
-
|
|
146
|
-
| Dữ liệu | Nguồn | Cách truy cập | Caching |
|
|
147
|
-
|---|---|---|---|
|
|
148
|
-
| {{DATA}} | {{SOURCE}} | {{PATH}} | {{TTL_OR_DASH}} |
|
|
149
|
-
|
|
150
|
-
### Giao tiếp giữa các service <!-- [TUỲ CHỌN] khi multi-service -->
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
{{SERVICE_A}} ──{{PROTOCOL}}──▶ {{SERVICE_B}} ({{VIA_CLIENT}})
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
> **Endpoint nội bộ** ({{INTERNAL_ROUTE_PREFIX}}): {{INTERNAL_AUTH_MECHANISM}} — vd: header shared-secret + IP whitelist. Xem §Luồng Xác thực.
|
|
157
|
-
|
|
158
|
-
## Repositories & Hướng dẫn nền tảng <!-- tier: conditional --> <!-- chỉ giữ nếu là hệ multi-repo -->
|
|
159
|
-
|
|
160
|
-
| Repository | Stack | Platform Guide |
|
|
161
|
-
|---|---|---|
|
|
162
|
-
| `{{repo-name}}/` | {{STACK_SUMMARY}} | `{{repo-name}}/.ai-project-guide.md` |
|
|
163
|
-
|
|
164
|
-
> **Cấu trúc thư mục, scan path, quy ước namespace, code pattern** → xem `.ai-project-guide.md` của từng repo.
|
|
165
|
-
> File này tập trung vào **kiến trúc cắt ngang** dùng chung cho mọi repo.
|
|
166
|
-
|
|
167
|
-
## Phân loại Entity <!-- tier: conditional --> <!-- khi hệ thống tích hợp dữ liệu từ hệ ngoài -->
|
|
168
|
-
|
|
169
|
-
Entity được chia thành các nhóm sau. Mọi code, tài liệu, và BDD spec PHẢI dùng các thuật ngữ này nhất quán.
|
|
170
|
-
|
|
171
|
-
| Nhóm | Thuật ngữ | Lưu ở DB? | ORM quản lý? | Truy cập qua | Ví dụ |
|
|
172
|
-
|---|---|---|---|---|---|
|
|
173
|
-
| **DB Entity** | `[entity] entity` | CÓ | CÓ | {{DB_REPO_INTERFACE}} | {{EXAMPLES}} |
|
|
174
|
-
| **Model nguồn-API** | `[entity] model` | KHÔNG | KHÔNG — POCO/DTO | {{API_SERVICE_INTERFACE}} | {{EXAMPLES}} |
|
|
175
|
-
| **Projection Entity** | `[entity] projection` | CÓ | CÓ | {{PROJECTION_REPO}} | {{EXAMPLES}} |
|
|
176
|
-
|
|
177
|
-
**Quy tắc:**
|
|
178
|
-
- Model nguồn-API KHÔNG có bảng DB, KHÔNG migration — là POCO/DTO được populate từ API ngoài.
|
|
179
|
-
- {{ID_RULE}} <!-- vd: Model nguồn-API Id = external ID; DB entity Id = tự sinh -->
|
|
180
|
-
- {{PROJECT_SPECIFIC_RULE}}
|
|
181
|
-
|
|
182
|
-
## Phân loại truy cập dữ liệu — Ranh giới các tầng <!-- tier: conditional --> <!-- khi gộp dữ liệu nhiều nguồn (API ngoài + DB) -->
|
|
183
|
-
|
|
184
|
-
Cách các tầng truy cập dữ liệu và ranh giới giữa chúng:
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
{{ACCESS_TREE}}
|
|
188
|
-
```
|
|
189
|
-
<!-- Ví dụ:
|
|
190
|
-
Handler / Controller
|
|
191
|
-
├── IProductCatalogService (Application — điểm gộp DUY NHẤT)
|
|
192
|
-
│ ├── IProductService (Infrastructure — API ngoài)
|
|
193
|
-
│ └── IDisplayConfigRepository (Infrastructure — DB)
|
|
194
|
-
└── IOrderRepository (Infrastructure — DB, inject trực tiếp)
|
|
195
|
-
-->
|
|
196
|
-
|
|
197
|
-
| Tầng | Mục đích | Sở hữu | Ví dụ |
|
|
198
|
-
|---|---|---|---|
|
|
199
|
-
| **{{API_SERVICE_LAYER}}** (Infrastructure) | Gọi API ngoài; tự quản cache/retry/circuit-breaker/mapping | Model nguồn-API | {{EXAMPLES}} |
|
|
200
|
-
| **{{DB_REPO_LAYER}}** (Infrastructure) | Thao tác DB local; repository pattern chuẩn | DB entity | {{EXAMPLES}} |
|
|
201
|
-
| **{{APP_SERVICE_LAYER}}** (Application) | Gộp dữ liệu nhiều nguồn; điểm composition duy nhất | Domain object đã enrich | {{EXAMPLES}} |
|
|
202
|
-
| **{{HANDLER_LAYER}}** (Presentation/Application) | Điều phối use-case; mapping request→response | — | {{EXAMPLES}} |
|
|
203
|
-
|
|
204
|
-
**Quy tắc Injection (BẮT BUỘC tuân theo):**
|
|
205
|
-
1. {{RULE_1}} <!-- vd: Service gọi API ngoài chỉ inject vào Application Service, KHÔNG inject thẳng vào Handler -->
|
|
206
|
-
2. {{RULE_2}}
|
|
207
|
-
3. {{RULE_3}}
|
|
208
|
-
|
|
209
|
-
## Trách nhiệm của từng service <!-- tier: conditional --> <!-- khi multi-service -->
|
|
210
|
-
|
|
211
|
-
| Service | Domain | Trách nhiệm chính |
|
|
212
|
-
|---|---|---|
|
|
213
|
-
| {{SERVICE}} | {{DOMAIN}} | {{RESPONSIBILITIES}} |
|
|
214
|
-
|
|
215
|
-
## Mô hình đăng ký DI <!-- tier: conditional -->
|
|
216
|
-
|
|
217
|
-
Mỗi feature đăng ký dependency qua extension method / module:
|
|
218
|
-
```{{LANG}}
|
|
219
|
-
{{DI_REGISTRATION_EXAMPLE}}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Mô hình Multi-tenant <!-- tier: conditional --> <!-- khi một hệ thống phục vụ nhiều khách hàng/chi nhánh, dữ liệu tách riêng -->
|
|
223
|
-
|
|
224
|
-
Mọi entity (trừ {{GLOBAL_ENTITIES}}) PHẢI có `{{TENANT_KEY}}`. {{ISOLATION_MECHANISM}} đảm bảo cách ly:
|
|
225
|
-
```{{LANG}}
|
|
226
|
-
{{QUERY_FILTER_EXAMPLE}}
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Truy cập tenant context qua: `{{TENANT_CONTEXT_ACCESSOR}}` <!-- các field: TenantId, AppId, UserId... -->
|
|
230
|
-
|
|
231
|
-
## Phân giải định danh — External ID vs Internal ID <!-- tier: conditional --> <!-- khi tích hợp hệ ngoài có ID riêng -->
|
|
232
|
-
|
|
233
|
-
Hệ thống tích hợp với {{EXTERNAL_SYSTEM}}. Mỗi entity ngoài có ID riêng, **KHÔNG trùng** với internal ID. Hai hệ ID này phải luôn được phân biệt rõ.
|
|
234
|
-
|
|
235
|
-
| | DB Entity (local) | Model nguồn-API (ngoài) |
|
|
236
|
-
|---|---|---|
|
|
237
|
-
| **`Id`** | {{INTERNAL_ID_RULE}} (tự sinh) | Gán từ response hệ ngoài — KHÔNG tự sinh |
|
|
238
|
-
| **`ExternalId`** | Lưu ID hệ ngoài để tham chiếu chéo | Không áp dụng — `Id` chính là external ID |
|
|
239
|
-
|
|
240
|
-
### Quy tắc bắt buộc
|
|
241
|
-
1. {{RULE_1}} <!-- vd: DB Entity Id luôn tự sinh, TUYỆT ĐỐI KHÔNG gán external ID vào Id -->
|
|
242
|
-
2. {{RULE_2}}
|
|
243
|
-
3. {{RULE_3}}
|
|
244
|
-
|
|
245
|
-
### Anti-pattern (CẤM)
|
|
246
|
-
```{{LANG}}
|
|
247
|
-
// ❌ SAI — {{ANTIPATTERN_DESC}}
|
|
248
|
-
{{BAD_EXAMPLE}}
|
|
249
|
-
|
|
250
|
-
// ✅ ĐÚNG
|
|
251
|
-
{{GOOD_EXAMPLE}}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## API Gateway <!-- tier: conditional -->
|
|
255
|
-
|
|
256
|
-
| Trách nhiệm | Chi tiết |
|
|
257
|
-
|---|---|
|
|
258
|
-
| Xác minh chữ ký / auth | {{DETAIL}} |
|
|
259
|
-
| Rate limiting | {{DETAIL}} |
|
|
260
|
-
| Xử lý CORS | {{DETAIL}} |
|
|
261
|
-
| Định tuyến request | {{DETAIL}} |
|
|
262
|
-
| Cân bằng tải | {{DETAIL}} |
|
|
263
|
-
| IP whitelist | {{DETAIL}} |
|
|
264
|
-
|
|
265
|
-
**Nguyên tắc thiết kế:** Stateless, không chứa business logic, scale ngang được.
|
|
266
|
-
|
|
267
|
-
## Chiến lược Caching <!-- tier: conditional -->
|
|
268
|
-
|
|
269
|
-
**Mô hình**: {{CACHE_PATTERN}} <!-- vd: Cache-Aside (read-through) -->
|
|
270
|
-
**Định dạng key**: {{KEY_FORMAT}} <!-- vd: {entity}:{tenantId}:{id} -->
|
|
271
|
-
|
|
272
|
-
| Loại dữ liệu | TTL | Cách invalidate |
|
|
273
|
-
|---|---|---|
|
|
274
|
-
| {{DATA}} | {{TTL}} | {{INVALIDATION}} |
|
|
275
|
-
|
|
276
|
-
## Event Bus <!-- tier: conditional -->
|
|
277
|
-
|
|
278
|
-
> **Trạng thái:** {{STATUS}} <!-- vd: đã cấp hạ tầng nhưng chưa implement / đã chạy production -->
|
|
279
|
-
|
|
280
|
-
**Nguyên tắc thiết kế:**
|
|
281
|
-
- {{PARTITIONING}} <!-- vd: partition theo TenantId để đảm bảo thứ tự trong mỗi tenant -->
|
|
282
|
-
- {{DELIVERY_GUARANTEE}} <!-- vd: at-least-once + theo dõi idempotency -->
|
|
283
|
-
- {{DLQ_RETRY}} <!-- vd: DLQ {topic}.dlq, retry 3 lần với exponential backoff -->
|
|
284
|
-
|
|
285
|
-
## Sharding <!-- tier: conditional -->
|
|
286
|
-
|
|
287
|
-
- {{SHARD_STRATEGY}} <!-- vd: mô hình Shard Registry + cache -->
|
|
288
|
-
- {{SHARD_RESOLVER}} <!-- vd: IShardResolver: cache → Registry DB → tự gán -->
|
|
289
|
-
|
|
290
|
-
## Feature Toggle <!-- tier: conditional -->
|
|
291
|
-
|
|
292
|
-
Hệ thống dùng {{FEATURE_TOGGLE_TOOL}} cho feature flag lúc runtime.
|
|
293
|
-
|
|
294
|
-
| Điều kiện | Hành vi |
|
|
295
|
-
|---|---|
|
|
296
|
-
| Toggle bị tắt | {{BEHAVIOR}} <!-- thường: fail-open / cho phép -->|
|
|
297
|
-
| Lỗi khi đánh giá | {{BEHAVIOR}} <!-- thường: fail-open để sự cố không khoá user -->|
|
|
298
|
-
| Flag trả về false | {{BEHAVIOR}} |
|
|
299
|
-
|
|
300
|
-
## Luồng Xác thực <!-- tier: conditional -->
|
|
301
|
-
|
|
302
|
-
### {{AUTH_METHOD}} <!-- vd: JWT Bearer / API Key (HMAC) / OAuth2 / Token Exchange -->
|
|
303
|
-
|
|
304
|
-
```
|
|
305
|
-
{{AUTH_FLOW_STEPS}}
|
|
306
|
-
```
|
|
307
|
-
<!-- Liệt kê tuần tự các bước middleware xử lý: extract → verify → resolve → build context.
|
|
308
|
-
Nếu có nhiều luồng auth (S2S, browser, internal), mô tả từng luồng. -->
|
|
309
|
-
|
|
310
|
-
**Quy tắc chính:**
|
|
311
|
-
- {{AUTH_RULE_1}}
|
|
312
|
-
- {{AUTH_RULE_2}}
|
|
313
|
-
|
|
314
|
-
**Middleware pipeline:**
|
|
315
|
-
```
|
|
316
|
-
{{ROUTE_PATTERN}} → {{MIDDLEWARE_OR_BYPASS}}
|
|
317
|
-
{{HEALTH_ROUTE}} → bypass (health probe)
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
<!-- ════════════════════ OPS (chỉ người đọc — AI không nạp khi sinh code) ════════════════════ -->
|
|
321
|
-
|
|
322
|
-
## Observability (Khả năng quan sát) <!-- tier: ops -->
|
|
323
|
-
|
|
324
|
-
### Ghi log (Logging)
|
|
325
|
-
- Thư viện: {{LOGGING_LIB}}
|
|
326
|
-
- Định dạng: {{LOG_FORMAT}} <!-- vd: Compact JSON -->
|
|
327
|
-
- Sink: {{LOG_SINKS}} <!-- vd: file xoay vòng theo ngày, giữ 30 ngày; console chỉ khi dev -->
|
|
328
|
-
- **Correlation ID**: {{CORRELATION_MECHANISM}} <!-- vd: X-Correlation-Id đẩy vào log context -->
|
|
329
|
-
- Mức log: {{LOG_LEVELS}}
|
|
330
|
-
|
|
331
|
-
### Metrics <!-- [TUỲ CHỌN] -->
|
|
332
|
-
|
|
333
|
-
| Metric | Loại | Mô tả |
|
|
334
|
-
|---|---|---|
|
|
335
|
-
| {{METRIC}} | {{TYPE}} | {{DESC}} |
|
|
336
|
-
|
|
337
|
-
### Distributed Tracing <!-- [TUỲ CHỌN] -->
|
|
338
|
-
- {{TRACING_TOOL}} — {{PROPAGATION_SCOPE}} <!-- vd: OpenTelemetry, propagate qua HTTP + messaging -->
|
|
339
|
-
|
|
340
|
-
### Health Check
|
|
341
|
-
```{{LANG}}
|
|
342
|
-
{{HEALTH_CHECK_REGISTRATION}}
|
|
343
|
-
```
|
|
344
|
-
- `{{LIVENESS_ROUTE}}` — liveness (chỉ tự kiểm tra)
|
|
345
|
-
- `{{READINESS_ROUTE}}` — readiness (phụ thuộc: DB + cache + bus)
|
|
346
|
-
|
|
347
|
-
## Triển khai & DevOps <!-- tier: ops -->
|
|
348
|
-
|
|
349
|
-
### Chiến lược môi trường
|
|
350
|
-
|
|
351
|
-
| Môi trường | Mục đích | Hạ tầng |
|
|
352
|
-
|---|---|---|
|
|
353
|
-
| Development | {{PURPOSE}} | {{INFRA}} |
|
|
354
|
-
| Staging | {{PURPOSE}} | {{INFRA}} |
|
|
355
|
-
| Production | {{PURPOSE}} | {{INFRA}} |
|
|
356
|
-
|
|
357
|
-
### CI/CD Pipeline
|
|
358
|
-
```
|
|
359
|
-
{{PIPELINE_STAGES}}
|
|
360
|
-
```
|
|
361
|
-
<!-- vd: Code Push → Build → Unit Test → Integration Test → Docker Build → Push Registry → Deploy Staging → Smoke → Duyệt tay → Production -->
|
|
362
|
-
|
|
363
|
-
### Quản lý cấu hình
|
|
364
|
-
|
|
365
|
-
| Loại cấu hình | Lưu ở | Ví dụ |
|
|
366
|
-
|---|---|---|
|
|
367
|
-
| App Settings | {{STORAGE}} | {{EXAMPLE}} |
|
|
368
|
-
| Secrets | {{SECRET_STORE}} | {{EXAMPLE}} <!-- secret production TUYỆT ĐỐI KHÔNG commit vào repo -->|
|
|
369
|
-
| Biến môi trường | {{ENV_STORE}} | {{EXAMPLE}} |
|
|
370
|
-
|
|
371
|
-
## Chiến lược kiểm thử <!-- tier: ops -->
|
|
372
|
-
|
|
373
|
-
| Cấp độ | Phạm vi | Công cụ |
|
|
374
|
-
|---|---|---|
|
|
375
|
-
| Unit Test | {{SCOPE}} | {{TOOLS}} |
|
|
376
|
-
| Integration Test | {{SCOPE}} | {{TOOLS}} |
|
|
377
|
-
| Functional Test | {{SCOPE}} | {{TOOLS}} |
|
|
378
|
-
| Load Test | {{SCOPE}} | {{TOOLS}} |
|
|
379
|
-
|
|
380
|
-
- Đặt tên: {{TEST_NAMING}} <!-- vd: MethodName_Scenario_ExpectedResult -->
|
|
381
|
-
- {{CI_TEST_RULE}} <!-- vd: CI chạy unit + integration mỗi PR -->
|
|
382
|
-
|
|
383
|
-
## Yêu cầu phi chức năng (NFR) <!-- tier: ops -->
|
|
384
|
-
|
|
385
|
-
| Yêu cầu | Mục tiêu |
|
|
386
|
-
|---|---|
|
|
387
|
-
| Khả năng mở rộng | {{TARGET}} |
|
|
388
|
-
| Tính sẵn sàng | {{TARGET}} <!-- vd: SLA uptime 99.9% -->|
|
|
389
|
-
| Triển khai | {{TARGET}} <!-- vd: zero-downtime, rolling update -->|
|
|
390
|
-
| Tính nhất quán | {{TARGET}} |
|
|
391
|
-
| Độ trễ | {{TARGET}} <!-- vd: API p95 < 200ms -->|
|
|
392
|
-
| Thông lượng | {{TARGET}} |
|
|
393
|
-
| Lưu trữ dữ liệu | {{TARGET}} |
|
|
394
|
-
| Sao lưu | {{TARGET}} |
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
# {TICKET-ID} {Feature Name} — Design Spec [{Platform}]
|
|
2
|
-
|
|
3
|
-
<!--
|
|
4
|
-
Template này được sử dụng bởi /generate-design-spec.
|
|
5
|
-
Platform = web | app | app-ios | app-android
|
|
6
|
-
|
|
7
|
-
PLATFORM SECTIONS:
|
|
8
|
-
- Section 3A + 4A: chỉ dành cho web (react/nextjs/vue/angular). Xóa C khi dùng cho web.
|
|
9
|
-
- Section 3C + 4B: chỉ dành cho app (flutter/react-native/ios/android). Xóa A+B khi dùng cho app.
|
|
10
|
-
|
|
11
|
-
COMPONENT MAPPING (bắt buộc):
|
|
12
|
-
- Mọi component trong Component Inventory PHẢI được map với figma-components/{module}.md
|
|
13
|
-
- ✅ Matched → dùng Code Component và Import Path từ catalog
|
|
14
|
-
- ⚠️ TODO → đánh dấu [TODO — chưa implement]
|
|
15
|
-
- ❌ Chưa có → đánh dấu [NEW — cần confirm với designer]
|
|
16
|
-
|
|
17
|
-
FIGMA LINKS (bắt buộc mỗi màn):
|
|
18
|
-
- Mỗi screen PHẢI có link Figma node-level (URL chứa ?node-id=...) — lấy bằng
|
|
19
|
-
right-click frame → "Copy link to selection". Đây là link AI đọc được qua Figma MCP.
|
|
20
|
-
- Link file trần (không có node-id) KHÔNG hợp lệ — AI không định vị được frame.
|
|
21
|
-
- Screen chưa có design → đánh dấu ❌ Missing; spec giữ Status "draft", chặn sign-off
|
|
22
|
-
và /generate-bdd cho tới khi đủ link.
|
|
23
|
-
|
|
24
|
-
SCREEN STATES (bắt buộc mỗi màn):
|
|
25
|
-
- Tối thiểu: default, loading, error
|
|
26
|
-
- Thêm "empty" nếu màn có thể hiển thị trạng thái không có dữ liệu
|
|
27
|
-
- Thêm "success" nếu action tạo ra trạng thái xác nhận riêng biệt
|
|
28
|
-
-->
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## Metadata
|
|
33
|
-
|
|
34
|
-
| Field | Value |
|
|
35
|
-
|--------------------|---------------------------------------------------------------|
|
|
36
|
-
| **Spec ID** | {TICKET-ID}-DS-{platform} |
|
|
37
|
-
| **Version** | 1.0 |
|
|
38
|
-
| **Status** | draft / approved |
|
|
39
|
-
| **Platform** | {web \| app \| app-ios \| app-android} |
|
|
40
|
-
| **Module** | {active_module} |
|
|
41
|
-
| **Service** | {active_service} |
|
|
42
|
-
| **Domain** | {domain} |
|
|
43
|
-
| **Business PRD** | [{TICKET-ID}](./{TICKET-ID}-slug.md) |
|
|
44
|
-
| **Figma** | {link file feature} ({linked}/{N} frame đã link) |
|
|
45
|
-
| **Author** | {tên PO hoặc "AI-assisted"} |
|
|
46
|
-
| **Created** | {YYYY-MM-DD} |
|
|
47
|
-
| **Updated** | {YYYY-MM-DD} |
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
# 1. Danh mục màn hình (Screen Inventory)
|
|
52
|
-
|
|
53
|
-
| # | Tên màn hình | Điểm vào | Figma Frame (link node-level) | Ghi chú |
|
|
54
|
-
|---|-------------|-------------|-------------------------------|-------|
|
|
55
|
-
| 1 | {Màn hình 1} | {người dùng đến từ đâu} | [Frame]({node-level url}) | |
|
|
56
|
-
| 2 | {Màn hình 2} | {điểm vào} | ❌ Missing — thêm link node-id | |
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
# 2. Đặc tả màn hình (Screen Specs)
|
|
61
|
-
|
|
62
|
-
## Màn hình 1: {Tên màn hình}
|
|
63
|
-
|
|
64
|
-
**Figma**: [{Tên frame}]({figma_frame_url})
|
|
65
|
-
|
|
66
|
-
### Layout
|
|
67
|
-
|
|
68
|
-
{Grid / max-width / padding / spacing — tham chiếu design token nếu áp dụng được}
|
|
69
|
-
|
|
70
|
-
### Component Inventory
|
|
71
|
-
|
|
72
|
-
| Component (Figma) | Code Component | Import Path | States | Ghi chú |
|
|
73
|
-
|------------------------|----------------|------------------------|---------------------------------|---------|
|
|
74
|
-
| {Figma/Button/Primary} | Button | @/components/ui/Button | default, loading, disabled | |
|
|
75
|
-
| {Figma/Input/Text} | TextInput | @/components/ui/Input | default, focus, error, disabled | |
|
|
76
|
-
|
|
77
|
-
### Screen States
|
|
78
|
-
|
|
79
|
-
| State | Trigger | Hành vi UI |
|
|
80
|
-
|-----------|----------------------------------|----------------------------------------------------------|
|
|
81
|
-
| default | Màn đã load, có dữ liệu | {Mô tả toàn bộ giao diện đã render} |
|
|
82
|
-
| loading | API đang gọi | {Vị trí và kiểu skeleton / spinner} |
|
|
83
|
-
| error | API thất bại / lỗi validation | {Toast / lỗi inline / màn lỗi + CTA khôi phục} |
|
|
84
|
-
| empty | Không có dữ liệu trả về | {Illustration + CTA — vd: "Chưa có mục nào. Thêm mới →"} |
|
|
85
|
-
| success | Action hoàn tất (nếu có) | {Toast xác nhận / điều hướng / thay đổi giao diện} |
|
|
86
|
-
|
|
87
|
-
### Actions & Navigation
|
|
88
|
-
|
|
89
|
-
| Action | Trigger | Kết quả |
|
|
90
|
-
|-----------------|---------------------------|---------------------------------------------------|
|
|
91
|
-
| {Tên action} | Tap/click {phần tử} | Điều hướng tới {Màn hình N} / Mở {Tên modal} |
|
|
92
|
-
| {Back/Cancel} | Cử chỉ back / nút | Quay lại {màn trước} mà không lưu |
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
<!-- Lặp lại ## Màn hình N cho mỗi màn bổ sung -->
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
# 3. Pattern tương tác (Interaction Patterns)
|
|
101
|
-
|
|
102
|
-
<!-- === CHỈ WEB — xóa section này cho app === -->
|
|
103
|
-
|
|
104
|
-
## A. Hành vi Responsive *(web)*
|
|
105
|
-
|
|
106
|
-
| Breakpoint | Width | Thay đổi layout |
|
|
107
|
-
|------------|------------|---------------------------------------------|
|
|
108
|
-
| Mobile | < 768px | {1 cột, bottom nav, CTA full-width} |
|
|
109
|
-
| Tablet | 768–1279px | {grid 2 cột, sidebar thu gọn} |
|
|
110
|
-
| Desktop | ≥ 1280px | {layout đầy đủ, max-width 1440px} |
|
|
111
|
-
|
|
112
|
-
## B. Hover / Focus / Keyboard *(web)*
|
|
113
|
-
|
|
114
|
-
| Phần tử | Hover | Focus | Keyboard |
|
|
115
|
-
|----------------|-------------------------------|---------------------------------|---------------|
|
|
116
|
-
| Primary button | Background → {color.hover} | Outline 2px {color.focus} | Enter / Space |
|
|
117
|
-
| Text input | Border → {color.border.hover} | Border → {color.primary} | Tab to focus |
|
|
118
|
-
|
|
119
|
-
<!-- === CHỈ APP — xóa section A+B cho app === -->
|
|
120
|
-
|
|
121
|
-
## C. Cử chỉ & Điều hướng *(app)*
|
|
122
|
-
|
|
123
|
-
| Cử chỉ | Màn / Phần tử | Hành vi |
|
|
124
|
-
|----------------------|---------------------|---------------------------------------------|
|
|
125
|
-
| Cử chỉ back | Mọi màn | {Quay lại / hiện dialog "Discard changes?"} |
|
|
126
|
-
| Pull-to-refresh | {Tên màn} | Refresh dữ liệu, spinner ở trên cùng |
|
|
127
|
-
| Swipe trái trên row | {List item} | Hiện action {Delete / Archive} |
|
|
128
|
-
|
|
129
|
-
### Navigation Stack *(app)*
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
{vd: BottomTab(Home) → ListPage → DetailPage → EditPage}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Platform Conventions *(app)*
|
|
136
|
-
|
|
137
|
-
| Khía cạnh | iOS | Android |
|
|
138
|
-
|------------------|-------------------------------------------|-------------------------------------|
|
|
139
|
-
| Navigation bar | Nút back trên-trái, title canh giữa | Mũi tên Up, title canh trái |
|
|
140
|
-
| Bottom sheet | UISheetPresentation, hiện grabber | BottomSheet, drag handle |
|
|
141
|
-
| Dialog | Action canh phải | Action canh trái |
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
# 4. Cân nhắc theo Platform (Platform Considerations)
|
|
146
|
-
|
|
147
|
-
<!-- === CHỈ WEB === -->
|
|
148
|
-
|
|
149
|
-
## A. Accessibility *(web)*
|
|
150
|
-
|
|
151
|
-
- [ ] Mọi phần tử tương tác đều tới được bằng phím Tab — không có keyboard trap
|
|
152
|
-
- [ ] Focus trap bên trong modal
|
|
153
|
-
- [ ] Nút chỉ có icon phải có `aria-label`
|
|
154
|
-
- [ ] Nội dung động thông báo qua `aria-live`
|
|
155
|
-
- [ ] Tương phản WCAG AA: text ≥ 4.5:1, text lớn ≥ 3:1
|
|
156
|
-
- [ ] Input form có label hiển thị (không chỉ dùng placeholder)
|
|
157
|
-
|
|
158
|
-
<!-- === CHỈ APP === -->
|
|
159
|
-
|
|
160
|
-
## B. Thiết bị & OS *(app)*
|
|
161
|
-
|
|
162
|
-
- [ ] Áp dụng safe area insets (trên + dưới) ở mọi màn
|
|
163
|
-
- [ ] Touch target tối thiểu: 44×44pt (iOS) / 48×48dp (Android)
|
|
164
|
-
- [ ] Đã test trên 375pt (iPhone SE) và 360dp (Android nhỏ)
|
|
165
|
-
- [ ] Deep link: `{scheme}://{host}/{path}` → {tên màn}
|
|
166
|
-
- [ ] Permission: {Camera / Location / Notification} — nội dung lý do TBD
|
|
167
|
-
- [ ] Offline: {tên màn} hiện dữ liệu cache + banner; {action} bị disable kèm tooltip
|
|
168
|
-
- [ ] Đã test dark mode — không có màu hardcode
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
# 5. AC-UI — Tiêu chí chấp nhận về Design
|
|
173
|
-
|
|
174
|
-
> Được **PO + Designer** review và sign off trước khi sinh BDD.
|
|
175
|
-
> Bổ sung cho AC mức nghiệp vụ trong [Business PRD](./{TICKET-ID}-slug.md).
|
|
176
|
-
|
|
177
|
-
| ID | Tiêu chí chấp nhận | Verified by |
|
|
178
|
-
|--------|--------------------------------------------------------------------------|-----------------|
|
|
179
|
-
| AC-UI1 | Mọi màn khớp với frame Figma đã duyệt trong dung sai design-system | Designer |
|
|
180
|
-
| AC-UI2 | Trạng thái loading xuất hiện trong vòng 200ms kể từ khi gọi API | QA |
|
|
181
|
-
| AC-UI3 | Mọi thông báo lỗi đều hiển thị, rõ ràng, và kèm CTA khôi phục | PO |
|
|
182
|
-
| AC-UI4 | Empty state có illustration và call-to-action | PO + Designer |
|
|
183
|
-
| AC-UI5 | {Tiêu chí riêng theo platform} | QA |
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
# Appendix
|
|
188
|
-
|
|
189
|
-
## Tóm tắt Figma
|
|
190
|
-
|
|
191
|
-
| Màn hình | Figma Frame (node-level) | Trạng thái Link / Fetch |
|
|
192
|
-
|------------|--------------------------|--------------------------------|
|
|
193
|
-
| {Màn hình 1} | [Link]({node-level url}) | ✅ Đã link & fetch |
|
|
194
|
-
| {Màn hình 2} | — | ❌ Missing — không có link node-id |
|
|
195
|
-
|
|
196
|
-
## Design Token đã tham chiếu
|
|
197
|
-
|
|
198
|
-
| Token | Value | Dùng ở |
|
|
199
|
-
|-------------------|----------|----------------------------|
|
|
200
|
-
| `color.primary` | {#hex} | Button, link |
|
|
201
|
-
| `spacing.md` | {16px} | Khoảng cách dọc tiêu chuẩn |
|
|
202
|
-
|
|
203
|
-
## Tài liệu tham khảo
|
|
204
|
-
|
|
205
|
-
- [{TICKET-ID}](./{TICKET-ID}-slug.md) — Business PRD
|
|
206
|
-
|
|
207
|
-
## Giả định AI
|
|
208
|
-
|
|
209
|
-
- {Giả định — [AI DRAFT]}
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Changelog
|
|
214
|
-
|
|
215
|
-
| Version | Date | Changes |
|
|
216
|
-
|---------|--------------|-----------------|
|
|
217
|
-
| 1.0 | {YYYY-MM-DD} | Initial version |
|