@rashidee/co2 1.2.5

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 (190) hide show
  1. package/dist/index.js +25449 -0
  2. package/drizzle/0000_remarkable_charles_xavier.sql +210 -0
  3. package/drizzle/0001_wise_wolf_cub.sql +13 -0
  4. package/drizzle/0002_secret_spyke.sql +16 -0
  5. package/drizzle/0003_workspace_config_singleton.sql +16 -0
  6. package/drizzle/0004_terminal_claim_v120.sql +11 -0
  7. package/drizzle/0005_brainstorm_v124.sql +10 -0
  8. package/drizzle/0006_project_v140.sql +6 -0
  9. package/drizzle/0007_prd_wizard_v124.sql +14 -0
  10. package/drizzle/0008_workflow_artifact_v126.sql +24 -0
  11. package/drizzle/0009_project_import_v150.sql +7 -0
  12. package/drizzle/0010_quality_v151.sql +3 -0
  13. package/drizzle/meta/0000_snapshot.json +1335 -0
  14. package/drizzle/meta/0001_snapshot.json +1416 -0
  15. package/drizzle/meta/0002_snapshot.json +1510 -0
  16. package/drizzle/meta/_journal.json +83 -0
  17. package/package.json +41 -0
  18. package/plugin/.claude-plugin/marketplace.json +36 -0
  19. package/plugin/.claude-plugin/plugin.json +22 -0
  20. package/plugin/README.md +625 -0
  21. package/plugin/SKILLS.md +350 -0
  22. package/plugin/co2.svg +5 -0
  23. package/plugin/commands/brainstorm-loop.md +129 -0
  24. package/plugin/skills/conductor-defect/SKILL.md +898 -0
  25. package/plugin/skills/conductor-feature-develop/SKILL.md +1383 -0
  26. package/plugin/skills/conductor-feature-develop/references/implementation-domain-template.md +131 -0
  27. package/plugin/skills/conductor-feature-develop/references/implementation-master-template.md +89 -0
  28. package/plugin/skills/conductor-feature-develop/references/playwright-setup.md +224 -0
  29. package/plugin/skills/conductor-feature-prepare/SKILL.md +604 -0
  30. package/plugin/skills/depgen-k8s/SKILL.md +468 -0
  31. package/plugin/skills/depgen-k8s/references/dockerfile-laravel.md +197 -0
  32. package/plugin/skills/depgen-k8s/references/dockerfile-nodejs.md +163 -0
  33. package/plugin/skills/depgen-k8s/references/dockerfile-spring-boot.md +174 -0
  34. package/plugin/skills/depgen-k8s/references/k8s-patterns.md +869 -0
  35. package/plugin/skills/mockgen-shadcn/SKILL.md +1067 -0
  36. package/plugin/skills/mockgen-shadcn/references/admin-layout-template.md +1467 -0
  37. package/plugin/skills/mockgen-shadcn/references/mockup-hub-template.md +498 -0
  38. package/plugin/skills/mockgen-shadcn/references/mockup-index-template.md +216 -0
  39. package/plugin/skills/mockgen-tailwind/SKILL.md +904 -0
  40. package/plugin/skills/mockgen-tailwind/references/admin-layout-template.md +720 -0
  41. package/plugin/skills/mockgen-tailwind/references/mockup-hub-template.md +498 -0
  42. package/plugin/skills/mockgen-tailwind/references/mockup-index-template.md +190 -0
  43. package/plugin/skills/modelgen-nosql/SKILL.md +617 -0
  44. package/plugin/skills/modelgen-nosql/references/model-extraction-methodology.md +497 -0
  45. package/plugin/skills/modelgen-nosql/references/nosql-design-guide.md +258 -0
  46. package/plugin/skills/modelgen-relational/SKILL.md +707 -0
  47. package/plugin/skills/modelgen-relational/references/model-extraction-methodology.md +499 -0
  48. package/plugin/skills/specgen-flutter-riverpod/SKILL.md +898 -0
  49. package/plugin/skills/specgen-flutter-riverpod/references/component-patterns.md +971 -0
  50. package/plugin/skills/specgen-flutter-riverpod/references/notification-patterns.md +457 -0
  51. package/plugin/skills/specgen-flutter-riverpod/references/routing-patterns.md +362 -0
  52. package/plugin/skills/specgen-flutter-riverpod/references/security-patterns.md +709 -0
  53. package/plugin/skills/specgen-flutter-riverpod/references/spec-template.md +1566 -0
  54. package/plugin/skills/specgen-flutter-riverpod/references/state-patterns.md +518 -0
  55. package/plugin/skills/specgen-flutter-riverpod/references/storage-patterns.md +370 -0
  56. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/SKILL.md +984 -0
  57. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/batch-patterns.md +359 -0
  58. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/messaging-patterns.md +468 -0
  59. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/modulith-patterns.md +461 -0
  60. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/reporting-patterns.md +803 -0
  61. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/security-patterns.md +501 -0
  62. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/spec-template.md +1268 -0
  63. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/web-patterns.md +301 -0
  64. package/plugin/skills/specgen-node-cli-web/SKILL.md +561 -0
  65. package/plugin/skills/specgen-node-cli-web/references/auth-patterns.md +293 -0
  66. package/plugin/skills/specgen-node-cli-web/references/cli-packaging-patterns.md +250 -0
  67. package/plugin/skills/specgen-node-cli-web/references/server-patterns.md +247 -0
  68. package/plugin/skills/specgen-node-cli-web/references/spec-template.md +401 -0
  69. package/plugin/skills/specgen-node-cli-web/references/testing-patterns.md +174 -0
  70. package/plugin/skills/specgen-react-mui/SKILL.md +789 -0
  71. package/plugin/skills/specgen-react-mui/references/component-patterns.md +1077 -0
  72. package/plugin/skills/specgen-react-mui/references/reporting-patterns.md +1998 -0
  73. package/plugin/skills/specgen-react-mui/references/routing-patterns.md +461 -0
  74. package/plugin/skills/specgen-react-mui/references/security-patterns.md +599 -0
  75. package/plugin/skills/specgen-react-mui/references/spec-template.md +1030 -0
  76. package/plugin/skills/specgen-react-mui/references/state-patterns.md +327 -0
  77. package/plugin/skills/specgen-react-tailwind/SKILL.md +859 -0
  78. package/plugin/skills/specgen-react-tailwind/references/component-patterns.md +1212 -0
  79. package/plugin/skills/specgen-react-tailwind/references/reporting-patterns.md +1529 -0
  80. package/plugin/skills/specgen-react-tailwind/references/routing-patterns.md +669 -0
  81. package/plugin/skills/specgen-react-tailwind/references/security-patterns.md +656 -0
  82. package/plugin/skills/specgen-react-tailwind/references/spec-template.md +1237 -0
  83. package/plugin/skills/specgen-react-tailwind/references/state-patterns.md +327 -0
  84. package/plugin/skills/specgen-sdk-java/SKILL.md +933 -0
  85. package/plugin/skills/specgen-sdk-java/references/api-extraction-patterns.md +247 -0
  86. package/plugin/skills/specgen-sdk-java/references/http-client-patterns.md +495 -0
  87. package/plugin/skills/specgen-sdk-java/references/packaging-patterns.md +366 -0
  88. package/plugin/skills/specgen-sdk-java/references/spec-template.md +956 -0
  89. package/plugin/skills/specgen-spring-jpa-jtehtmx/SKILL.md +1284 -0
  90. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/batch-patterns.md +1224 -0
  91. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/jasper-patterns.md +1638 -0
  92. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/messaging-patterns.md +512 -0
  93. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/modulith-patterns.md +354 -0
  94. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/security-patterns.md +551 -0
  95. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/spec-template.md +2502 -0
  96. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/web-patterns.md +503 -0
  97. package/plugin/skills/specgen-spring-jpa-restapi/SKILL.md +990 -0
  98. package/plugin/skills/specgen-spring-jpa-restapi/references/batch-patterns.md +1224 -0
  99. package/plugin/skills/specgen-spring-jpa-restapi/references/messaging-patterns.md +512 -0
  100. package/plugin/skills/specgen-spring-jpa-restapi/references/modulith-patterns.md +279 -0
  101. package/plugin/skills/specgen-spring-jpa-restapi/references/reporting-patterns.md +1536 -0
  102. package/plugin/skills/specgen-spring-jpa-restapi/references/restapi-patterns.md +722 -0
  103. package/plugin/skills/specgen-spring-jpa-restapi/references/security-patterns.md +351 -0
  104. package/plugin/skills/specgen-spring-jpa-restapi/references/spec-template.md +553 -0
  105. package/plugin/skills/specgen-ts-cli/SKILL.md +861 -0
  106. package/plugin/skills/specgen-ts-cli/references/async-patterns.md +1101 -0
  107. package/plugin/skills/specgen-ts-cli/references/command-patterns.md +383 -0
  108. package/plugin/skills/specgen-ts-cli/references/config-patterns.md +430 -0
  109. package/plugin/skills/specgen-ts-cli/references/database-patterns.md +750 -0
  110. package/plugin/skills/specgen-ts-cli/references/packaging-patterns.md +426 -0
  111. package/plugin/skills/specgen-ts-cli/references/spec-template.md +1391 -0
  112. package/plugin/skills/specgen-ts-cli/references/testing-patterns.md +909 -0
  113. package/plugin/skills/testgen-functional/SKILL.md +1381 -0
  114. package/plugin/skills/tracegen-matrix/SKILL.md +243 -0
  115. package/plugin/skills/util-preparek8senv/SKILL.md +422 -0
  116. package/plugin/skills/util-projectinit/SKILL.md +307 -0
  117. package/plugin/skills/util-projectinit/reference/brainstorm-loop.md +129 -0
  118. package/plugin/skills/util-projectinit/reference/brainstorm-protocol.md +144 -0
  119. package/plugin/skills/util-projectinit/reference/brainstorm-setup-guide.md +153 -0
  120. package/plugin/skills/util-projectinit/reference/brainstorm-template-appdev.md +87 -0
  121. package/plugin/skills/util-projectinit/reference/co2-context-generation-guide.md +761 -0
  122. package/plugin/skills/util-projectsync/SKILL.md +501 -0
  123. package/plugin/skills/util-updprd/SKILL.md +324 -0
  124. package/plugin/skills/util-usanalyzer/SKILL.md +307 -0
  125. package/plugin/skills/util-ustagger/SKILL.md +154 -0
  126. package/static/assets/abnfDiagram-VRR7QNED-DvPuwyCV.js +1 -0
  127. package/static/assets/arc-DRKw7sjs.js +1 -0
  128. package/static/assets/architectureDiagram-ZJ3FMSHR-CaNcxUbC.js +36 -0
  129. package/static/assets/blockDiagram-677ZJIJ3-Demd4AOK.js +132 -0
  130. package/static/assets/c4Diagram-LMCZKHZV-PVKUfc2x.js +10 -0
  131. package/static/assets/channel-C2nVbuwv.js +1 -0
  132. package/static/assets/chunk-2Q5K7J3B-CExf8ww_.js +1 -0
  133. package/static/assets/chunk-32BRIVSS-CFPaoONF.js +1 -0
  134. package/static/assets/chunk-5VM5RSS4-DE2esM67.js +15 -0
  135. package/static/assets/chunk-EX3LRPZG-SON_YdDG.js +231 -0
  136. package/static/assets/chunk-JWPE2WC7-Qxah8LNr.js +1 -0
  137. package/static/assets/chunk-MOJQB5TN-BcWGQV3j.js +88 -0
  138. package/static/assets/chunk-RYQCIY6F-DkDj-OR5.js +1 -0
  139. package/static/assets/chunk-V7JOEXUC-BlI1Mrah.js +206 -0
  140. package/static/assets/chunk-VR4S4FIN-Agf__duj.js +1 -0
  141. package/static/assets/chunk-XXDRQBXY-B5CfAh85.js +1 -0
  142. package/static/assets/classDiagram-OUVF2IWQ-DXJIljsR.js +1 -0
  143. package/static/assets/classDiagram-v2-EOCWNBFH-DXJIljsR.js +1 -0
  144. package/static/assets/cose-bilkent-JH36ORCC-DO0cQkcy.js +1 -0
  145. package/static/assets/cynefin-VYW2F7L2-CfOnsnXc.js +178 -0
  146. package/static/assets/cynefinDiagram-TSTJHNR4-BJ8tULAv.js +62 -0
  147. package/static/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
  148. package/static/assets/dagre-VKFMJZFB-DfjwzHqP.js +4 -0
  149. package/static/assets/defaultLocale-DX6XiGOO.js +1 -0
  150. package/static/assets/diagram-FQU43EPY-CndSOIIM.js +3 -0
  151. package/static/assets/diagram-G47NLZAW-Czf5hN0Z.js +24 -0
  152. package/static/assets/diagram-NH7WQ7WH-COAyojGh.js +24 -0
  153. package/static/assets/diagram-OA4YK3LP-H8PoiN2m.js +30 -0
  154. package/static/assets/diagram-WEI45ONY-DzcaVzjp.js +41 -0
  155. package/static/assets/ebnfDiagram-CCIWWBDH-DPazGYLJ.js +1 -0
  156. package/static/assets/erDiagram-Q63AITRT-Bo-fubgF.js +85 -0
  157. package/static/assets/flowDiagram-23GEKE2U-CSvxUDwh.js +156 -0
  158. package/static/assets/ganttDiagram-NO4QXBWP-DnBveWX6.js +292 -0
  159. package/static/assets/gitGraphDiagram-IHSO6WYX-B3rVL8c-.js +106 -0
  160. package/static/assets/graph-C9eacEi8.js +1 -0
  161. package/static/assets/index-LZSQkLE2.css +41 -0
  162. package/static/assets/index-y7XDSgMG.js +495 -0
  163. package/static/assets/infoDiagram-FWYZ7A6U-CvWV9yy2.js +2 -0
  164. package/static/assets/init-Gi6I4Gst.js +1 -0
  165. package/static/assets/ishikawaDiagram-FXEZZL3T-DF28a1N6.js +70 -0
  166. package/static/assets/journeyDiagram-5HDEW3XC-CB6CugYk.js +139 -0
  167. package/static/assets/kanban-definition-HUTT4EX6-ResSLF6d.js +89 -0
  168. package/static/assets/katex-C5jXJg4s.js +257 -0
  169. package/static/assets/layout-DEXfKzaS.js +1 -0
  170. package/static/assets/linear-CLO--ryk.js +1 -0
  171. package/static/assets/map-Czzmt4hB.js +1 -0
  172. package/static/assets/mindmap-definition-LN4V7U3C-BvW3EbxX.js +96 -0
  173. package/static/assets/ordinal-Cboi1Yqb.js +1 -0
  174. package/static/assets/pegDiagram-2B236MQR-BHCgqrrM.js +1 -0
  175. package/static/assets/pieDiagram-ENE6RG2P-DVmCQ5FA.js +39 -0
  176. package/static/assets/quadrantDiagram-ABIIQ3AL-B3e5KR52.js +7 -0
  177. package/static/assets/railroadDiagram-RFXS5EU6-Csv5ysLc.js +1 -0
  178. package/static/assets/requirementDiagram-TGXJPOKE-DOMVzvnB.js +84 -0
  179. package/static/assets/sankeyDiagram-HTMAVEWB-B1dcTOvy.js +40 -0
  180. package/static/assets/sequenceDiagram-DBY2YBRQ-BY414yeO.js +162 -0
  181. package/static/assets/sizeCapture-X5ZJPWSS-CuJfrfBN.js +1 -0
  182. package/static/assets/stateDiagram-2N3HPSRC-FX4rJkzV.js +1 -0
  183. package/static/assets/stateDiagram-v2-6OUMAXLB-BVufbO_H.js +1 -0
  184. package/static/assets/swimlanes-5IMT3BWC-Sfy58mmv.js +2 -0
  185. package/static/assets/swimlanesDiagram-G3AALYLV-wDCDw08H.js +8 -0
  186. package/static/assets/timeline-definition-FHXFAJF6-CmV7by8p.js +120 -0
  187. package/static/assets/vennDiagram-L72KCM5P-FqIyFZFt.js +34 -0
  188. package/static/assets/wardleyDiagram-EHGQE667-BZ06O45i.js +78 -0
  189. package/static/assets/xychartDiagram-FW5EYKEG-BOkffR06.js +7 -0
  190. package/static/index.html +24 -0
