ai-flow-dev 2.1.2 → 2.1.4

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 (96) hide show
  1. package/README.md +28 -40
  2. package/dist/cli.js +69 -47
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +5 -5
  5. package/prompts/backend/flow-build-phase-0.md +96 -84
  6. package/prompts/backend/flow-build-phase-1.md +10 -18
  7. package/prompts/backend/flow-build-phase-10.md +199 -583
  8. package/prompts/backend/flow-build-phase-2.md +152 -86
  9. package/prompts/backend/flow-build-phase-3.md +108 -68
  10. package/prompts/backend/flow-build-phase-4.md +5 -8
  11. package/prompts/backend/flow-build-phase-5.md +39 -12
  12. package/prompts/backend/flow-build-phase-6.md +29 -8
  13. package/prompts/backend/flow-build-phase-7.md +121 -41
  14. package/prompts/backend/flow-build-phase-8.md +28 -65
  15. package/prompts/backend/flow-build-phase-9.md +267 -1298
  16. package/prompts/backend/flow-build.md +881 -957
  17. package/prompts/backend/flow-dev-commit.md +27 -50
  18. package/prompts/backend/flow-dev-feature.md +1929 -2017
  19. package/prompts/backend/flow-dev-fix.md +936 -964
  20. package/prompts/backend/flow-dev-refactor.md +672 -701
  21. package/prompts/backend/flow-dev-review.md +356 -389
  22. package/prompts/backend/flow-dev-work.md +1066 -1118
  23. package/prompts/backend/flow-docs-sync.md +31 -210
  24. package/prompts/frontend/flow-build-phase-0.md +503 -484
  25. package/prompts/frontend/flow-build-phase-1.md +445 -433
  26. package/prompts/frontend/flow-build-phase-2.md +910 -957
  27. package/prompts/frontend/flow-build-phase-3.md +692 -664
  28. package/prompts/frontend/flow-build-phase-4.md +478 -463
  29. package/prompts/frontend/flow-build-phase-5.md +488 -467
  30. package/prompts/frontend/flow-build-phase-6.md +571 -550
  31. package/prompts/frontend/flow-build-phase-7.md +560 -592
  32. package/prompts/frontend/flow-build-phase-8.md +17 -42
  33. package/prompts/frontend/flow-build.md +457 -503
  34. package/prompts/frontend/flow-docs-sync.md +24 -45
  35. package/prompts/mobile/flow-build-phase-0.md +104 -97
  36. package/prompts/mobile/flow-build-phase-1.md +137 -122
  37. package/prompts/mobile/flow-build-phase-2.md +123 -130
  38. package/prompts/mobile/flow-build-phase-3.md +144 -149
  39. package/prompts/mobile/flow-build-phase-4.md +140 -132
  40. package/prompts/mobile/flow-build-phase-5.md +70 -70
  41. package/prompts/mobile/flow-build-phase-6.md +136 -134
  42. package/prompts/mobile/flow-build-phase-7.md +24 -58
  43. package/prompts/mobile/flow-build-phase-8.md +17 -42
  44. package/prompts/mobile/flow-build.md +47 -97
  45. package/prompts/mobile/flow-docs-sync.md +23 -42
  46. package/prompts/shared/mermaid-guidelines.md +106 -0
  47. package/prompts/shared/scope-levels.md +126 -0
  48. package/prompts/shared/story-points.md +65 -0
  49. package/prompts/shared/task-format.md +86 -0
  50. package/templates/AGENT.template.md +194 -15
  51. package/templates/backend/README.template.md +2 -32
  52. package/templates/backend/ai-instructions.template.md +2 -32
  53. package/templates/backend/copilot-instructions.template.md +2 -22
  54. package/templates/backend/docs/api.template.md +89 -20
  55. package/templates/backend/docs/architecture.template.md +165 -53
  56. package/templates/backend/docs/business-flows.template.md +7 -14
  57. package/templates/backend/docs/code-standards.template.md +2 -38
  58. package/templates/backend/docs/contributing.template.md +2 -16
  59. package/templates/backend/docs/data-model.template.md +125 -21
  60. package/templates/backend/docs/operations.template.md +179 -50
  61. package/templates/backend/docs/testing.template.md +2 -42
  62. package/templates/backend/project-brief.template.md +2 -28
  63. package/templates/backend/specs/configuration.template.md +2 -14
  64. package/templates/backend/specs/security.template.md +2 -32
  65. package/templates/frontend/README.template.md +2 -18
  66. package/templates/frontend/ai-instructions.template.md +2 -20
  67. package/templates/frontend/docs/api-integration.template.md +12 -30
  68. package/templates/frontend/docs/components.template.md +2 -28
  69. package/templates/frontend/docs/error-handling.template.md +11 -27
  70. package/templates/frontend/docs/operations.template.md +8 -18
  71. package/templates/frontend/docs/performance.template.md +8 -18
  72. package/templates/frontend/docs/pwa.template.md +8 -18
  73. package/templates/frontend/docs/state-management.template.md +2 -28
  74. package/templates/frontend/docs/styling.template.md +2 -26
  75. package/templates/frontend/docs/testing.template.md +2 -28
  76. package/templates/frontend/project-brief.template.md +2 -16
  77. package/templates/frontend/specs/accessibility.template.md +8 -18
  78. package/templates/frontend/specs/configuration.template.md +2 -24
  79. package/templates/frontend/specs/security.template.md +10 -24
  80. package/templates/fullstack/README.template.md +17 -47
  81. package/templates/fullstack/ai-instructions.template.md +17 -45
  82. package/templates/fullstack/project-brief.template.md +16 -42
  83. package/templates/fullstack/specs/configuration.template.md +16 -42
  84. package/templates/mobile/README.template.md +11 -29
  85. package/templates/mobile/ai-instructions.template.md +11 -27
  86. package/templates/mobile/docs/app-store.template.md +11 -29
  87. package/templates/mobile/docs/architecture.template.md +14 -38
  88. package/templates/mobile/docs/native-features.template.md +16 -44
  89. package/templates/mobile/docs/navigation.template.md +9 -23
  90. package/templates/mobile/docs/offline-strategy.template.md +10 -26
  91. package/templates/mobile/docs/permissions.template.md +9 -23
  92. package/templates/mobile/docs/state-management.template.md +12 -32
  93. package/templates/mobile/docs/testing.template.md +14 -38
  94. package/templates/mobile/project-brief.template.md +12 -30
  95. package/templates/mobile/specs/build-configuration.template.md +10 -26
  96. package/templates/mobile/specs/deployment.template.md +9 -23