@@ -0,0 +1,1030 @@
1
+ # Specification Template — React SPA with MUI
2
+
3
+ This is the authoritative template for the generated specification. The specification is
4
+ split into **two types of files**:
5
+
6
+ 1. **`SPECIFICATION.md`** (root) — Table of Contents, shared infrastructure, and all
7
+ application-level sections. Generated once per application.
8
+ 2. **`<module>/SPEC.md`** (per-module) — Self-contained module blueprint.
9
+ Generated once per module from PRD.md.
10
+
11
+ ```
12
+ spec/
13
+ ├── SPECIFICATION.md
14
+ ├── hero-section/
15
+ │ └── SPEC.md
16
+ ├── product-service/
17
+ │ └── SPEC.md
18
+ └── ...
19
+ ```
20
+
21
+ Placeholders use `{{VARIABLE}}` syntax and must be replaced with actual values gathered
22
+ from context files.
23
+
24
+ Sections marked **[CONDITIONAL]** should only be included when the corresponding
25
+ integration is selected.
26
+
27
+ **CRITICAL: Sample code requirement.** Every component in the spec MUST include a
28
+ complete, continuous code sample in a fenced code block (TypeScript, TSX, or JSON as
29
+ appropriate). The code must be self-explanatory and directly usable as a reference for
30
+ a coding agent. Do not describe components with bullet points alone — always accompany
31
+ descriptions with full code.
32
+
33
+ ---
34
+
35
+ # Part A: Root SPECIFICATION.md
36
+
37
+ ---
38
+
39
+ ## Table of Contents
40
+
41
+ Generate a TOC with clickable Markdown anchor links to every H2 and H3 section.
42
+ Additionally, include a **Modules** section in the TOC that links to each module's
43
+ `SPEC.md` file:
44
+
45
+ ```markdown
46
+ ## Table of Contents
47
+
48
+ ### Shared Infrastructure
49
+ - [1. Project Overview](#1-project-overview)
50
+ - [2. Package Configuration](#2-package-configuration)
51
+ - ...all shared sections...
52
+
53
+ ### Modules
54
+ - [Hero Section](hero-section/SPEC.md)
55
+ - [Product and Service](product-service/SPEC.md)
56
+ - [Blog](blog/SPEC.md)
57
+ - ...(one link per module)...
58
+ ```
59
+
60
+ Only include conditional sections that apply based on determined selections.
61
+
62
+ ---
63
+
64
+ ## Section 1: Project Overview
65
+
66
+ ```
67
+ # {{APPLICATION_NAME}} — Technical Specification
68
+
69
+ ## 1. Project Overview
70
+
71
+ **Application Name**: {{APPLICATION_NAME}}
72
+ **Project Slug**: {{PROJECT_SLUG}}
73
+ **App Title**: {{APP_TITLE}}
74
+ **Framework**: React SPA
75
+ **Description**: {{APP_DESCRIPTION}}
76
+ **Versions Covered**: v1.0.0 — v{{LATEST_VERSION}}
77
+
78
+ ### Optional Components (Auto-Determined)
79
+ **Backend API Base URL**: {{API_BASE_URL}}
80
+ **Authentication**: {{AUTH_TYPE}}
81
+ **DataGrid**: {{DATAGRID}}
82
+ **Charts**: {{CHARTS}}
83
+ **DatePickers**: {{DATE_PICKERS}}
84
+ **WebSocket**: {{WEBSOCKET}}
85
+ **i18n**: {{I18N}}
86
+ **RichText**: {{RICH_TEXT}}
87
+
88
+ ### Technology Stack
89
+ (Render the core stack version table from SKILL.md, plus selected optional integration versions)
90
+
91
+ ### User Roles
92
+ (List each user role extracted from mockup role folders, with role constant and access scope.)
93
+
94
+ | Role | Description | Constant | Accessible Modules |
95
+ |------|-------------|----------|-------------------|
96
+ | Administrator | Full system access | `ADMIN` | All modules |
97
+ | Editor | Content management | `EDITOR` | Hero Section, Blog, ... |
98
+
99
+ ### Modules
100
+ (List each module from PRD.md, with type and link to its SPEC.md.)
101
+
102
+ | Module | Type | Stories | Versions | Spec |
103
+ |--------|------|---------|----------|------|
104
+ | Hero Section | Business | 3 | 1.0.0, 1.0.4 | [SPEC](hero-section/SPEC.md) |
105
+ | Blog | Business | 5 | 1.0.0 | [SPEC](blog/SPEC.md) |
106
+
107
+ ### Input Sources
108
+ - CLAUDE.md: {{path}}
109
+ - PRD.md: {{path}}
110
+ - Module Model: {{path to MODEL.md}}
111
+ - Mockup Screens: {{path to MOCKUP.html}}
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Section 2: Package Configuration
117
+
118
+ ### 2.1 package.json
119
+
120
+ Generate a complete `package.json` inside a code block. Include all core and
121
+ conditional dependencies based on the determined selections.
122
+
123
+ ```json
124
+ {
125
+ "name": "{{PROJECT_SLUG}}",
126
+ "version": "1.0.0",
127
+ "private": true,
128
+ "type": "module",
129
+ "scripts": {
130
+ "dev": "vite",
131
+ "build": "tsc -b && vite build",
132
+ "preview": "vite preview",
133
+ "lint": "eslint .",
134
+ "type-check": "tsc --noEmit"
135
+ },
136
+ "dependencies": {
137
+ "react": "^19.0.0",
138
+ "react-dom": "^19.0.0",
139
+ "@mui/material": "^6.0.0",
140
+ "@mui/icons-material": "^6.0.0",
141
+ "@emotion/react": "^11.0.0",
142
+ "@emotion/styled": "^11.0.0",
143
+ "react-router-dom": "^7.0.0",
144
+ "@tanstack/react-query": "^5.0.0",
145
+ "zustand": "^5.0.0",
146
+ "react-hook-form": "^7.0.0",
147
+ "@hookform/resolvers": "^3.0.0",
148
+ "zod": "^3.0.0",
149
+ "axios": "^1.0.0"
150
+ },
151
+ "devDependencies": {
152
+ "typescript": "^5.0.0",
153
+ "@types/react": "^19.0.0",
154
+ "@types/react-dom": "^19.0.0",
155
+ "vite": "^6.0.0",
156
+ "@vitejs/plugin-react": "^4.0.0",
157
+ "@tanstack/react-query-devtools": "^5.0.0",
158
+ "eslint": "^9.0.0",
159
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
160
+ "@typescript-eslint/parser": "^8.0.0"
161
+ }
162
+ }
163
+ ```
164
+
165
+ Include conditional dependencies as annotated comments in the final output.
166
+
167
+ ### 2.2 vite.config.ts
168
+
169
+ ```typescript
170
+ import { defineConfig } from 'vite';
171
+ import react from '@vitejs/plugin-react';
172
+ import path from 'path';
173
+
174
+ export default defineConfig({
175
+ plugins: [react()],
176
+ resolve: {
177
+ alias: {
178
+ '@': path.resolve(__dirname, './src'),
179
+ },
180
+ },
181
+ server: {
182
+ port: {{DEV_PORT}},
183
+ proxy: {
184
+ '/api': {
185
+ target: '{{API_BASE_URL_DEV}}',
186
+ changeOrigin: true,
187
+ rewrite: (path) => path.replace(/^\/api/, ''),
188
+ },
189
+ },
190
+ },
191
+ });
192
+ ```
193
+
194
+ ### 2.3 tsconfig.json
195
+
196
+ ```json
197
+ {
198
+ "compilerOptions": {
199
+ "target": "ES2020",
200
+ "useDefineForClassFields": true,
201
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
202
+ "module": "ESNext",
203
+ "skipLibCheck": true,
204
+ "moduleResolution": "bundler",
205
+ "allowImportingTsExtensions": true,
206
+ "isolatedModules": true,
207
+ "moduleDetection": "force",
208
+ "noEmit": true,
209
+ "jsx": "react-jsx",
210
+ "strict": true,
211
+ "noUnusedLocals": true,
212
+ "noUnusedParameters": true,
213
+ "noFallthroughCasesInSwitch": true,
214
+ "baseUrl": ".",
215
+ "paths": {
216
+ "@/*": ["./src/*"]
217
+ }
218
+ },
219
+ "include": ["src"],
220
+ "references": [{ "path": "./tsconfig.node.json" }]
221
+ }
222
+ ```
223
+
224
+ ### 2.4 Environment Variables
225
+
226
+ ```env
227
+ # .env.development
228
+ VITE_APP_TITLE={{APP_TITLE}}
229
+ VITE_API_BASE_URL={{API_BASE_URL_DEV}}
230
+
231
+ # [If Auth = Keycloak]
232
+ VITE_KEYCLOAK_AUTHORITY=http://localhost:8180/realms/{{KEYCLOAK_REALM}}
233
+ VITE_KEYCLOAK_CLIENT_ID={{KEYCLOAK_CLIENT_ID}}
234
+ VITE_KEYCLOAK_REDIRECT_URI=http://localhost:{{DEV_PORT}}/auth/callback
235
+ VITE_KEYCLOAK_POST_LOGOUT_REDIRECT_URI=http://localhost:{{DEV_PORT}}
236
+ VITE_KEYCLOAK_SCOPE=openid profile email
237
+ ```
238
+
239
+ ```env
240
+ # .env.production
241
+ VITE_APP_TITLE={{APP_TITLE}}
242
+ VITE_API_BASE_URL=${API_BASE_URL}
243
+
244
+ # [If Auth = Keycloak]
245
+ VITE_KEYCLOAK_AUTHORITY=${KEYCLOAK_AUTHORITY}
246
+ VITE_KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID}
247
+ VITE_KEYCLOAK_REDIRECT_URI=${APP_URL}/auth/callback
248
+ VITE_KEYCLOAK_POST_LOGOUT_REDIRECT_URI=${APP_URL}
249
+ VITE_KEYCLOAK_SCOPE=openid profile email
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Section 3: Application Configuration
255
+
256
+ ### 3.1 .gitignore
257
+
258
+ ```gitignore
259
+ # Build output
260
+ dist/
261
+ dist-ssr/
262
+
263
+ # Dependencies
264
+ node_modules/
265
+
266
+ # IDE
267
+ .idea/
268
+ *.iml
269
+ .vscode/
270
+ *.swp
271
+ *~
272
+
273
+ # OS
274
+ .DS_Store
275
+ Thumbs.db
276
+
277
+ # Environment (never commit secrets)
278
+ .env
279
+ .env.local
280
+ .env.production
281
+ .env.*.local
282
+
283
+ # TypeScript
284
+ *.tsbuildinfo
285
+
286
+ # Logs
287
+ *.log
288
+ npm-debug.log*
289
+ yarn-debug.log*
290
+ pnpm-debug.log*
291
+
292
+ # Testing
293
+ coverage/
294
+ playwright-report/
295
+ test-results/
296
+ e2e/node_modules/
297
+ ```
298
+
299
+ ### 3.2 Environment Type Declarations
300
+
301
+ ```typescript
302
+ // src/types/global.d.ts
303
+
304
+ /// <reference types="vite/client" />
305
+
306
+ interface ImportMetaEnv {
307
+ readonly VITE_APP_TITLE: string;
308
+ readonly VITE_API_BASE_URL: string;
309
+ // [If Auth = Keycloak]
310
+ readonly VITE_KEYCLOAK_AUTHORITY: string;
311
+ readonly VITE_KEYCLOAK_CLIENT_ID: string;
312
+ readonly VITE_KEYCLOAK_REDIRECT_URI: string;
313
+ readonly VITE_KEYCLOAK_POST_LOGOUT_REDIRECT_URI: string;
314
+ readonly VITE_KEYCLOAK_SCOPE: string;
315
+ }
316
+
317
+ interface ImportMeta {
318
+ readonly env: ImportMetaEnv;
319
+ }
320
+ ```
321
+
322
+ ---
323
+
324
+ ## Section 4: Directory Structure
325
+
326
+ Generate the full `src/` directory tree. Use actual module names from PRD.md and MODEL.md.
327
+ Follow the feature-based structure from `references/routing-patterns.md`.
328
+
329
+ ```
330
+ src/
331
+ ├── main.tsx
332
+ ├── App.tsx
333
+ ├── router/
334
+ │ └── index.tsx
335
+ ├── lib/
336
+ │ ├── api/
337
+ │ │ ├── axiosInstance.ts
338
+ │ │ └── [If Auth = Keycloak] authBridge.ts
339
+ │ ├── auth/
340
+ │ │ ├── [If Auth = Keycloak] oidcConfig.ts
341
+ │ │ ├── [If Auth = Keycloak] keycloakRoles.ts
342
+ │ │ ├── [If Auth = Keycloak] useAuthUser.ts
343
+ │ │ └── roles.ts
344
+ │ └── queryClient.ts
345
+ ├── store/
346
+ │ ├── [If Auth = Local] auth.store.ts
347
+ │ ├── notification.store.ts
348
+ │ └── ui.store.ts
349
+ ├── shared/
350
+ │ ├── layouts/
351
+ │ │ ├── DashboardLayout.tsx
352
+ │ │ ├── PublicLayout.tsx
353
+ │ │ └── AuthLayout.tsx
354
+ │ ├── components/
355
+ │ │ ├── ProtectedRoute.tsx
356
+ │ │ ├── AppTopBar.tsx
357
+ │ │ ├── AppSidebar.tsx
358
+ │ │ ├── navigationConfig.ts
359
+ │ │ ├── PageHeader.tsx
360
+ │ │ ├── DataTable.tsx
361
+ │ │ ├── ConfirmDialog.tsx
362
+ │ │ ├── StatusChip.tsx
363
+ │ │ ├── FormDialog.tsx
364
+ │ │ ├── ImageUpload.tsx
365
+ │ │ ├── LoadingOverlay.tsx
366
+ │ │ ├── EmptyState.tsx
367
+ │ │ ├── ErrorBoundary.tsx
368
+ │ │ ├── NotificationProvider.tsx
369
+ │ │ └── SearchInput.tsx
370
+ │ ├── hooks/
371
+ │ │ ├── useDebounce.ts
372
+ │ │ ├── useNotification.ts
373
+ │ │ └── useConfirm.ts
374
+ │ └── form/
375
+ │ ├── TextFieldController.tsx
376
+ │ ├── SelectController.tsx
377
+ │ ├── DatePickerController.tsx
378
+ │ ├── SwitchController.tsx
379
+ │ ├── AutocompleteController.tsx
380
+ │ └── [If RichText = yes] RichTextController.tsx
381
+ ├── features/
382
+ │ ├── auth/
383
+ │ │ ├── pages/
384
+ │ │ │ ├── [If Auth = Keycloak] AuthCallbackPage.tsx
385
+ │ │ │ └── [If Auth = Local] LoginPage.tsx
386
+ │ │ └── index.ts
387
+ │ ├── dashboard/
388
+ │ │ ├── pages/
389
+ │ │ │ └── DashboardPage.tsx
390
+ │ │ └── index.ts
391
+ │ ├── {{module1}}/ ← Replace with actual module names
392
+ │ │ ├── api/
393
+ │ │ │ └── {{module1}}Api.ts
394
+ │ │ ├── components/
395
+ │ │ ├── hooks/
396
+ │ │ ├── pages/
397
+ │ │ ├── {{module1}}.types.ts
398
+ │ │ ├── {{module1}}.schema.ts
399
+ │ │ └── index.ts
400
+ │ └── {{module2}}/
401
+ │ └── (same structure)
402
+ ├── theme/
403
+ │ ├── index.ts
404
+ │ ├── palette.ts
405
+ │ └── typography.ts
406
+ └── types/
407
+ └── global.d.ts
408
+ ```
409
+
410
+ ---
411
+
412
+ ## Section 5: MUI Theme Configuration
413
+
414
+ Generate the complete MUI theme using design tokens extracted from MOCKUP.html.
415
+ Reference `references/component-patterns.md` for the theme setup pattern.
416
+
417
+ Include:
418
+ - `src/theme/palette.ts` — color palette with actual hex values from mockup
419
+ - `src/theme/typography.ts` — font family and size scale from mockup
420
+ - `src/theme/index.ts` — `createTheme()` with `lightTheme` and `darkTheme` exports,
421
+ MUI component overrides (Button, Card, TextField, etc.)
422
+ - Design token mapping table showing mockup CSS property → MUI theme property
423
+
424
+ **App.tsx integration:**
425
+
426
+ ```tsx
427
+ // src/App.tsx
428
+ import { useMemo } from 'react';
429
+ import { ThemeProvider, CssBaseline } from '@mui/material';
430
+ import { RouterProvider } from 'react-router-dom';
431
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
432
+ import { lightTheme, darkTheme } from './theme';
433
+ import { useUiStore } from './store/ui.store';
434
+ import { router } from './router';
435
+ import { NotificationProvider } from './shared/components/NotificationProvider';
436
+ import { ConfirmDialog } from './shared/components/ConfirmDialog';
437
+ // [If Auth = Keycloak]
438
+ import { useAuth } from 'react-oidc-context';
439
+ import { useEffect } from 'react';
440
+ import { setAuthUser } from './lib/api/authBridge';
441
+
442
+ export function App() {
443
+ const { themeMode } = useUiStore();
444
+ const theme = useMemo(
445
+ () => (themeMode === 'dark' ? darkTheme : lightTheme),
446
+ [themeMode],
447
+ );
448
+
449
+ // [If Auth = Keycloak] Keep the auth bridge in sync
450
+ // const auth = useAuth();
451
+ // useEffect(() => { setAuthUser(auth.user ?? null); }, [auth.user]);
452
+
453
+ return (
454
+ <ThemeProvider theme={theme}>
455
+ <CssBaseline />
456
+ <RouterProvider router={router} />
457
+ <NotificationProvider />
458
+ <ConfirmDialog />
459
+ <ReactQueryDevtools initialIsOpen={false} />
460
+ </ThemeProvider>
461
+ );
462
+ }
463
+ ```
464
+
465
+ ---
466
+
467
+ ## Section 6: Authentication Configuration [CONDITIONAL — Include only if Auth != none]
468
+
469
+ **[If Auth = Keycloak]:**
470
+ Refer to `references/security-patterns.md` for the complete content.
471
+ Must cover:
472
+ - `src/lib/auth/oidcConfig.ts` — OIDC configuration object
473
+ - `src/lib/auth/keycloakRoles.ts` — role extraction utilities
474
+ - `src/lib/auth/useAuthUser.ts` — typed auth hook
475
+ - `src/lib/auth/roles.ts` — role constants
476
+ - `src/lib/api/authBridge.ts` — bridge for Axios interceptor
477
+ - `src/shared/components/ProtectedRoute.tsx` — route guard component
478
+ - `src/features/auth/pages/AuthCallbackPage.tsx` — OIDC callback handler
479
+ - main.tsx integration with `AuthProvider`
480
+ - Axios interceptor that injects Bearer token
481
+
482
+ **[If Auth = Local]:**
483
+ Refer to `references/security-patterns.md` (Local JWT section) for the complete content.
484
+ Must cover:
485
+ - `src/store/auth.store.ts` — Zustand auth store with login/logout/token management
486
+ - `src/lib/api/axiosInstance.ts` — interceptor reads token from Zustand store
487
+ - Token refresh interceptor for 401 handling
488
+ - `src/shared/components/ProtectedRoute.tsx` — redirects to /login
489
+ - `src/features/auth/pages/LoginPage.tsx` — email/password form with RHF + Zod
490
+ - `src/lib/auth/roles.ts` — role constants
491
+
492
+ ---
493
+
494
+ ## Section 7: Router Configuration
495
+
496
+ Refer to `references/routing-patterns.md` for the complete route tree.
497
+ Must cover:
498
+ - `src/router/index.tsx` — complete `createBrowserRouter()` with ALL routes from PRD.md
499
+ - Lazy loading via `React.lazy()` for every page component
500
+ - `<Suspense>` with `<LoadingOverlay />` fallback
501
+ - `<ProtectedRoute>` wrappers with `requiredRoles` matching the mockup role folders
502
+ - Public routes (login, callback, 404)
503
+ - The exact module-based URL paths (e.g., `/hero-section`, NOT `/admin/hero-section`)
504
+
505
+ ---
506
+
507
+ ## Section 8: API Client Configuration
508
+
509
+ ```typescript
510
+ // src/lib/api/axiosInstance.ts
511
+ import axios from 'axios';
512
+
513
+ export const axiosInstance = axios.create({
514
+ baseURL: import.meta.env.VITE_API_BASE_URL,
515
+ timeout: 30_000,
516
+ headers: { 'Content-Type': 'application/json' },
517
+ // [If Auth = Local] withCredentials: true, // for httpOnly refresh token cookie
518
+ });
519
+
520
+ // Auth interceptor — see Section 6 for implementation
521
+ // Error interceptor — see below
522
+ axiosInstance.interceptors.response.use(
523
+ (response) => response,
524
+ (error) => {
525
+ if (axios.isAxiosError(error)) {
526
+ const status = error.response?.status;
527
+ const message =
528
+ (error.response?.data as { message?: string })?.message ??
529
+ error.message ??
530
+ 'An unexpected error occurred';
531
+
532
+ // Global error notifications for non-401 errors
533
+ // (401 handled by the auth interceptor)
534
+ if (status && status !== 401) {
535
+ // Imported lazily to avoid circular dependency with Zustand store
536
+ import('../store/notification.store').then(({ useNotificationStore }) => {
537
+ useNotificationStore.getState().push('error', message);
538
+ });
539
+ }
540
+ }
541
+ return Promise.reject(error);
542
+ },
543
+ );
544
+ ```
545
+
546
+ ---
547
+
548
+ ## Section 9: Global State (Zustand)
549
+
550
+ Describe and provide code for:
551
+ - `src/store/notification.store.ts` — toast notification queue
552
+ - `src/store/ui.store.ts` — sidebar open/closed, theme mode
553
+ - [If Auth = Local] `src/store/auth.store.ts` — auth state and actions
554
+
555
+ Reference `references/component-patterns.md` for the full store implementations.
556
+
557
+ ---
558
+
559
+ ## Section 10: TanStack Query Setup
560
+
561
+ ```typescript
562
+ // src/lib/queryClient.ts
563
+ // Full implementation from references/component-patterns.md
564
+ ```
565
+
566
+ Describe:
567
+ - `QueryClient` configuration (staleTime, gcTime, retry policy)
568
+ - `QueryClientProvider` in `main.tsx`
569
+ - `ReactQueryDevtools` in `App.tsx` (dev mode only)
570
+ - Query key factory pattern (object with `all`, `lists`, `list(params)`, `detail(id)`)
571
+ - Naming convention: `use{Entity}s` for list queries, `use{Entity}` for single queries,
572
+ `use{Entity}Mutations` for all CUD mutations of a feature
573
+
574
+ ---
575
+
576
+ ## Section 11: Shared Layouts
577
+
578
+ For each layout, provide:
579
+ 1. The TypeScript props interface
580
+ 2. The complete TSX component
581
+
582
+ - **DashboardLayout**: MUI `Box` + `Drawer` sidebar + `AppBar` topbar + `Outlet`
583
+ from `references/routing-patterns.md`
584
+ - **PublicLayout**: Minimal layout for landing/public pages
585
+ - **AuthLayout**: Centered `Paper` card for login/callback pages
586
+
587
+ ---
588
+
589
+ ## Section 12: Shared Components
590
+
591
+ For each shared component, provide the TypeScript props interface and complete TSX.
592
+ Reference `references/component-patterns.md` for implementations.
593
+
594
+ | Component | Purpose |
595
+ |---|---|
596
+ | `ProtectedRoute` | Auth + role guard |
597
+ | `AppTopBar` | Fixed MUI AppBar with sidebar toggle, user avatar, theme toggle |
598
+ | `AppSidebar` | MUI Drawer with role-filtered navigation items |
599
+ | `navigationConfig.ts` | Navigation item definitions with role requirements |
600
+ | `PageHeader` | Page title + breadcrumbs + action buttons area |
601
+ | `StatusChip` | Colored MUI Chip for enum status values |
602
+ | `ConfirmDialog` + `useConfirm` | Imperative confirmation dialog |
603
+ | `LoadingOverlay` | Full-page MUI CircularProgress |
604
+ | `EmptyState` | Empty list placeholder with icon and message |
605
+ | `ErrorBoundary` | React ErrorBoundary with MUI fallback UI |
606
+ | `NotificationProvider` | Stacked MUI Snackbar/Alert toast renderer |
607
+ | `ImageUpload` | Drag-and-drop file input with image preview |
608
+
609
+ ---
610
+
611
+ ## Section 13: Navigation Configuration
612
+
613
+ Generate `src/shared/components/navigationConfig.ts` with the actual navigation items
614
+ from the mockup sidebar files. For each role:
615
+ - List all nav items that role can see
616
+ - Include MUI icon imports (use appropriate icons from `@mui/icons-material`)
617
+ - Sidebar hrefs use module-based paths only (e.g., `/hero-section`, `/users`)
618
+
619
+ ---
620
+
621
+ ## Section 14: Form Infrastructure
622
+
623
+ Reference `references/component-patterns.md` for the complete RHF controller components.
624
+ Describe:
625
+ - `useForm()` + `zodResolver()` usage pattern
626
+ - All `*Controller` components with full TypeScript generics
627
+ - Form reset pattern for edit modes (`reset(data)` in `useEffect`)
628
+ - Loading state on submit button (MUI `loading` prop on `Button`)
629
+
630
+ ---
631
+
632
+ ## Section 15: Error Handling Strategy
633
+
634
+ Describe:
635
+ - `ErrorBoundary` component wrapping the router outlet
636
+ - Axios response interceptor for API errors (already in Section 8)
637
+ - Zod error message extraction utility
638
+ - TanStack Query `mutation.error` → displayed in form via `useEffect`
639
+
640
+ ```typescript
641
+ // src/lib/utils/zodErrors.ts
642
+
643
+ import type { ZodError } from 'zod';
644
+
645
+ /**
646
+ * Extract a flat error message from a Zod error or generic Error.
647
+ */
648
+ export function extractErrorMessage(error: unknown): string {
649
+ if (error instanceof Error) return error.message;
650
+ if (typeof error === 'string') return error;
651
+ return 'An unexpected error occurred';
652
+ }
653
+
654
+ /**
655
+ * Map Zod field errors to React Hook Form setError calls.
656
+ */
657
+ export function mapZodErrorsToForm<T extends Record<string, unknown>>(
658
+ error: ZodError,
659
+ setError: (field: keyof T, error: { message: string }) => void,
660
+ ): void {
661
+ for (const issue of error.issues) {
662
+ const field = issue.path[0] as keyof T;
663
+ if (field) {
664
+ setError(field, { message: issue.message });
665
+ }
666
+ }
667
+ }
668
+ ```
669
+
670
+ ---
671
+
672
+ ## Section 16: Notification System
673
+
674
+ Reference `references/component-patterns.md` for:
675
+ - `src/store/notification.store.ts` — full Zustand store
676
+ - `src/shared/components/NotificationProvider.tsx` — MUI Snackbar stack renderer
677
+ - Usage: `useNotificationStore().push('success', 'Item saved.')` from any component or
678
+ mutation `onSuccess`/`onError` callback
679
+
680
+ ---
681
+
682
+ ## Section 17: Theming & Dark Mode
683
+
684
+ ```typescript
685
+ // src/shared/components/AppTopBar.tsx (theme toggle example)
686
+ import { IconButton } from '@mui/material';
687
+ import Brightness4Icon from '@mui/icons-material/Brightness4';
688
+ import Brightness7Icon from '@mui/icons-material/Brightness7';
689
+ import { useUiStore } from '../../store/ui.store';
690
+
691
+ export function ThemeToggle() {
692
+ const { themeMode, toggleThemeMode } = useUiStore();
693
+
694
+ return (
695
+ <IconButton onClick={toggleThemeMode} color="inherit">
696
+ {themeMode === 'dark' ? <Brightness7Icon /> : <Brightness4Icon />}
697
+ </IconButton>
698
+ );
699
+ }
700
+ ```
701
+
702
+ ---
703
+
704
+ ## Section 18: Testing Strategy
705
+
706
+ Overview only — detailed per-feature test patterns in each module's SPEC.md.
707
+
708
+ - **Vitest + React Testing Library**: Unit tests for hooks and components
709
+ - **MSW (Mock Service Worker)**: API mocking for integration tests
710
+ - **Playwright**: E2E test scripts per CO2 workflow
711
+
712
+ ```bash
713
+ # Add to package.json devDependencies:
714
+ # "vitest": "^2.0.0"
715
+ # "@testing-library/react": "^16.0.0"
716
+ # "@testing-library/user-event": "^14.0.0"
717
+ # "msw": "^2.0.0"
718
+ # "jsdom": "^25.0.0"
719
+ ```
720
+
721
+ ---
722
+
723
+ ## Section 19: Build & Deployment
724
+
725
+ ### Vite Build
726
+
727
+ ```bash
728
+ npm run build
729
+ # Output: dist/ — static files ready for deployment
730
+ ```
731
+
732
+ ### nginx Configuration (SPA Routing)
733
+
734
+ ```nginx
735
+ server {
736
+ listen 80;
737
+ root /usr/share/nginx/html;
738
+ index index.html;
739
+
740
+ # All routes fall back to index.html for client-side routing
741
+ location / {
742
+ try_files $uri $uri/ /index.html;
743
+ }
744
+
745
+ # Static assets — cache aggressively (Vite hashes filenames)
746
+ location /assets/ {
747
+ expires 1y;
748
+ add_header Cache-Control "public, immutable";
749
+ }
750
+ }
751
+ ```
752
+
753
+ ### Chunk Splitting (vite.config.ts)
754
+
755
+ ```typescript
756
+ // Optimised chunk splitting — add to build.rollupOptions
757
+ rollupOptions: {
758
+ output: {
759
+ manualChunks: {
760
+ vendor: ['react', 'react-dom', 'react-router-dom'],
761
+ mui: ['@mui/material', '@mui/icons-material', '@emotion/react', '@emotion/styled'],
762
+ query: ['@tanstack/react-query', 'axios'],
763
+ forms: ['react-hook-form', '@hookform/resolvers', 'zod'],
764
+ zustand: ['zustand'],
765
+ },
766
+ },
767
+ },
768
+ ```
769
+
770
+ ---
771
+
772
+ ## Section 20: Internationalisation [CONDITIONAL — Include only if i18n = yes]
773
+
774
+ ```typescript
775
+ // src/lib/i18n.ts
776
+ import i18n from 'i18next';
777
+ import { initReactI18next } from 'react-i18next';
778
+ import LanguageDetector from 'i18next-browser-languagedetector';
779
+ import HttpBackend from 'i18next-http-backend';
780
+
781
+ i18n
782
+ .use(HttpBackend)
783
+ .use(LanguageDetector)
784
+ .use(initReactI18next)
785
+ .init({
786
+ fallbackLng: 'en',
787
+ ns: ['common'],
788
+ defaultNS: 'common',
789
+ backend: {
790
+ loadPath: '/locales/{{lng}}/{{ns}}.json',
791
+ },
792
+ interpolation: { escapeValue: false },
793
+ });
794
+
795
+ export default i18n;
796
+ ```
797
+
798
+ ---
799
+
800
+ # Part B: Per-Module SPEC.md Template
801
+
802
+ Each module from PRD.md and MODEL.md gets its own `<module-name>/SPEC.md` file.
803
+
804
+ ---
805
+
806
+ ## Module SPEC.md Structure
807
+
808
+ ```markdown
809
+ # {{ModuleName}} — Module Specification
810
+
811
+ > Part of [{{APPLICATION_NAME}} Technical Specification](../SPECIFICATION.md)
812
+
813
+ ## Overview
814
+
815
+ **Module:** {{ModuleName}}
816
+ **Feature Path:** `src/features/{{moduleName}}/`
817
+ **Type:** {{System Module | Business Module}}
818
+ **Backend Endpoint Base:** `/{{api-path}}` (inferred from model/API context)
819
+ ```
820
+
821
+ ---
822
+
823
+ ### Traceability
824
+
825
+ ```markdown
826
+ ## Traceability
827
+
828
+ ### User Stories
829
+ | ID | Version | Description |
830
+ |---|---|---|
831
+ | USA000030 | v1.0.0 | Create/update hero section content |
832
+ | USA000033 | v1.0.0 | View list of hero section content |
833
+
834
+ ### Non-Functional Requirements
835
+ | ID | Version | Description |
836
+ |---|---|---|
837
+ | NFRA00021 | v1.0.0 | Image must be exactly 1600x500 pixels |
838
+ | NFRA00024 | v1.0.0 | Headline max 100 characters |
839
+
840
+ ### Constraints
841
+ | ID | Version | Description |
842
+ |---|---|---|
843
+ | CONSA0012 | v1.0.0 | Status values: DRAFT, ACTIVE, EXPIRED |
844
+
845
+ ### Removed / Replaced
846
+ | ID | Removed In | Replaced By | Reason |
847
+ |---|---|---|---|
848
+ | CONSA0012 (READY status) | v1.0.4 | — | Auto-computed status; READY removed |
849
+ _or "None." if no removals_
850
+
851
+ ### Data Sources
852
+ | Artifact | Reference |
853
+ |---|---|
854
+ | DB Table | `hero_section` |
855
+ | Mockup Screen | `admin/content/hero_section.html` |
856
+ ```
857
+
858
+ ---
859
+
860
+ ### TypeScript Types
861
+
862
+ ```markdown
863
+ ## TypeScript Types
864
+
865
+ File: `src/features/heroSection/heroSection.types.ts`
866
+
867
+ (Complete TypeScript interfaces and enums — field-for-field from MODEL.md)
868
+ ```
869
+
870
+ All enum values must match PRD.md constraints exactly (e.g., status DRAFT/ACTIVE/EXPIRED).
871
+ Include the generic `PaginatedResponse<T>` type in the shared types file, not per-module.
872
+
873
+ ---
874
+
875
+ ### Zod Schema
876
+
877
+ ```markdown
878
+ ## Zod Schema
879
+
880
+ File: `src/features/heroSection/heroSection.schema.ts`
881
+
882
+ (Complete Zod schema with all validation rules from PRD.md NFRs and Constraints)
883
+ ```
884
+
885
+ Rules must be explicitly derived from tagged NFR IDs:
886
+ - Character limits → `.max(N, '...')`
887
+ - URL format → `.url('...')`
888
+ - Required fields → `.min(1, '...')`
889
+ - Cross-field rules → `.refine()`
890
+
891
+ ---
892
+
893
+ ### API Functions
894
+
895
+ ```markdown
896
+ ## API Functions
897
+
898
+ File: `src/features/heroSection/api/heroSectionApi.ts`
899
+
900
+ (Complete API client object with all methods matching user stories)
901
+ ```
902
+
903
+ - `list(params)` — for list/search user stories
904
+ - `getById(id)` — for view detail user stories
905
+ - `create(payload, imageFile?)` — for create user stories
906
+ - `update(id, payload, imageFile?)` — for update user stories
907
+ - `delete(id)` — for delete user stories
908
+ - `imageUrl(id)` — if the module has image fields stored as blobs/binary
909
+
910
+ ---
911
+
912
+ ### TanStack Query Hooks
913
+
914
+ ```markdown
915
+ ## TanStack Query Hooks
916
+
917
+ Files:
918
+ - `src/features/heroSection/hooks/useHeroSections.ts`
919
+ - `src/features/heroSection/hooks/useHeroSectionMutations.ts`
920
+
921
+ (Complete query key factory and hook implementations)
922
+ ```
923
+
924
+ - Query key factory object with `all`, `lists()`, `list(params)`, `detail(id)` entries
925
+ - `use{Entity}s(params)` — paginated list query
926
+ - `use{Entity}(id)` — single item query (disabled when id is empty)
927
+ - `useCreate{Entity}()` — create mutation with cache invalidation
928
+ - `useUpdate{Entity}()` — update mutation with cache invalidation
929
+ - `useDelete{Entity}()` — delete mutation with cache invalidation
930
+
931
+ ---
932
+
933
+ ### Page Components
934
+
935
+ ```markdown
936
+ ## Page Components
937
+
938
+ Files:
939
+ - `src/features/heroSection/pages/HeroSectionListPage.tsx`
940
+ - `src/features/heroSection/pages/HeroSectionFormPage.tsx`
941
+
942
+ (Complete page component implementations matching the mockup screens)
943
+ ```
944
+
945
+ **CRITICAL — page component requirements:**
946
+ 1. Use `PageHeader` with breadcrumbs matching `Dashboard → Module Name`
947
+ 2. Use `useParams()` in form page to distinguish create vs edit mode
948
+ 3. Reset form when edit data loads: `useEffect(() => { if (data) reset(mapToFormValues(data)); }, [data, reset])`
949
+ 4. Navigate back after successful submit: `navigate('/hero-section')`
950
+ 5. Use `LoadingOverlay` while edit data is loading
951
+ 6. Use `ConfirmDialog` for delete actions via `useConfirm()`
952
+
953
+ Form page pattern for create/edit:
954
+ ```tsx
955
+ // The same page handles both create and edit based on the presence of :id param
956
+ export function HeroSectionFormPage() {
957
+ const { id } = useParams<{ id: string }>();
958
+ const isEditMode = !!id;
959
+ // ...fetch data if isEditMode, reset form when data loads
960
+ }
961
+ ```
962
+
963
+ ---
964
+
965
+ ### Form Component
966
+
967
+ ```markdown
968
+ ## Form Component
969
+
970
+ File: `src/features/heroSection/components/HeroSectionForm.tsx`
971
+
972
+ (Complete form component using React Hook Form + Zod + MUI controllers)
973
+ ```
974
+
975
+ ---
976
+
977
+ ### Route Definitions
978
+
979
+ ```markdown
980
+ ## Route Definitions
981
+
982
+ Add to `src/router/index.tsx`:
983
+
984
+ (Complete route definitions for this module — lazy-loaded, with ProtectedRoute wrapping
985
+ and requiredRoles matching the mockup role folder access control)
986
+ ```
987
+
988
+ ---
989
+
990
+ ### Navigation Items
991
+
992
+ ```markdown
993
+ ## Navigation Items
994
+
995
+ Add to `src/shared/components/navigationConfig.ts`:
996
+
997
+ (NavItem objects for this module, per role)
998
+ ```
999
+
1000
+ ---
1001
+
1002
+ ### Status Chip Map (if module has status enum)
1003
+
1004
+ ```markdown
1005
+ ## Status Configuration
1006
+
1007
+ ```typescript
1008
+ // Status display map for use with <StatusChip />
1009
+ const HERO_SECTION_STATUS_MAP = {
1010
+ DRAFT: { label: 'Draft', color: 'default' as const },
1011
+ ACTIVE: { label: 'Active', color: 'success' as const },
1012
+ EXPIRED: { label: 'Expired', color: 'error' as const },
1013
+ };
1014
+ ```
1015
+
1016
+ ---
1017
+
1018
+ ### CRITICAL Rules for Module SPEC.md
1019
+
1020
+ 1. **Use real field names** from MODEL.md — not `fieldOne`/`fieldTwo`
1021
+ 2. **Use real table/collection names** from MODEL.md
1022
+ 3. **Map every user story** to a specific API function or hook
1023
+ 4. **Map every NFR constraint** to a Zod rule or component behavior
1024
+ 5. **Use module-based URLs** — `/hero-section`, NOT `/admin/hero-section`
1025
+ 6. **Role guards** come from mockup role folder structure → `requiredRoles` on routes
1026
+ 7. **Version-tag every ID** in traceability tables
1027
+ 8. **Never use `any` type** — use proper TypeScript types or `unknown`
1028
+ 9. **All code samples must be complete** — no `// ...` gaps
1029
+ 10. **Form page handles both create and edit** via `useParams()` unless the mockup
1030
+ has clearly separate screens