@@ -1,687 +1,715 @@
1
- # Phase 3: State Management
2
-
3
- **Duration:** 15-20 minutes
4
- **Questions:** ~10 questions
5
- **Output:** docs/state-management.md, parts of ai-instructions.md
6
-
1
+ # Phase 3: State Management
2
+
3
+ **Duration:** 15-20 minutes
4
+ **Questions:** ~10 questions
5
+ **Output:** docs/state-management.md, parts of ai-instructions.md
6
+ ---
7
+ ## 🎯 Objective
8
+
9
+ Define how your application will manage state across four categories:
10
+
11
+ 1. **Server State** - Remote data from APIs
12
+ 2. **Client State** - Local UI state
13
+ 3. **URL State** - Query params and routes
14
+ 4. **Form State** - Form data and validation
15
+ ---
16
+ ## 📋 Questions
17
+
18
+ ### Question 3.1: Server State Management
19
+
20
+ **How will you fetch and cache data from APIs?**
21
+
22
+ #### React Options
23
+
24
+ A) ⭐ **TanStack Query (React Query)** (Recommended)
25
+
26
+ - Features: Auto caching, background refetching, optimistic updates
27
+ - Best for: REST APIs, GraphQL (via custom fetcher)
28
+ - Bundle: ~12KB (gzipped)
29
+
30
+ B) 🔥 **SWR (Vercel)**
31
+
32
+ - Features: Stale-while-revalidate, automatic deduplication
33
+ - Best for: REST APIs, simple data fetching
34
+ - Bundle: ~5KB (gzipped)
35
+
36
+ C) **Apollo Client**
37
+
38
+ - Features: GraphQL-specific, normalized cache, subscriptions
39
+ - Best for: GraphQL APIs only
40
+ - Bundle: ~33KB (gzipped)
41
+
42
+ D) **urql**
43
+
44
+ - Features: Lightweight GraphQL client, extensible
45
+ - Best for: GraphQL, smaller bundle than Apollo
46
+ - Bundle: ~16KB (gzipped)
47
+
48
+ E) **Redux Toolkit + RTK Query**
49
+
50
+ - Features: Integrated with Redux, powerful caching
51
+ - Best for: Complex apps already using Redux
52
+ - Bundle: ~15KB (gzipped, with Redux)
53
+
54
+ F) **Plain fetch + Custom Hooks**
55
+
56
+ - Features: Full control, no dependencies
57
+ - Best for: Very simple apps
58
+ - Bundle: 0KB (native)
59
+
60
+ #### Vue Options
61
+
62
+ A) ⭐ **TanStack Query (Vue Query)** (Recommended)
63
+
64
+ - Same as React version, Vue adapter
65
+
66
+ B) **Pinia + Custom Composables**
67
+
68
+ - Features: Reactive state management
69
+ - Best for: Vue 3 apps with complex state
70
+
71
+ C) **Villus (GraphQL)**
72
+
73
+ - Features: Lightweight GraphQL client for Vue
74
+ - Best for: Vue + GraphQL
75
+
76
+ #### Angular Options
77
+
78
+ A) ⭐ **TanStack Query (Angular Query)**
79
+
80
+ - Same as React version, Angular adapter
81
+
82
+ B) **NgRx + Custom Effects**
83
+
84
+ - Features: Redux pattern for Angular
85
+ - Best for: Enterprise Angular apps
86
+
87
+ C) **Apollo Angular**
88
+
89
+ - Features: GraphQL client for Angular
90
+ - Best for: Angular + GraphQL
91
+
92
+ **Your answer:**
7
93
  ---
8
-
9
- ## 🎯 Objective
10
-
11
- Define how your application will manage state across four categories:
12
-
13
- 1. **Server State** - Remote data from APIs
14
- 2. **Client State** - Local UI state
15
- 3. **URL State** - Query params and routes
16
- 4. **Form State** - Form data and validation
17
-
94
+ ### Question 3.2: Client State Management
95
+
96
+ **How will you manage local UI state?** (modals, themes, UI flags)
97
+
98
+ #### React Options
99
+
100
+ A) **Zustand** (Recommended for most)
101
+
102
+ - Features: Minimal boilerplate, hooks-based, simple API
103
+ - Best for: Small to medium apps, simple global state
104
+ - Bundle: ~1KB (gzipped)
105
+
106
+ B) 🔥 **Redux Toolkit**
107
+
108
+ - Features: Redux with less boilerplate, DevTools, middleware
109
+ - Best for: Large apps, complex state logic, time-travel debugging
110
+ - Bundle: ~14KB (gzipped)
111
+
112
+ C) **Jotai**
113
+
114
+ - Features: Atomic state management, bottom-up approach
115
+ - Best for: Fine-grained reactivity, derived state
116
+ - Bundle: ~3KB (gzipped)
117
+
118
+ D) **Recoil**
119
+
120
+ - Features: Facebook's state library, atom-based
121
+ - Best for: Complex dependency graphs
122
+ - Bundle: ~21KB (gzipped)
123
+
124
+ E) **Context API + useReducer**
125
+
126
+ - Features: Built-in React, no dependencies
127
+ - Best for: Simple apps, small global state
128
+ - Bundle: 0KB (native)
129
+
130
+ F) **XState**
131
+
132
+ - Features: State machines, predictable state transitions
133
+ - Best for: Complex workflows, multi-step forms
134
+ - Bundle: ~18KB (gzipped)
135
+
136
+ #### Vue Options
137
+
138
+ A) ⭐ **Pinia** (Recommended)
139
+
140
+ - Features: Official Vue state library, TypeScript support
141
+ - Best for: Vue 3 apps
142
+ - Bundle: ~1.5KB (gzipped)
143
+
144
+ B) **Vuex**
145
+
146
+ - Features: Traditional Vue state management
147
+ - Best for: Vue 2 apps, migration from Vue 2
148
+ - Bundle: ~2KB (gzipped)
149
+
150
+ C) **Composition API (Built-in)**
151
+
152
+ - Features: `reactive()`, `ref()`, composables
153
+ - Best for: Simple apps
154
+ - Bundle: 0KB (native)
155
+
156
+ #### Angular Options
157
+
158
+ A) ⭐ **NgRx** (Recommended for large apps)
159
+
160
+ - Features: Redux pattern, RxJS integration
161
+ - Best for: Enterprise Angular apps
162
+ - Bundle: ~18KB (gzipped)
163
+
164
+ B) **Akita**
165
+
166
+ - Features: Simplified state management, RxJS-based
167
+ - Best for: Medium Angular apps
168
+ - Bundle: ~12KB (gzipped)
169
+
170
+ C) **Elf**
171
+
172
+ - Features: Reactive state management, modular
173
+ - Best for: Flexible architecture
174
+ - Bundle: ~8KB (gzipped)
175
+
176
+ D) **Services + RxJS (Built-in)**
177
+
178
+ - Features: Angular services with BehaviorSubject
179
+ - Best for: Simple apps
180
+ - Bundle: 0KB (native)
181
+
182
+ #### Svelte Options
183
+
184
+ A) ⭐ **Svelte Stores** (Recommended)
185
+
186
+ - Features: Built-in, writable/readable/derived stores
187
+ - Best for: All Svelte apps
188
+ - Bundle: 0KB (built-in)
189
+
190
+ B) **XState + Svelte**
191
+
192
+ - Features: State machines for complex flows
193
+ - Best for: Complex workflows
194
+
195
+ #### Solid Options
196
+
197
+ A) ⭐ **Solid Store** (Recommended)
198
+
199
+ - Features: Built-in, reactive store
200
+ - Best for: All Solid apps
201
+ - Bundle: 0KB (built-in)
202
+
203
+ **Your answer:**
18
204
  ---
19
-
20
- ## 📋 Questions
21
-
22
- ### Question 3.1: Server State Management
23
-
24
- **How will you fetch and cache data from APIs?**
25
-
26
- #### React Options
27
-
28
- A) **TanStack Query (React Query)** (Recommended)
29
- - Features: Auto caching, background refetching, optimistic updates
30
- - Best for: REST APIs, GraphQL (via custom fetcher)
31
- - Bundle: ~12KB (gzipped)
32
-
33
- B) 🔥 **SWR (Vercel)**
34
- - Features: Stale-while-revalidate, automatic deduplication
35
- - Best for: REST APIs, simple data fetching
36
- - Bundle: ~5KB (gzipped)
37
-
38
- C) **Apollo Client**
39
- - Features: GraphQL-specific, normalized cache, subscriptions
40
- - Best for: GraphQL APIs only
41
- - Bundle: ~33KB (gzipped)
42
-
43
- D) **urql**
44
- - Features: Lightweight GraphQL client, extensible
45
- - Best for: GraphQL, smaller bundle than Apollo
46
- - Bundle: ~16KB (gzipped)
47
-
48
- E) **Redux Toolkit + RTK Query**
49
- - Features: Integrated with Redux, powerful caching
50
- - Best for: Complex apps already using Redux
51
- - Bundle: ~15KB (gzipped, with Redux)
52
-
53
- F) **Plain fetch + Custom Hooks**
54
- - Features: Full control, no dependencies
55
- - Best for: Very simple apps
56
- - Bundle: 0KB (native)
57
-
58
- #### Vue Options
59
-
60
- A) ⭐ **TanStack Query (Vue Query)** (Recommended)
61
- - Same as React version, Vue adapter
62
-
63
- B) **Pinia + Custom Composables**
64
- - Features: Reactive state management
65
- - Best for: Vue 3 apps with complex state
66
-
67
- C) **Villus (GraphQL)**
68
- - Features: Lightweight GraphQL client for Vue
69
- - Best for: Vue + GraphQL
70
-
71
- #### Angular Options
72
-
73
- A) ⭐ **TanStack Query (Angular Query)**
74
- - Same as React version, Angular adapter
75
-
76
- B) **NgRx + Custom Effects**
77
- - Features: Redux pattern for Angular
78
- - Best for: Enterprise Angular apps
79
-
80
- C) **Apollo Angular**
81
- - Features: GraphQL client for Angular
82
- - Best for: Angular + GraphQL
83
-
84
- **Your answer:**
85
-
205
+ ### Question 3.3: State Persistence
206
+
207
+ **Do you need to persist state to localStorage/sessionStorage?**
208
+
209
+ A) ⭐ **No Persistence**
210
+
211
+ - State reset on page reload
212
+ - Best for: Most apps
213
+
214
+ B) **Selective Persistence**
215
+
216
+ - Persist specific state (e.g., theme, user preferences)
217
+ - Example: Zustand persist middleware, Pinia persist plugin
218
+ - Best for: User preferences, shopping cart
219
+
220
+ C) **Full Persistence**
221
+
222
+ - Persist entire state tree
223
+ - Best for: Offline-first apps, complex forms
224
+
225
+ **Your answer:**
226
+
227
+ **If persistence selected, what should be persisted?**
86
228
  ---
87
-
88
- ### Question 3.2: Client State Management
89
-
90
- **How will you manage local UI state?** (modals, themes, UI flags)
91
-
92
- #### React Options
93
-
94
- A) ⭐ **Zustand** (Recommended for most)
95
- - Features: Minimal boilerplate, hooks-based, simple API
96
- - Best for: Small to medium apps, simple global state
97
- - Bundle: ~1KB (gzipped)
98
-
99
- B) 🔥 **Redux Toolkit**
100
- - Features: Redux with less boilerplate, DevTools, middleware
101
- - Best for: Large apps, complex state logic, time-travel debugging
102
- - Bundle: ~14KB (gzipped)
103
-
104
- C) **Jotai**
105
- - Features: Atomic state management, bottom-up approach
106
- - Best for: Fine-grained reactivity, derived state
107
- - Bundle: ~3KB (gzipped)
108
-
109
- D) **Recoil**
110
- - Features: Facebook's state library, atom-based
111
- - Best for: Complex dependency graphs
112
- - Bundle: ~21KB (gzipped)
113
-
114
- E) **Context API + useReducer**
115
- - Features: Built-in React, no dependencies
116
- - Best for: Simple apps, small global state
117
- - Bundle: 0KB (native)
118
-
119
- F) **XState**
120
- - Features: State machines, predictable state transitions
121
- - Best for: Complex workflows, multi-step forms
122
- - Bundle: ~18KB (gzipped)
123
-
124
- #### Vue Options
125
-
126
- A) ⭐ **Pinia** (Recommended)
127
- - Features: Official Vue state library, TypeScript support
128
- - Best for: Vue 3 apps
129
- - Bundle: ~1.5KB (gzipped)
130
-
131
- B) **Vuex**
132
- - Features: Traditional Vue state management
133
- - Best for: Vue 2 apps, migration from Vue 2
134
- - Bundle: ~2KB (gzipped)
135
-
136
- C) **Composition API (Built-in)**
137
- - Features: `reactive()`, `ref()`, composables
138
- - Best for: Simple apps
139
- - Bundle: 0KB (native)
140
-
141
- #### Angular Options
142
-
143
- A) **NgRx** (Recommended for large apps)
144
- - Features: Redux pattern, RxJS integration
145
- - Best for: Enterprise Angular apps
146
- - Bundle: ~18KB (gzipped)
147
-
148
- B) **Akita**
149
- - Features: Simplified state management, RxJS-based
150
- - Best for: Medium Angular apps
151
- - Bundle: ~12KB (gzipped)
152
-
153
- C) **Elf**
154
- - Features: Reactive state management, modular
155
- - Best for: Flexible architecture
156
- - Bundle: ~8KB (gzipped)
157
-
158
- D) **Services + RxJS (Built-in)**
159
- - Features: Angular services with BehaviorSubject
160
- - Best for: Simple apps
161
- - Bundle: 0KB (native)
162
-
163
- #### Svelte Options
164
-
165
- A) ⭐ **Svelte Stores** (Recommended)
166
- - Features: Built-in, writable/readable/derived stores
167
- - Best for: All Svelte apps
168
- - Bundle: 0KB (built-in)
169
-
170
- B) **XState + Svelte**
171
- - Features: State machines for complex flows
172
- - Best for: Complex workflows
173
-
174
- #### Solid Options
175
-
176
- A) ⭐ **Solid Store** (Recommended)
177
- - Features: Built-in, reactive store
178
- - Best for: All Solid apps
179
- - Bundle: 0KB (built-in)
180
-
181
- **Your answer:**
182
-
229
+ ### Question 3.4: Form State Management
230
+
231
+ **How will you handle forms?**
232
+
233
+ #### React Options
234
+
235
+ A) ⭐ **React Hook Form** (Recommended)
236
+
237
+ - Features: Uncontrolled forms, minimal re-renders, validation
238
+ - Best for: Performance-critical forms, complex validation
239
+ - Bundle: ~9KB (gzipped)
240
+
241
+ B) **Formik**
242
+
243
+ - Features: Controlled forms, popular, mature
244
+ - Best for: Traditional React forms
245
+ - Bundle: ~15KB (gzipped)
246
+
247
+ C) **TanStack Form**
248
+
249
+ - Features: Framework-agnostic, type-safe
250
+ - Best for: Advanced form logic
251
+ - Bundle: ~12KB (gzipped)
252
+
253
+ D) **Controlled Components (Built-in)**
254
+
255
+ - Features: Manual useState management
256
+ - Best for: Simple forms (1-3 fields)
257
+ - Bundle: 0KB (native)
258
+
259
+ #### Vue Options
260
+
261
+ A) **VeeValidate** (Recommended)
262
+
263
+ - Features: Composition API, Yup/Zod integration
264
+ - Best for: Vue 3 forms with validation
265
+ - Bundle: ~7KB (gzipped)
266
+
267
+ B) **FormKit**
268
+
269
+ - Features: All-in-one forms + UI components
270
+ - Best for: Rapid form development
271
+ - Bundle: ~25KB (gzipped)
272
+
273
+ C) **v-model (Built-in)**
274
+
275
+ - Features: Two-way binding
276
+ - Best for: Simple forms
277
+ - Bundle: 0KB (native)
278
+
279
+ #### Angular Options
280
+
281
+ A) **Reactive Forms** (Recommended)
282
+
283
+ - Features: Built-in, powerful validation
284
+ - Best for: Complex Angular forms
285
+ - Bundle: 0KB (built-in)
286
+
287
+ B) **Template-Driven Forms**
288
+
289
+ - Features: Built-in, simpler API
290
+ - Best for: Simple Angular forms
291
+ - Bundle: 0KB (built-in)
292
+
293
+ #### Svelte/Solid Options
294
+
295
+ A) **Two-way binding (Built-in)**
296
+
297
+ - Features: Simple bind:value syntax
298
+ - Best for: Most forms
299
+ - Bundle: 0KB (built-in)
300
+
301
+ B) **Felte (Svelte) / Modular Forms (Solid)**
302
+
303
+ - Features: Advanced form libraries
304
+ - Best for: Complex validation
305
+
306
+ **Your answer:**
183
307
  ---
184
-
185
- ### Question 3.3: State Persistence
186
-
187
- **Do you need to persist state to localStorage/sessionStorage?**
188
-
189
- A) ⭐ **No Persistence**
190
- - State reset on page reload
191
- - Best for: Most apps
192
-
193
- B) **Selective Persistence**
194
- - Persist specific state (e.g., theme, user preferences)
195
- - Example: Zustand persist middleware, Pinia persist plugin
196
- - Best for: User preferences, shopping cart
197
-
198
- C) **Full Persistence**
199
- - Persist entire state tree
200
- - Best for: Offline-first apps, complex forms
201
-
202
- **Your answer:**
203
-
204
- **If persistence selected, what should be persisted?**
205
-
308
+ ### Question 3.5: Form Validation
309
+
310
+ **What validation strategy will you use?**
311
+
312
+ A) ⭐ **Schema Validation (Zod/Yup)**
313
+
314
+ - Features: Type-safe, reusable schemas
315
+ - Best for: Complex validation, type safety
316
+ - Example: Zod for TypeScript projects
317
+
318
+ B) **Built-in HTML5 Validation**
319
+
320
+ - Features: Native browser validation
321
+ - Best for: Simple forms
322
+ - Example: `required`, `pattern`, `min`, `max`
323
+
324
+ C) **Custom Validation Functions**
325
+
326
+ - Features: Full control, no dependencies
327
+ - Best for: Unique validation rules
328
+
329
+ D) **Backend Validation Only**
330
+
331
+ - Features: Server-side validation
332
+ - Best for: Security-critical forms
333
+ - Note: Still need client-side for UX
334
+
335
+ E) **Combined (Client + Server)**
336
+
337
+ - Features: Client for UX, server for security
338
+ - Best for: Most production apps
339
+
340
+ **Your answer:**
206
341
  ---
207
-
208
- ### Question 3.4: Form State Management
209
-
210
- **How will you handle forms?**
211
-
212
- #### React Options
213
-
214
- A) ⭐ **React Hook Form** (Recommended)
215
- - Features: Uncontrolled forms, minimal re-renders, validation
216
- - Best for: Performance-critical forms, complex validation
217
- - Bundle: ~9KB (gzipped)
218
-
219
- B) **Formik**
220
- - Features: Controlled forms, popular, mature
221
- - Best for: Traditional React forms
222
- - Bundle: ~15KB (gzipped)
223
-
224
- C) **TanStack Form**
225
- - Features: Framework-agnostic, type-safe
226
- - Best for: Advanced form logic
227
- - Bundle: ~12KB (gzipped)
228
-
229
- D) **Controlled Components (Built-in)**
230
- - Features: Manual useState management
231
- - Best for: Simple forms (1-3 fields)
232
- - Bundle: 0KB (native)
233
-
234
- #### Vue Options
235
-
236
- A) ⭐ **VeeValidate** (Recommended)
237
- - Features: Composition API, Yup/Zod integration
238
- - Best for: Vue 3 forms with validation
239
- - Bundle: ~7KB (gzipped)
240
-
241
- B) **FormKit**
242
- - Features: All-in-one forms + UI components
243
- - Best for: Rapid form development
244
- - Bundle: ~25KB (gzipped)
245
-
246
- C) **v-model (Built-in)**
247
- - Features: Two-way binding
248
- - Best for: Simple forms
249
- - Bundle: 0KB (native)
250
-
251
- #### Angular Options
252
-
253
- A) ⭐ **Reactive Forms** (Recommended)
254
- - Features: Built-in, powerful validation
255
- - Best for: Complex Angular forms
256
- - Bundle: 0KB (built-in)
257
-
258
- B) **Template-Driven Forms**
259
- - Features: Built-in, simpler API
260
- - Best for: Simple Angular forms
261
- - Bundle: 0KB (built-in)
262
-
263
- #### Svelte/Solid Options
264
-
265
- A) **Two-way binding (Built-in)**
266
- - Features: Simple bind:value syntax
267
- - Best for: Most forms
268
- - Bundle: 0KB (built-in)
269
-
270
- B) **Felte (Svelte) / Modular Forms (Solid)**
271
- - Features: Advanced form libraries
272
- - Best for: Complex validation
273
-
274
- **Your answer:**
275
-
342
+ ### Question 3.6: Optimistic Updates
343
+
344
+ **Will you use optimistic UI updates?**
345
+
346
+ Optimistic updates = Update UI before server confirms success
347
+
348
+ A) ⭐ **Yes, for common actions**
349
+
350
+ - Example: Like button, delete item, mark complete
351
+ - Best for: Interactive apps, real-time feel
352
+ - Requires: Rollback logic on error
353
+
354
+ B) **No, wait for server confirmation**
355
+
356
+ - Best for: Critical actions (payments, deletions)
357
+ - Safer but slower UX
358
+
359
+ C) **Selective (case-by-case)**
360
+
361
+ - Optimistic for safe actions, wait for critical ones
362
+
363
+ **Your answer:**
276
364
  ---
277
-
278
- ### Question 3.5: Form Validation
279
-
280
- **What validation strategy will you use?**
281
-
282
- A) ⭐ **Schema Validation (Zod/Yup)**
283
- - Features: Type-safe, reusable schemas
284
- - Best for: Complex validation, type safety
285
- - Example: Zod for TypeScript projects
286
-
287
- B) **Built-in HTML5 Validation**
288
- - Features: Native browser validation
289
- - Best for: Simple forms
290
- - Example: `required`, `pattern`, `min`, `max`
291
-
292
- C) **Custom Validation Functions**
293
- - Features: Full control, no dependencies
294
- - Best for: Unique validation rules
295
-
296
- D) **Backend Validation Only**
297
- - Features: Server-side validation
298
- - Best for: Security-critical forms
299
- - Note: Still need client-side for UX
300
-
301
- E) **Combined (Client + Server)**
302
- - Features: Client for UX, server for security
303
- - Best for: Most production apps
304
-
305
- **Your answer:**
306
-
365
+ ### Question 3.7: Real-Time Updates
366
+
367
+ **Do you need real-time data updates?**
368
+
369
+ A) ⭐ **No Real-Time**
370
+
371
+ - Data fetched on demand or on interval
372
+ - Best for: Most apps
373
+
374
+ B) **Polling (Short Intervals)**
375
+
376
+ - Refetch data every X seconds
377
+ - Best for: Near real-time, simple implementation
378
+ - Example: Every 10-30 seconds
379
+
380
+ C) **WebSockets**
381
+
382
+ - Bi-directional, persistent connection
383
+ - Best for: Chat, live dashboards, collaboration
384
+ - Technologies: Socket.io, native WebSockets
385
+
386
+ D) **Server-Sent Events (SSE)**
387
+
388
+ - Unidirectional, server pushes updates
389
+ - Best for: Live notifications, feeds
390
+ - Technologies: EventSource API
391
+
392
+ E) **GraphQL Subscriptions**
393
+
394
+ - Real-time GraphQL queries
395
+ - Best for: GraphQL apps with live data
396
+
397
+ **Your answer:**
307
398
  ---
308
-
309
- ### Question 3.6: Optimistic Updates
310
-
311
- **Will you use optimistic UI updates?**
312
-
313
- Optimistic updates = Update UI before server confirms success
314
-
315
- A) ⭐ **Yes, for common actions**
316
- - Example: Like button, delete item, mark complete
317
- - Best for: Interactive apps, real-time feel
318
- - Requires: Rollback logic on error
319
-
320
- B) **No, wait for server confirmation**
321
- - Best for: Critical actions (payments, deletions)
322
- - Safer but slower UX
323
-
324
- C) **Selective (case-by-case)**
325
- - Optimistic for safe actions, wait for critical ones
326
-
327
- **Your answer:**
328
-
399
+ ### Question 3.8: State Normalization
400
+
401
+ **Will you normalize relational data?**
402
+
403
+ Normalization = Flatten nested data into lookup tables (like a database)
404
+
405
+ **Example:**
406
+
407
+ ```javascript
408
+ // Nested (Not normalized)
409
+ {
410
+ posts: [
411
+ { id: 1, title: 'Post 1', author: { id: 10, name: 'Alice' } },
412
+ { id: 2, title: 'Post 2', author: { id: 10, name: 'Alice' } }
413
+ ]
414
+ }
415
+
416
+ // Normalized
417
+ {
418
+ posts: { 1: { id: 1, title: 'Post 1', authorId: 10 }, 2: { ... } },
419
+ authors: { 10: { id: 10, name: 'Alice' } }
420
+ }
421
+ ```
422
+
423
+ A) ⭐ **Yes, normalize relational data**
424
+
425
+ - Best for: Complex data models, many-to-many relationships
426
+ - Tools: normalizr, Redux Toolkit (createEntityAdapter)
427
+
428
+ B) **No, keep data nested**
429
+
430
+ - Best for: Simple data structures, tree-like data
431
+ - Easier to reason about
432
+
433
+ **Your answer:**
329
434
  ---
330
-
331
- ### Question 3.7: Real-Time Updates
332
-
333
- **Do you need real-time data updates?**
334
-
335
- A) ⭐ **No Real-Time**
336
- - Data fetched on demand or on interval
337
- - Best for: Most apps
338
-
339
- B) **Polling (Short Intervals)**
340
- - Refetch data every X seconds
341
- - Best for: Near real-time, simple implementation
342
- - Example: Every 10-30 seconds
343
-
344
- C) **WebSockets**
345
- - Bi-directional, persistent connection
346
- - Best for: Chat, live dashboards, collaboration
347
- - Technologies: Socket.io, native WebSockets
348
-
349
- D) **Server-Sent Events (SSE)**
350
- - Unidirectional, server pushes updates
351
- - Best for: Live notifications, feeds
352
- - Technologies: EventSource API
353
-
354
- E) **GraphQL Subscriptions**
355
- - Real-time GraphQL queries
356
- - Best for: GraphQL apps with live data
357
-
358
- **Your answer:**
359
-
435
+ ### Question 3.9: Global vs Local State
436
+
437
+ **What's your default strategy for state placement?**
438
+
439
+ A) ⭐ **Local by default, global when shared** (Recommended)
440
+
441
+ - Start with component state (useState/reactive)
442
+ - Lift to global only when multiple components need it
443
+ - Best for: Most apps, avoid over-engineering
444
+
445
+ B) **Global by default**
446
+
447
+ - Most state in global store
448
+ - Best for: Complex apps with heavy state sharing
449
+
450
+ C) **URL-driven state**
451
+
452
+ - Prefer URL params over global state
453
+ - Best for: Multi-page apps, shareable state
454
+
455
+ **Your answer:**
360
456
  ---
361
-
362
- ### Question 3.8: State Normalization
363
-
364
- **Will you normalize relational data?**
365
-
366
- Normalization = Flatten nested data into lookup tables (like a database)
367
-
368
- **Example:**
369
- ```javascript
370
- // ❌ Nested (Not normalized)
371
- {
372
- posts: [
373
- { id: 1, title: 'Post 1', author: { id: 10, name: 'Alice' } },
374
- { id: 2, title: 'Post 2', author: { id: 10, name: 'Alice' } }
375
- ]
376
- }
377
-
378
- // Normalized
379
- {
380
- posts: { 1: { id: 1, title: 'Post 1', authorId: 10 }, 2: { ... } },
381
- authors: { 10: { id: 10, name: 'Alice' } }
382
- }
383
- ```
384
-
385
- A) **Yes, normalize relational data**
386
- - Best for: Complex data models, many-to-many relationships
387
- - Tools: normalizr, Redux Toolkit (createEntityAdapter)
388
-
389
- B) **No, keep data nested**
390
- - Best for: Simple data structures, tree-like data
391
- - Easier to reason about
392
-
393
- **Your answer:**
394
-
457
+ ### Question 3.10: Error Handling Strategy
458
+
459
+ **How will you handle API errors and failed requests?**
460
+
461
+ A) ⭐ **Toast Notifications**
462
+
463
+ - Show temporary error message
464
+ - Best for: Non-critical errors
465
+ - Libraries: react-hot-toast, vue-toastification
466
+
467
+ B) **Inline Error Messages**
468
+
469
+ - Display errors next to forms/components
470
+ - Best for: Form validation, input errors
471
+
472
+ C) **Error Boundary (Global)**
473
+
474
+ - Catch all errors, show fallback UI
475
+ - Best for: Unhandled errors, app crashes
476
+ - React: Error Boundaries, Vue: errorHandler
477
+
478
+ D) **Modal Dialogs**
479
+
480
+ - Show error in modal
481
+ - Best for: Critical errors requiring user action
482
+
483
+ E) **Retry Mechanism**
484
+
485
+ - Auto-retry failed requests
486
+ - Best for: Network errors, transient failures
487
+ - TanStack Query has built-in retry
488
+
489
+ F) **Combined Approach**
490
+
491
+ - Different strategies for different error types
492
+
493
+ **Your answer:**
395
494
  ---
396
-
397
- ### Question 3.9: Global vs Local State
398
-
399
- **What's your default strategy for state placement?**
400
-
401
- A) ⭐ **Local by default, global when shared** (Recommended)
402
- - Start with component state (useState/reactive)
403
- - Lift to global only when multiple components need it
404
- - Best for: Most apps, avoid over-engineering
405
-
406
- B) **Global by default**
407
- - Most state in global store
408
- - Best for: Complex apps with heavy state sharing
409
-
410
- C) **URL-driven state**
411
- - Prefer URL params over global state
412
- - Best for: Multi-page apps, shareable state
413
-
414
- **Your answer:**
415
-
495
+ #### 🎨 MERMAID STATE MANAGEMENT DIAGRAM FORMATS - CRITICAL
496
+
497
+ **Use these exact formats** for state management diagrams mentioned in documentation:
416
498
  ---
417
-
418
- ### Question 3.10: Error Handling Strategy
419
-
420
- **How will you handle API errors and failed requests?**
421
-
422
- A) ⭐ **Toast Notifications**
423
- - Show temporary error message
424
- - Best for: Non-critical errors
425
- - Libraries: react-hot-toast, vue-toastification
426
-
427
- B) **Inline Error Messages**
428
- - Display errors next to forms/components
429
- - Best for: Form validation, input errors
430
-
431
- C) **Error Boundary (Global)**
432
- - Catch all errors, show fallback UI
433
- - Best for: Unhandled errors, app crashes
434
- - React: Error Boundaries, Vue: errorHandler
435
-
436
- D) **Modal Dialogs**
437
- - Show error in modal
438
- - Best for: Critical errors requiring user action
439
-
440
- E) **Retry Mechanism**
441
- - Auto-retry failed requests
442
- - Best for: Network errors, transient failures
443
- - TanStack Query has built-in retry
444
-
445
- F) **Combined Approach**
446
- - Different strategies for different error types
447
-
448
- **Your answer:**
449
-
499
+ ##### 1️⃣ State Categories & Store Organization
500
+
501
+ Use `graph LR` to show different state types and their tools:
502
+
503
+ ````markdown
504
+ ```mermaid
505
+ graph LR
506
+ subgraph "State Types"
507
+ SS[Server State<br/>TanStack Query<br/>React Query]
508
+ CS[Client State<br/>Zustand/Redux<br/>Context]
509
+ US[URL State<br/>React Router<br/>Query Params]
510
+ FS[Form State<br/>React Hook Form<br/>Formik]
511
+ LS[Local State<br/>useState<br/>useReducer]
512
+ end
513
+
514
+ subgraph "Components"
515
+ C1[ProductList]
516
+ C2[UserProfile]
517
+ C3[SearchPage]
518
+ C4[CheckoutForm]
519
+ C5[DropdownMenu]
520
+ end
521
+
522
+ SS -.->|products, users| C1
523
+ SS -.->|user data| C2
524
+ CS -.->|theme, auth| C1
525
+ CS -.->|auth| C2
526
+ US -.->|search query| C3
527
+ FS -.->|form data| C4
528
+ LS -.->|isOpen| C5
529
+
530
+ style SS fill:#e1f5ff
531
+ style CS fill:#fff4e6
532
+ style US fill:#e8f5e9
533
+ style FS fill:#fce4ec
534
+ style LS fill:#f3e5f5
535
+ ```
536
+ ````
537
+
538
+ **Use for:** Deciding where to store state, showing state architecture, documenting state tools
450
539
  ---
451
-
452
- #### 🎨 MERMAID STATE MANAGEMENT DIAGRAM FORMATS - CRITICAL
453
-
454
- **Use these exact formats** for state management diagrams mentioned in documentation:
455
-
540
+ ##### 2️⃣ Data Flow Sequence (API to UI)
541
+
542
+ Use `sequenceDiagram` to show step-by-step data flow:
543
+
544
+ ````markdown
545
+ ```mermaid
546
+ sequenceDiagram
547
+ participant U as User
548
+ participant C as Component
549
+ participant S as Store/Hook
550
+ participant API as API Service
551
+ participant BE as Backend
552
+
553
+ U->>C: Click "Load Products"
554
+ C->>S: useProducts() hook
555
+ S->>API: fetchProducts()
556
+ API->>BE: GET /api/products
557
+ BE-->>API: 200 OK + data
558
+ API-->>S: Return products[]
559
+ S->>S: Update cache
560
+ S-->>C: products data
561
+ C->>U: Render UI
562
+
563
+ Note over S: TanStack Query<br/>caches for 5min
564
+
565
+ U->>C: Click "Add to Cart"
566
+ C->>S: addToCart(productId)
567
+ S->>S: Update client state
568
+ S-->>C: cart updated
569
+ C->>U: Show cart badge
570
+ ```
571
+ ````
572
+
573
+ **Use for:** Showing request/response cycles, async operations, state updates, caching behavior
456
574
  ---
457
-
458
- ##### 1️⃣ State Categories & Store Organization
459
-
460
- Use `graph LR` to show different state types and their tools:
461
-
462
- ````markdown
463
- ```mermaid
464
- graph LR
465
- subgraph "State Types"
466
- SS[Server State<br/>TanStack Query<br/>React Query]
467
- CS[Client State<br/>Zustand/Redux<br/>Context]
468
- US[URL State<br/>React Router<br/>Query Params]
469
- FS[Form State<br/>React Hook Form<br/>Formik]
470
- LS[Local State<br/>useState<br/>useReducer]
471
- end
472
-
473
- subgraph "Components"
474
- C1[ProductList]
475
- C2[UserProfile]
476
- C3[SearchPage]
477
- C4[CheckoutForm]
478
- C5[DropdownMenu]
479
- end
480
-
481
- SS -.->|products, users| C1
482
- SS -.->|user data| C2
483
- CS -.->|theme, auth| C1
484
- CS -.->|auth| C2
485
- US -.->|search query| C3
486
- FS -.->|form data| C4
487
- LS -.->|isOpen| C5
488
-
489
- style SS fill:#e1f5ff
490
- style CS fill:#fff4e6
491
- style US fill:#e8f5e9
492
- style FS fill:#fce4ec
493
- style LS fill:#f3e5f5
494
- ```
495
- ````
496
-
497
- **Use for:** Deciding where to store state, showing state architecture, documenting state tools
498
-
575
+ ##### 3️⃣ State Location Decision Tree
576
+
577
+ Use `graph TD` to help developers choose where to store state:
578
+
579
+ ````markdown
580
+ ```mermaid
581
+ graph TD
582
+ A[New State Needed] --> B{From Server?}
583
+ B -->|Yes| C[Use TanStack Query<br/>Server State<br/>Auto-caching]
584
+ B -->|No| D{Shared Across<br/>Components?}
585
+ D -->|Yes| E{Needs to<br/>Persist?}
586
+ E -->|Yes| F[Use Zustand +<br/>localStorage<br/>Client State]
587
+ E -->|No| G[Use Zustand or<br/>Context<br/>Client State]
588
+ D -->|No| H{In URL?}
589
+ H -->|Yes| I[Use React Router<br/>searchParams<br/>URL State]
590
+ H -->|No| J{Form Data?}
591
+ J -->|Yes| K[Use React Hook Form<br/>Form State]
592
+ J -->|No| L[Use useState/useReducer<br/>Local Component State]
593
+
594
+ style C fill:#e1f5ff
595
+ style F fill:#fff4e6
596
+ style G fill:#fff4e6
597
+ style I fill:#e8f5e9
598
+ style K fill:#fce4ec
599
+ style L fill:#f3e5f5
600
+ ```
601
+ ````
602
+
603
+ **Use for:** Decision-making guide, onboarding new developers, documenting state strategy
499
604
  ---
500
-
501
- ##### 2️⃣ Data Flow Sequence (API to UI)
502
-
503
- Use `sequenceDiagram` to show step-by-step data flow:
504
-
505
- ````markdown
506
- ```mermaid
507
- sequenceDiagram
508
- participant U as User
509
- participant C as Component
510
- participant S as Store/Hook
511
- participant API as API Service
512
- participant BE as Backend
513
-
514
- U->>C: Click "Load Products"
515
- C->>S: useProducts() hook
516
- S->>API: fetchProducts()
517
- API->>BE: GET /api/products
518
- BE-->>API: 200 OK + data
519
- API-->>S: Return products[]
520
- S->>S: Update cache
521
- S-->>C: products data
522
- C->>U: Render UI
523
-
524
- Note over S: TanStack Query<br/>caches for 5min
525
-
526
- U->>C: Click "Add to Cart"
527
- C->>S: addToCart(productId)
528
- S->>S: Update client state
529
- S-->>C: cart updated
530
- C->>U: Show cart badge
531
- ```
532
- ````
533
-
534
- **Use for:** Showing request/response cycles, async operations, state updates, caching behavior
535
-
605
+ **Best Practices for State Management Diagrams:**
606
+
607
+ 1. **Use Sequence Diagrams for Time-Based Flows:**
608
+ - Show async operations step-by-step
609
+ - Include caching behavior
610
+ - Document timing (e.g., "caches for 5min")
611
+
612
+ 2. **Use Graph Diagrams for Relationships:**
613
+ - State categories and their connections
614
+ - Decision trees for choosing state location
615
+ - Component-to-store relationships
616
+
617
+ 3. **Color Code by State Type:**
618
+ - Server State: `#e1f5ff` (light blue)
619
+ - Client State: `#fff4e6` (light orange)
620
+ - URL State: `#e8f5e9` (light green)
621
+ - Form State: `#fce4ec` (light pink)
622
+ - Local State: `#f3e5f5` (light purple)
623
+
624
+ 4. **Include Tool Names:** Always specify actual tools (TanStack Query, Zustand, React Hook Form, etc.)
625
+
626
+ 5. **Show Data Flow Direction:** Use solid arrows for data flow, dotted for state updates
627
+
628
+ **Common Formatting Rules:**
629
+
630
+ - Code fence: ` ```mermaid ` (lowercase, no spaces, three backticks)
631
+ - Use `sequenceDiagram` for API calls and async flows
632
+ - Use `graph TD` for decision trees
633
+ - Use `graph LR` for category relationships
634
+ - Preview at https://mermaid.live/ before saving
536
635
  ---
537
-
538
- ##### 3️⃣ State Location Decision Tree
539
-
540
- Use `graph TD` to help developers choose where to store state:
541
-
542
- ````markdown
543
- ```mermaid
544
- graph TD
545
- A[New State Needed] --> B{From Server?}
546
- B -->|Yes| C[Use TanStack Query<br/>Server State<br/>Auto-caching]
547
- B -->|No| D{Shared Across<br/>Components?}
548
- D -->|Yes| E{Needs to<br/>Persist?}
549
- E -->|Yes| F[Use Zustand +<br/>localStorage<br/>Client State]
550
- E -->|No| G[Use Zustand or<br/>Context<br/>Client State]
551
- D -->|No| H{In URL?}
552
- H -->|Yes| I[Use React Router<br/>searchParams<br/>URL State]
553
- H -->|No| J{Form Data?}
554
- J -->|Yes| K[Use React Hook Form<br/>Form State]
555
- J -->|No| L[Use useState/useReducer<br/>Local Component State]
556
-
557
- style C fill:#e1f5ff
558
- style F fill:#fff4e6
559
- style G fill:#fff4e6
560
- style I fill:#e8f5e9
561
- style K fill:#fce4ec
562
- style L fill:#f3e5f5
563
- ```
564
- ````
565
-
566
- **Use for:** Decision-making guide, onboarding new developers, documenting state strategy
567
-
636
+ ## 📊 Phase 3 Summary
637
+
638
+ ```
568
639
  ---
569
-
570
- **Best Practices for State Management Diagrams:**
571
-
572
- 1. **Use Sequence Diagrams for Time-Based Flows:**
573
- - Show async operations step-by-step
574
- - Include caching behavior
575
- - Document timing (e.g., "caches for 5min")
576
-
577
- 2. **Use Graph Diagrams for Relationships:**
578
- - State categories and their connections
579
- - Decision trees for choosing state location
580
- - Component-to-store relationships
581
-
582
- 3. **Color Code by State Type:**
583
- - Server State: `#e1f5ff` (light blue)
584
- - Client State: `#fff4e6` (light orange)
585
- - URL State: `#e8f5e9` (light green)
586
- - Form State: `#fce4ec` (light pink)
587
- - Local State: `#f3e5f5` (light purple)
588
-
589
- 4. **Include Tool Names:** Always specify actual tools (TanStack Query, Zustand, React Hook Form, etc.)
590
-
591
- 5. **Show Data Flow Direction:** Use solid arrows for data flow, dotted for state updates
592
-
593
- **Common Formatting Rules:**
594
- - Code fence: ` ```mermaid ` (lowercase, no spaces, three backticks)
595
- - Use `sequenceDiagram` for API calls and async flows
596
- - Use `graph TD` for decision trees
597
- - Use `graph LR` for category relationships
598
- - Preview at https://mermaid.live/ before saving
599
-
640
+ 📋 PHASE 3 SUMMARY: STATE MANAGEMENT
600
641
  ---
601
-
602
- ## 📊 Phase 3 Summary
603
-
604
- ```
605
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
606
- 📋 PHASE 3 SUMMARY: STATE MANAGEMENT
607
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
608
-
609
- Server State: [Answer from 3.1]
610
- Client State: [Answer from 3.2]
611
- State Persistence: [Answer from 3.3]
612
- Form Management: [Answer from 3.4]
613
- Form Validation: [Answer from 3.5]
614
- Optimistic Updates: [Answer from 3.6]
615
- Real-Time Updates: [Answer from 3.7]
616
- State Normalization: [Answer from 3.8]
617
- State Placement: [Answer from 3.9]
618
- Error Handling: [Answer from 3.10]
619
- API Error Handling: [Answer from 3.11]
620
- Retry Strategy: [Answer from 3.12]
621
-
622
- Is this correct? (Y/n)
623
- ```
624
-
642
+ Server State: [Answer from 3.1]
643
+ Client State: [Answer from 3.2]
644
+ State Persistence: [Answer from 3.3]
645
+ Form Management: [Answer from 3.4]
646
+ Form Validation: [Answer from 3.5]
647
+ Optimistic Updates: [Answer from 3.6]
648
+ Real-Time Updates: [Answer from 3.7]
649
+ State Normalization: [Answer from 3.8]
650
+ State Placement: [Answer from 3.9]
651
+ Error Handling: [Answer from 3.10]
652
+ API Error Handling: [Answer from 3.11]
653
+ Retry Strategy: [Answer from 3.12]
654
+
655
+ Is this correct? (Y/n)
656
+ ```
625
657
  ---
626
-
627
- ## 📝 Document Generation
628
-
629
- Generate `docs/state-management.md` using the template:
630
-
631
- Replace these placeholders:
632
-
633
- - `{{STATE_MANAGEMENT}}` → Client state solution (e.g., "Zustand")
634
- - `{{DATA_FETCHING}}` → Server state solution (e.g., "TanStack Query")
635
- - `{{FORM_LIBRARY}}` → Form library (e.g., "React Hook Form")
636
- - `{{FORM_VALIDATION}}` → Validation strategy (e.g., "Zod")
637
- - `{{STATE_PERSISTENCE}}` → Persistence approach
638
- - `{{OPTIMISTIC_UPDATES}}` → Yes/No
639
- - `{{REAL_TIME_STRATEGY}}` → Real-time approach
640
- - `{{STATE_NORMALIZATION}}` → Yes/No
641
- - `{{ERROR_HANDLING_STRATEGY}}` → Error handling approach
642
-
643
- Also update `ai-instructions.md`:
644
-
645
- ```markdown
646
- ## State Management
647
-
648
- - **Server State:** {{DATA_FETCHING}}
649
- - **Client State:** {{STATE_MANAGEMENT}}
650
- - **Forms:** {{FORM_LIBRARY}} with {{FORM_VALIDATION}}
651
- - **Real-Time:** {{REAL_TIME_STRATEGY}}
652
-
653
- ### Rules
654
-
655
- - ✅ ALWAYS use {{DATA_FETCHING}} for server data
656
- - ALWAYS validate forms with {{FORM_VALIDATION}}
657
- - ❌ NEVER store derived data in state
658
- - ❌ NEVER mutate state directly (use immutable updates)
659
- {{#IF_OPTIMISTIC_UPDATES}}
660
- - ✅ ALWAYS implement rollback for optimistic updates
661
- {{/IF_OPTIMISTIC_UPDATES}}
662
- ```
663
-
658
+ ## 📝 Document Generation
659
+
660
+ Generate `docs/state-management.md` using the template:
661
+
662
+ Replace these placeholders:
663
+
664
+ - `{{STATE_MANAGEMENT}}` → Client state solution (e.g., "Zustand")
665
+ - `{{DATA_FETCHING}}` → Server state solution (e.g., "TanStack Query")
666
+ - `{{FORM_LIBRARY}}` → Form library (e.g., "React Hook Form")
667
+ - `{{FORM_VALIDATION}}` → Validation strategy (e.g., "Zod")
668
+ - `{{STATE_PERSISTENCE}}` → Persistence approach
669
+ - `{{OPTIMISTIC_UPDATES}}` → Yes/No
670
+ - `{{REAL_TIME_STRATEGY}}` → Real-time approach
671
+ - `{{STATE_NORMALIZATION}}` → Yes/No
672
+ - `{{ERROR_HANDLING_STRATEGY}}` → Error handling approach
673
+
674
+ Also update `ai-instructions.md`:
675
+
676
+ ```markdown
677
+ ## State Management
678
+
679
+ - **Server State:** {{DATA_FETCHING}}
680
+ - **Client State:** {{STATE_MANAGEMENT}}
681
+ - **Forms:** {{FORM_LIBRARY}} with {{FORM_VALIDATION}}
682
+ - **Real-Time:** {{REAL_TIME_STRATEGY}}
683
+
684
+ ### Rules
685
+
686
+ - ✅ ALWAYS use {{DATA_FETCHING}} for server data
687
+ - ✅ ALWAYS validate forms with {{FORM_VALIDATION}}
688
+ - NEVER store derived data in state
689
+ - ❌ NEVER mutate state directly (use immutable updates)
690
+ {{#IF_OPTIMISTIC_UPDATES}}
691
+ - ✅ ALWAYS implement rollback for optimistic updates
692
+ {{/IF_OPTIMISTIC_UPDATES}}
693
+ ```
664
694
  ---
665
-
666
- ## 🚀 Next Steps
667
-
668
- ```
669
- ✅ Phase 3 Complete!
670
-
671
- Documents Generated:
672
- - docs/state-management.md
673
- - ai-instructions.md (updated)
674
-
675
- Next: Phase 4 - Styling & Design
676
-
677
- Read: .ai-flow/prompts/frontend/flow-build-phase-4-styling.md
678
- ```
679
-
695
+ ## 🚀 Next Steps
696
+
697
+ ```
698
+ ✅ Phase 3 Complete!
699
+
700
+ Documents Generated:
701
+ - docs/state-management.md
702
+ - ai-instructions.md (updated)
703
+
704
+ Next: Phase 4 - Styling & Design
705
+
706
+ Read: .ai-flow/prompts/frontend/flow-build-phase-4-styling.md
707
+ ```
680
708
  ---
681
-
682
- **Last Updated:** 2025-01-XX
683
-
684
- **Version:** 1.2.0
709
+ **Last Updated:** 2025-01-XX
710
+
711
+ **Version:** 1.2.0
712
+
685
713
 
686
714
 
687
715