ai-flow-dev 2.1.9 → 2.2.1

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 (77) hide show
  1. package/README.md +26 -29
  2. package/dist/cli.js +10 -4
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +278 -1738
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-10.md +1 -0
  8. package/prompts/backend/flow-build-phase-2.md +19 -0
  9. package/prompts/backend/flow-build-phase-3.md +19 -0
  10. package/prompts/backend/flow-build-phase-4.md +19 -0
  11. package/prompts/backend/flow-build-phase-5.md +19 -0
  12. package/prompts/backend/flow-build-phase-6.md +19 -0
  13. package/prompts/backend/flow-build-phase-7.md +19 -0
  14. package/prompts/backend/flow-build-phase-8.md +6 -7
  15. package/prompts/backend/flow-build-phase-9.md +15 -0
  16. package/prompts/backend/flow-build.md +59 -836
  17. package/prompts/backend/flow-check-review.md +20 -0
  18. package/prompts/backend/flow-check-test.md +14 -0
  19. package/prompts/backend/flow-check.md +65 -0
  20. package/prompts/backend/flow-commit.md +51 -0
  21. package/prompts/backend/flow-docs-sync.md +53 -53
  22. package/prompts/backend/flow-work-feature.md +42 -0
  23. package/prompts/backend/flow-work-fix.md +33 -0
  24. package/prompts/backend/flow-work-refactor.md +32 -0
  25. package/prompts/backend/flow-work-resume.md +32 -0
  26. package/prompts/backend/flow-work.md +127 -0
  27. package/prompts/frontend/flow-build-phase-0.md +323 -426
  28. package/prompts/frontend/flow-build-phase-1.md +433 -404
  29. package/prompts/frontend/flow-build-phase-10.md +33 -0
  30. package/prompts/frontend/flow-build-phase-2.md +508 -872
  31. package/prompts/frontend/flow-build-phase-3.md +629 -562
  32. package/prompts/frontend/flow-build-phase-4.md +438 -382
  33. package/prompts/frontend/flow-build-phase-5.md +559 -362
  34. package/prompts/frontend/flow-build-phase-6.md +383 -452
  35. package/prompts/frontend/flow-build-phase-7.md +818 -392
  36. package/prompts/frontend/flow-build-phase-8.md +27 -16
  37. package/prompts/frontend/flow-build-phase-9.md +94 -0
  38. package/prompts/frontend/flow-build.md +68 -414
  39. package/prompts/frontend/flow-check-review.md +20 -0
  40. package/prompts/frontend/flow-check-test.md +14 -0
  41. package/prompts/frontend/flow-check.md +65 -0
  42. package/prompts/frontend/flow-commit.md +51 -0
  43. package/prompts/frontend/flow-docs-sync.md +36 -34
  44. package/prompts/frontend/flow-work-feature.md +42 -0
  45. package/prompts/frontend/flow-work-fix.md +33 -0
  46. package/prompts/frontend/flow-work-refactor.md +32 -0
  47. package/prompts/frontend/flow-work-resume.md +32 -0
  48. package/prompts/frontend/flow-work.md +127 -0
  49. package/prompts/mobile/flow-build-phase-0.md +335 -319
  50. package/prompts/mobile/flow-build-phase-1.md +438 -493
  51. package/prompts/mobile/flow-build-phase-10.md +32 -0
  52. package/prompts/mobile/flow-build-phase-2.md +458 -464
  53. package/prompts/mobile/flow-build-phase-3.md +613 -487
  54. package/prompts/mobile/flow-build-phase-4.md +439 -258
  55. package/prompts/mobile/flow-build-phase-5.md +582 -250
  56. package/prompts/mobile/flow-build-phase-6.md +389 -359
  57. package/prompts/mobile/flow-build-phase-7.md +871 -285
  58. package/prompts/mobile/flow-build-phase-8.md +27 -16
  59. package/prompts/mobile/flow-build-phase-9.md +90 -0
  60. package/prompts/mobile/flow-build.md +67 -426
  61. package/prompts/mobile/flow-check-review.md +20 -0
  62. package/prompts/mobile/flow-check-test.md +14 -0
  63. package/prompts/mobile/flow-check.md +65 -0
  64. package/prompts/mobile/flow-commit.md +51 -0
  65. package/prompts/mobile/flow-docs-sync.md +37 -40
  66. package/prompts/mobile/flow-work-feature.md +42 -0
  67. package/prompts/mobile/flow-work-fix.md +33 -0
  68. package/prompts/mobile/flow-work-refactor.md +32 -0
  69. package/prompts/mobile/flow-work-resume.md +32 -0
  70. package/prompts/mobile/flow-work.md +127 -0
  71. package/prompts/shared/smart-skip-preflight.md +214 -0
  72. package/prompts/backend/flow-dev-commit.md +0 -829
  73. package/prompts/backend/flow-dev-feature.md +0 -1948
  74. package/prompts/backend/flow-dev-fix.md +0 -952
  75. package/prompts/backend/flow-dev-refactor.md +0 -690
  76. package/prompts/backend/flow-dev-review.md +0 -372
  77. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,937 +1,573 @@
1
- # Phase 2: Component Architecture
1
+ ## PHASE 2: Data Architecture (15-20 min)
2
2
 
3
- > **Duration:** 15-20 minutes
4
- > **Purpose:** Define UI framework, component patterns, and frontend architecture
5
- ---
6
- ## 📋 Context
3
+ > **Order for this phase:** 2.1 → 2.2 → 2.3 → 2.4 → 2.5 → 2.6 → 2.7
7
4
 
8
- You are in **Phase 2 of 7** of the frontend build process.
5
+ > **📌 Scope-based behavior:**
6
+ > - **MVP/Basic Scope:** Focus only on essential entities and basic relationships.
7
+ > - **Production-Ready Scope:** In-depth modeling including indexes, constraints, and audit fields.
9
8
 
10
- **What we're defining:**
11
- - UI Framework selection (React/Vue/Angular/Svelte/Solid)
12
- - Component architecture pattern
13
- - Component library and tooling
14
- - File organization strategy
9
+ ### Objective
15
10
 
16
- **Documents to generate:**
17
- - `docs/components.md` - Component architecture guide
18
- - `docs/architecture.md` - Frontend system architecture
19
- - Updates to `ai-instructions.md` - Tech stack section
20
- ---
21
- ## 🎯 Instructions
11
+ Design the database model, entities, and relationships.
22
12
 
23
- Ask questions **one at a time**, wait for user response before next question.
13
+ ---
24
14
 
25
- **Progress indicator:** Show "Question X/12" for each question.
15
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
26
16
 
27
- **Recommendations:** Mark with ⭐ (recommended), 🔥 (popular), (modern), 🏆 (enterprise)
28
- ---
29
- ## Question 2.1: UI Framework
17
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../shared/smart-skip-preflight.md) for the complete smart skip logic.
30
18
 
31
- **Question:** Which UI framework will you use?
19
+ **Execute Pre-Flight Check for Phase 2:**
32
20
 
33
- **Context:** This is the foundation of your frontend. Choose based on team expertise, ecosystem, and project requirements.
21
+ - **Target File**: `docs/data-model.md`
22
+ - **Phase Name**: "DATA ARCHITECTURE"
23
+ - **Key Items**: Entities, relationships, data patterns, indexes
24
+ - **Typical Gaps**: Missing entities, undocumented relationships, missing fields
34
25
 
35
- **Options:**
26
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
36
27
 
37
- A) ⭐ **React 18+** (Recommended - Largest ecosystem)
38
- - Functional components + hooks
39
- - Virtual DOM, component-based architecture
40
- - Massive ecosystem (Next.js, Remix for SSR)
41
- - Best for: Teams with React experience, large apps
42
- - Meta-frameworks: Next.js 14+, Remix 2+, Vite
28
+ ---
43
29
 
44
- B) 🔥 **Vue 3** (Popular - Progressive framework)
45
- - Composition API + reactivity system
46
- - Single-file components (.vue)
47
- - Excellent documentation
48
- - Best for: Rapid development, gradual adoption
49
- - Meta-framework: Nuxt 3
30
+ ## Phase 2 Questions (Full Mode)
50
31
 
51
- C) 🏆 **Angular 17+** (Enterprise - Batteries included)
52
- - TypeScript-first, opinionated
53
- - Dependency injection, RxJS
54
- - Complete framework (router, HTTP, forms included)
55
- - Best for: Large teams, enterprise apps
56
- - Meta-framework: Analog (experimental)
32
+ **2.1 Database Type**
57
33
 
58
- D) ⚡ **Svelte 4 / SvelteKit** (Modern - Compiler-based)
59
- - No virtual DOM, compiles to vanilla JS
60
- - Less boilerplate, reactive by default
61
- - Best for: Performance-critical apps
62
- - Meta-framework: SvelteKit
34
+ ```
35
+ [If detected from Phase 0, show:]
36
+ Database Detected: [PostgreSQL/MySQL/MongoDB/etc.]
37
+ Version: [version if found]
38
+ ORM/Client: [Prisma/TypeORM/Sequelize/SQLAlchemy/etc.]
63
39
 
64
- E) 🚀 **Solid.js** (Modern - Fine-grained reactivity)
65
- - JSX syntax, no virtual DOM
66
- - Blazing fast performance
67
- - Best for: Performance enthusiasts
68
- - Meta-framework: SolidStart
40
+ Is this correct? (Y/N)
41
+ If no, please provide correct database type.
69
42
 
70
- **Your choice:** (A/B/C/D/E)
43
+ [If NOT detected, ask:]
44
+ What type of database will you use? (Can select multiple)
71
45
 
72
- **Follow-up if A (React):**
73
- - **Meta-framework:** Next.js 14+ / Remix 2 / Create React App / Vite?
74
- - **Version:** React 18.2+ (latest stable)
46
+ A) ⭐ PostgreSQL - Recommended for most backends (ACID, relational, JSON support)
47
+ B) 🔥 MySQL/MariaDB - Popular, proven, wide ecosystem
48
+ C) ⚡ MongoDB - Modern, NoSQL, flexible schema
49
+ D) 🏆 Multi-database - PostgreSQL + Redis + S3, etc.
50
+ E) Other: [specify]
75
51
 
76
- **Follow-up if B (Vue):**
77
- - **Meta-framework:** Nuxt 3 / Vite?
78
- - **Version:** Vue 3.4+ (latest stable)
79
-
80
- **Follow-up if C (Angular):**
81
- - **Version:** Angular 17+ (latest stable with signals)
82
-
83
- **Follow-up if D (Svelte):**
84
- - **Meta-framework:** SvelteKit (recommended) / Vite?
85
- - **Version:** Svelte 4+ (latest stable)
86
-
87
- **Follow-up if E (Solid):**
88
- - **Meta-framework:** SolidStart / Vite?
89
- - **Version:** Solid 1.8+ (latest stable)
90
- ---
91
- ## Question 2.2: TypeScript
92
-
93
- **Question:** Will you use TypeScript?
94
-
95
- **Context:** TypeScript adds static typing, improving code quality and developer experience.
96
-
97
- **Options:**
98
-
99
- A) ⭐ **Yes, strict mode** (Recommended)
100
- - `"strict": true` in tsconfig.json
101
- - Maximum type safety
102
- - Best for: Production apps, large codebases
103
-
104
- B) **Yes, relaxed mode**
105
- - Some strict options disabled
106
- - Gradual typing adoption
107
- - Best for: Migrating from JavaScript
108
-
109
- C) **No, JavaScript only**
110
- - Pure JavaScript
111
- - Best for: Small projects, prototypes
112
-
113
- **Your choice:** (A/B/C)
114
-
115
- **If Yes:** TypeScript 5.3+ (latest stable)
116
- ---
117
- ## Question 2.3: Build Tool
118
-
119
- **Question:** Which build tool will you use?
120
-
121
- **Context:** Modern build tools provide fast development and optimized production builds.
122
-
123
- **Options:**
124
-
125
- A) ⭐ **Vite** (Recommended - Lightning fast)
126
- - Instant HMR, ESM-based
127
- - Optimized production builds
128
- - Best for: Modern apps, all frameworks
129
-
130
- B) **Webpack 5**
131
- - Mature, highly configurable
132
- - Large ecosystem of loaders/plugins
133
- - Best for: Complex build requirements
134
-
135
- C) **Turbopack** (Next.js only)
136
- - Rust-based, ultra-fast
137
- - Integrated with Next.js 13+
138
- - Best for: Next.js projects
139
-
140
- D) **esbuild**
141
- - Extremely fast Go-based bundler
142
- - Minimal configuration
143
- - Best for: Simple builds
144
-
145
- E) **Framework default**
146
- - Use whatever the meta-framework provides
147
- - (e.g., Next.js has built-in bundler)
148
-
149
- **Your choice:** (A/B/C/D/E)
150
- ---
151
- ## Question 2.4: Component Architecture Pattern
152
-
153
- **Question:** How will you organize components?
154
-
155
- **Context:** Component organization impacts maintainability and scalability.
156
-
157
- **Options:**
158
-
159
- A) ⭐ **Atomic Design** (Recommended - Scalable)
160
- - Atoms → Molecules → Organisms → Templates → Pages
161
- - Clear hierarchy, highly reusable
162
- - Best for: Design systems, large apps
163
- - Example:
164
- ```
165
- components/
166
- atoms/ (Button, Input, Label)
167
- molecules/ (SearchBar, FormField)
168
- organisms/ (Header, UserCard, DataTable)
169
- templates/ (MainLayout, DashboardLayout)
170
- pages/ (actual routes)
171
- ```
172
-
173
- B) **Feature-based** (Domain-driven)
174
- - Components organized by feature/domain
175
- - Co-located code (components + hooks + tests)
176
- - Best for: Feature-rich apps, microfront ends
177
- - Example:
178
- ```
179
- features/
180
- auth/ (LoginForm, RegisterForm, hooks, services)
181
- dashboard/ (DashboardView, widgets, hooks)
182
- profile/ (ProfileForm, settings, hooks)
183
- ```
184
-
185
- C) **Flat structure** (Simple)
186
- - All components in one folder
187
- - Minimal hierarchy
188
- - Best for: Small apps, prototypes
189
- - Example:
190
- ```
191
- components/ (all components here)
192
- ```
193
-
194
- D) **Hybrid** (Mix of Atomic + Feature-based)
195
- - Shared components in atomic structure
196
- - Feature-specific in feature folders
197
- - Best for: Large, complex apps
198
- - Example:
199
- ```
200
- components/shared/ (atomic design)
201
- features/ (feature-specific components)
202
- ```
203
-
204
- **Your choice:** (A/B/C/D)
205
- ---
206
- #### 🎨 MERMAID COMPONENT DIAGRAM FORMATS - CRITICAL
207
-
208
- **Use these exact formats** for frontend component diagrams mentioned in documentation:
209
- ---
210
- ##### 1️⃣ Component Hierarchy (Atomic Design)
211
-
212
- Use `graph TD` to show component organization from pages down to atoms:
213
-
214
- ````markdown
215
- ```mermaid
216
- graph TD
217
- subgraph "Pages"
218
- P1[HomePage]
219
- P2[ProductPage]
220
- P3[CheckoutPage]
221
- end
222
-
223
- subgraph "Organisms"
224
- H[Header]
225
- HG[HeroSection]
226
- PL[ProductList]
227
- CF[CheckoutForm]
228
- F[Footer]
229
- end
230
-
231
- subgraph "Molecules"
232
- N[NavBar]
233
- S[SearchBar]
234
- PC[ProductCard]
235
- FI[FormInput]
236
- end
237
-
238
- subgraph "Atoms"
239
- B[Button]
240
- I[Input]
241
- L[Logo]
242
- IC[Icon]
243
- end
244
-
245
- P1 --> H
246
- P1 --> HG
247
- P1 --> F
248
- P2 --> H
249
- P2 --> PL
250
- P2 --> F
251
- P3 --> H
252
- P3 --> CF
253
- P3 --> F
254
-
255
- H --> N
256
- H --> L
257
- HG --> S
258
- PL --> PC
259
- CF --> FI
260
-
261
- N --> B
262
- S --> I
263
- S --> B
264
- PC --> B
265
- PC --> IC
266
- FI --> I
267
- FI --> L
268
-
269
- style P1 fill:#e1f5ff
270
- style P2 fill:#e1f5ff
271
- style P3 fill:#e1f5ff
272
- style H fill:#fff4e6
273
- style F fill:#fff4e6
274
- style N fill:#e8f5e9
275
- style B fill:#fce4ec
276
- ```
277
- ````
278
-
279
- **Use for:** Showing component organization, Atomic Design hierarchy, composition patterns
280
- ---
281
- ##### 2️⃣ Component Tree with Props/Events
282
-
283
- Use `graph LR` to show parent-child relationships and data flow:
284
-
285
- ````markdown
286
- ```mermaid
287
- graph LR
288
- subgraph "Parent Component"
289
- P[UserDashboard]
290
- end
291
-
292
- subgraph "Child Components"
293
- H[UserHeader]
294
- PR[UserProfile]
295
- AF[ActivityFeed]
296
- S[Sidebar]
297
- end
298
-
299
- subgraph "Grandchild Components"
300
- A[Avatar]
301
- E[EditButton]
302
- AI[ActivityItem]
303
- end
304
-
305
- P -->|user: User| H
306
- P -->|user: User| PR
307
- P -->|activities: Activity[]| AF
308
- P -->|menuItems: MenuItem[]| S
309
-
310
- H --> A
311
- H --> E
312
- AF --> AI
313
-
314
- E -.->|onEdit(userId)| P
315
- AI -.->|onLike(activityId)| AF
316
- AF -.->|onUpdate()| P
317
-
318
- style P fill:#e1f5ff
319
- style H fill:#fff4e6
320
- style PR fill:#fff4e6
321
- style AF fill:#fff4e6
322
- style S fill:#fff4e6
323
- ```
324
- ````
325
-
326
- **Notation:**
327
- - Solid arrow `-->|prop: Type|` = Props passed down
328
- - Dotted arrow `-.->|event(args)|` = Events bubbled up
329
- - Group related components in subgraphs
330
-
331
- **Use for:** Documenting data flow, props drilling, event handling patterns
332
- ---
333
- ##### 3️⃣ Component File Organization
334
-
335
- Use `graph TB` to show file/folder structure:
336
-
337
- ````markdown
338
- ```mermaid
339
- graph TB
340
- subgraph "src/components/"
341
- subgraph "pages/"
342
- HP[HomePage.tsx]
343
- PP[ProductPage.tsx]
344
- end
345
-
346
- subgraph "organisms/"
347
- H[Header/]
348
- PL[ProductList/]
349
- end
350
-
351
- subgraph "molecules/"
352
- N[NavBar/]
353
- PC[ProductCard/]
354
- end
355
-
356
- subgraph "atoms/"
357
- B[Button/]
358
- I[Input/]
359
- end
360
- end
361
-
362
- HP -.-> H
363
- HP -.-> PL
364
- H -.-> N
365
- PL -.-> PC
366
- PC -.-> B
367
-
368
- style pages fill:#e1f5ff
369
- style organisms fill:#fff4e6
370
- style molecules fill:#e8f5e9
371
- style atoms fill:#fce4ec
372
- ```
373
- ````
374
-
375
- **Use for:** Showing folder structure, import relationships, file organization patterns
376
- ---
377
- ##### 4️⃣ Application Routing Structure
378
-
379
- Use `graph TD` to show route hierarchy:
380
-
381
- ````markdown
382
- ```mermaid
383
- graph TD
384
- ROOT[/ Root Layout] --> PUBLIC[Public Routes]
385
- ROOT --> AUTH[Protected Routes]
386
-
387
- PUBLIC --> HOME[/]
388
- PUBLIC --> LOGIN[/auth/login]
389
- PUBLIC --> REGISTER[/auth/register]
390
- PUBLIC --> RESET[/auth/reset-password]
391
-
392
- AUTH --> DASH[/dashboard]
393
- AUTH --> PROF[/profile]
394
- AUTH --> SETTINGS[/settings]
395
-
396
- DASH --> OVERVIEW[/dashboard/overview]
397
- DASH --> ANALYTICS[/dashboard/analytics]
398
- DASH --> REPORTS[/dashboard/reports]
399
-
400
- PROF --> VIEW[/profile/:userId]
401
- PROF --> EDIT[/profile/:userId/edit]
402
-
403
- SETTINGS --> ACCOUNT[/settings/account]
404
- SETTINGS --> PREFS[/settings/preferences]
405
-
406
- style ROOT fill:#e1f5ff
407
- style PUBLIC fill:#e8f5e9
408
- style AUTH fill:#fff4e6
409
- ```
410
- ````
411
-
412
- **Use for:** Documenting route structure, showing protected routes, nested routing patterns
413
- ---
414
- **Best Practices for Component Diagrams:**
415
-
416
- 1. **Color Code by Abstraction Level:**
417
- - Pages/Routes: `#e1f5ff` (light blue)
418
- - Organisms: `#fff4e6` (light orange)
419
- - Molecules: `#e8f5e9` (light green)
420
- - Atoms: `#fce4ec` (light pink)
421
-
422
- 2. **Use Subgraphs:** Group related components by type or feature
423
- 3. **Show Relationships:** Use solid arrows for composition, dotted for communication
424
- 4. **Label Props:** Include TypeScript types when helpful (`user: User`, `items: Product[]`)
425
- 5. **Keep It Readable:** Avoid overcrowding, use clear naming
426
-
427
- **Common Formatting Rules:**
428
- - Code fence: ` ```mermaid ` (lowercase, no spaces, three backticks)
429
- - Start Mermaid syntax at column 0 (no indentation before code block)
430
- - Use consistent colors across diagrams
431
- - Preview at https://mermaid.live/ before saving
432
- ---
433
- ## Question 2.5: Component Library
434
-
435
- **Question:** Will you use a component library?
436
-
437
- **Context:** Component libraries provide pre-built, accessible components.
438
-
439
- **Options:**
440
-
441
- **For React:**
442
- A) ⭐ **Material UI (MUI)** - Comprehensive, Material Design
443
- B) 🔥 **Chakra UI** - Accessible, themeable, modern
444
- C) **shadcn/ui** - Copy-paste components, full control
445
- D) **Ant Design** - Enterprise-focused, complete
446
- E) **Headless UI** - Unstyled, accessible primitives
447
- F) **None** - Build custom components
448
-
449
- **For Vue:**
450
- A) ⭐ **Vuetify** - Material Design, comprehensive
451
- B) **Quasar** - Full framework, multiple platforms
452
- C) **Element Plus** - Enterprise-focused
453
- D) **PrimeVue** - Rich component set
454
- E) **Headless UI Vue** - Unstyled primitives
455
- F) **None** - Build custom components
456
-
457
- **For Angular:**
458
- A) ⭐ **Angular Material** - Official, Material Design
459
- B) **PrimeNG** - Rich component set
460
- C) **NG-ZORRO** - Ant Design for Angular
461
- D) **None** - Build custom components
462
-
463
- **For Svelte:**
464
- A) **Skeleton** - Full-featured UI toolkit
465
- B) **Carbon Components Svelte** - IBM Design
466
- C) **Svelte Material UI** - Material Design
467
- D) **None** - Build custom components
468
-
469
- **For Solid:**
470
- A) **Hope UI** - Chakra-inspired for Solid
471
- B) **Solid UI** - Minimalist component library
472
- C) **None** - Build custom components
473
-
474
- **Your choice:** (specify library or None)
475
- ---
476
- ## Question 2.6: State Management
477
-
478
- **Question:** How will you manage global state?
479
-
480
- **Context:** Choose based on app complexity and team preference.
481
-
482
- **Options:**
483
-
484
- **For React:**
485
- A) ⭐ **Zustand** (Recommended - Simple, modern)
486
- - Minimal boilerplate, hooks-based
487
- - Best for: Most apps
488
- B) **Redux Toolkit** - Predictable, DevTools
489
- - Best for: Complex state, time-travel debugging
490
- C) **Jotai** - Atomic state management
491
- - Best for: Fine-grained state control
492
- D) **Context API** - Built-in React
493
- - Best for: Simple global state (theme, auth)
494
- E) **None** - Local state only (useState, useReducer)
495
-
496
- **For Vue:**
497
- A) ⭐ **Pinia** (Recommended - Official)
498
- - TypeScript-first, simple API
499
- - Best for: Most Vue 3 apps
500
- B) **Vuex 4** - Classic Vue state management
501
- - Best for: Existing Vuex apps
502
- C) **Composition API + provide/inject**
503
- - Built-in Vue, simple
504
- - Best for: Small to medium apps
505
-
506
- **For Angular:**
507
- A) ⭐ **NgRx** (Recommended - Redux for Angular)
508
- - Reactive, RxJS-based
509
- - Best for: Enterprise Angular apps
510
- B) **Akita** - Simple, object-oriented
511
- - Best for: Easier learning curve
512
- C) **Services + RxJS** - Angular built-in
513
- - Best for: Simple state needs
514
-
515
- **For Svelte:**
516
- A) ⭐ **Svelte Stores** (Built-in, recommended)
517
- - Reactive stores, simple API
518
- - Best for: Most Svelte apps
519
- B) **None** - Component state only
520
-
521
- **For Solid:**
522
- A) ⭐ **Solid Store** (Built-in, recommended)
523
- - Fine-grained reactivity
524
- - Best for: Most Solid apps
525
- B) **None** - Signals only
526
-
527
- **Your choice:** (specify option)
528
- ---
529
- ## Question 2.7: Data Fetching
530
-
531
- **Question:** How will you fetch and cache server data?
532
-
533
- **Context:** Modern data fetching libraries handle caching, revalidation, and loading states.
534
-
535
- **Options:**
536
-
537
- A) ⭐ **TanStack Query (React Query)** (Recommended)
538
- - Works with React, Vue, Svelte, Solid
539
- - Automatic caching, background updates
540
- - Best for: REST APIs, GraphQL
541
- - Features: Pagination, infinite scroll, optimistic updates
542
-
543
- B) **SWR** (Stale-While-Revalidate)
544
- - Lightweight, hooks-based (React)
545
- - Best for: Simple data fetching
546
-
547
- C) **Apollo Client** (GraphQL only)
548
- - Complete GraphQL client
549
- - Best for: GraphQL APIs
550
-
551
- D) **RTK Query** (Redux Toolkit)
552
- - Integrated with Redux
553
- - Best for: Redux-based apps
554
-
555
- E) **Axios + manual caching**
556
- - Traditional approach
557
- - Best for: Simple apps
558
-
559
- F) **Native fetch + useState**
560
- - No dependencies
561
- - Best for: Minimal apps
562
-
563
- **Your choice:** (A/B/C/D/E/F)
564
- ---
565
- ## Question 2.8: Routing
566
-
567
- **Question:** How will you handle routing?
568
-
569
- **Context:** Most meta-frameworks include routing. For SPAs, you need a routing library.
570
-
571
- **Options:**
572
-
573
- **If using meta-framework (Next.js, Nuxt, SvelteKit, etc.):**
574
- - ⭐ **Use built-in file-based routing** (Recommended)
575
- - pages/ directory = routes
576
- - No configuration needed
577
-
578
- **If building SPA:**
579
-
580
- **For React:**
581
- A) ⭐ **React Router 6+** (Recommended)
582
- - Industry standard
583
- - Data loading, nested routes
584
- B) **TanStack Router**
585
- - Type-safe, modern
586
- - Best for: TypeScript-heavy apps
587
- C) **Wouter**
588
- - Tiny, minimalist
589
- - Best for: Small apps
590
-
591
- **For Vue:**
592
- A) ⭐ **Vue Router 4** (Official, recommended)
593
- - Composition API support
594
- - Nested routes, guards
595
-
596
- **For Angular:**
597
- A) ⭐ **Angular Router** (Built-in, only option)
598
-
599
- **For Svelte:**
600
- A) ⭐ **SvelteKit routing** (Built-in)
601
- B) **Page.js** (for non-SvelteKit SPAs)
602
-
603
- **For Solid:**
604
- A) ⭐ **Solid Router** (Official)
605
- B) **@solidjs/router**
606
-
607
- **Your choice:** (specify router or "meta-framework built-in")
608
- ---
609
- ## Question 2.9: Form Management
610
-
611
- **Question:** How will you handle complex forms?
612
-
613
- **Context:** Form libraries handle validation, errors, and submission state.
52
+ Why this choice?
53
+ ```
614
54
 
615
- **Options:**
55
+ **2.2 Core Data Entities**
616
56
 
617
- **For React:**
618
- A) **React Hook Form** (Recommended)
619
- - Minimal re-renders, performance-focused
620
- - Best for: Complex forms
621
- B) **Formik**
622
- - Popular, full-featured
623
- - Best for: Traditional form handling
624
- C) **Native HTML forms**
625
- - No library
626
- - Best for: Simple forms
57
+ ```
58
+ [If detected from Phase 0, show:]
59
+ Entities Detected from Code:
60
+ - [User] - [description if inferred from code]
61
+ - [Product] - [description]
62
+ - [Order] - [description]
63
+ - [etc.]
64
+
65
+ Are these correct? (Y/N)
66
+ Do you need to add more entities? (Y/N)
67
+
68
+ [If NOT detected OR user wants to add more, show:]
69
+ Based on your system type (from Phase 1, question 1.5), here are common entities:
70
+
71
+ 🛒 E-commerce typical entities:
72
+ 1) User - System users with authentication
73
+ 2) Product - Items available for purchase
74
+ 3) Category - Product categorization
75
+ 4) Cart - Shopping cart items
76
+ 5) Order - Customer orders
77
+ 6) OrderItem - Individual items in an order
78
+ 7) Payment - Payment transactions
79
+ 8) Address - Shipping/billing addresses
80
+ 9) Review - Product reviews and ratings
81
+ 10) Inventory - Stock tracking
82
+
83
+ 📱 SaaS typical entities:
84
+ 1) User - System users
85
+ 2) Organization - Tenant/workspace
86
+ 3) Team - Groups within organizations
87
+ 4) Role - Access control roles
88
+ 5) Permission - Granular permissions
89
+ 6) Subscription - Billing plans
90
+ 7) Invoice - Payment records
91
+ 8) ApiKey - API access credentials
92
+ 9) AuditLog - Activity tracking
93
+
94
+ 📊 CRM typical entities:
95
+ 1) User - System users
96
+ 2) Contact - Customers/leads
97
+ 3) Company - Organizations
98
+ 4) Deal - Sales opportunities
99
+ 5) Activity - Calls, emails, meetings
100
+ 6) Task - To-do items
101
+ 7) Note - Free-form notes
102
+ 8) Document - Attachments
103
+
104
+ 🎮 Social typical entities:
105
+ 1) User - Platform users
106
+ 2) Profile - User profiles
107
+ 3) Post - Content/publications
108
+ 4) Comment - Post comments
109
+ 5) Like/Reaction - Engagement
110
+ 6) Follow - User connections
111
+ 7) Notification - User alerts
112
+ H) Message - Direct messages
113
+ I) Group - Communities
114
+
115
+ → Your selection (e.g., A, C, F): __
116
+
117
+ OR list your custom entities:
118
+
119
+ 1.
120
+ 2.
121
+ 3.
122
+ 4.
123
+ 5.
124
+ ...
125
+
126
+ (Include brief description for custom entities)
127
+ ```
627
128
 
628
- **For Vue:**
629
- A) ⭐ **VeeValidate 4**
630
- - Composition API, flexible
631
- - Best for: Complex forms
632
- B) **Native v-model**
633
- - Built-in Vue
634
- - Best for: Simple forms
129
+ **2.3 Relationships**
635
130
 
636
- **For Angular:**
637
- A) **Reactive Forms** (Built-in, recommended)
638
- - Strongly typed, testable
639
- B) **Template-driven Forms**
640
- - Simpler, less control
131
+ ```
132
+ Common relationship patterns (select what applies to your entities):
641
133
 
642
- **For Svelte:**
643
- A) **Svelte Native** (bind:value)
644
- - Built-in two-way binding
645
- - Best for: Most forms
646
- B) **Felte** - Form library for Svelte
134
+ One-to-Many (most common):
135
+ A) User Order (one user has many orders)
136
+ B) User Post (one user creates many posts)
137
+ C) Organization User (one org has many users)
138
+ D) Category Product (one category contains many products)
139
+ E) Order → OrderItem (one order has many line items)
140
+ F) Post → Comment (one post has many comments)
141
+ G) Other: __
647
142
 
648
- **For Solid:**
649
- A) **Solid Forms**
650
- - Form library for Solid
651
- B) **Native** - Solid signals
143
+ Your selection (e.g., A, B, D): __
652
144
 
653
- **Your choice:** (specify library or native)
654
- ---
655
- ## Question 2.10: Styling Approach
145
+ Many-to-Many (via join table):
146
+ A) Order ↔ Product (via OrderItem)
147
+ B) User Role (via UserRole)
148
+ E) Course ↔ Student (via Enrollment)
149
+ F) Other: __
656
150
 
657
- **Question:** How will you style components?
151
+ Your selection (e.g., A, C, E): __
658
152
 
659
- **Context:** Choose based on team preference, design system needs, and performance requirements.
153
+ One-to-One (less common):
660
154
 
661
- **Options:**
155
+ ⭐ One-to-One (less common):
156
+ C) Order → Payment (one order has one payment)
157
+ D) Other: __
662
158
 
663
- A) **Tailwind CSS** (Recommended - Utility-first)
664
- - Rapid development, consistent design
665
- - JIT compiler, small bundle
666
- - Best for: Most modern apps
667
-
668
- B) **CSS Modules** (Scoped CSS)
669
- - Standard CSS, locally scoped
670
- - Best for: Traditional CSS developers
671
-
672
- C) **Styled Components / Emotion** (CSS-in-JS)
673
- - Dynamic styles, themed
674
- - Best for: Component libraries
159
+ Your selection (e.g., A, B): __
675
160
 
676
- D) **Sass/SCSS** (CSS preprocessor)
677
- - Variables, mixins, nesting
678
- - Best for: Traditional workflow
679
-
680
- E) **Vanilla CSS** (Plain CSS files)
681
- - No dependencies
682
- - Best for: Simple apps
683
-
684
- F) **UnoCSS** (Instant atomic CSS)
685
- - Faster than Tailwind
686
- - Best for: Performance enthusiasts
161
+ Polymorphic (one entity relates to multiple types):
162
+ C) Activity → (User | Organization | Deal) - activities linked to various objects
163
+ D) Other: __
687
164
 
688
- **Your choice:** (A/B/C/D/E/F)
165
+ Your selection (e.g., A, C): __
166
+ ---
167
+ Your specific relationships (list main ones):
168
+ ---
169
+ Your specific relationships (list main ones):
170
+ -
171
+ -
172
+ -
689
173
 
690
- **If Tailwind:** Will you use any Tailwind plugins? (typography, forms, etc.)
691
- ---
692
- ## Question 2.11: Design Tokens / Theming
174
+ (Format: EntityA EntityB: Relationship type - description)
175
+ ```
693
176
 
694
- **Question:** Will you use design tokens for theming?
177
+ **2.4 Data Volume Estimates**
695
178
 
696
- **Context:** Design tokens centralize colors, spacing, typography for consistency.
179
+ ```
180
+ Estimated data volume (Year 1):
697
181
 
698
- **Options:**
182
+ - Total records: [Low (<10k) / Medium (10k-1M) / High (>1M)]
183
+ - Growth rate: [Slow / Moderate / Fast]
699
184
 
700
- A) **Yes, CSS Variables** (Recommended)
701
- - Dynamic theming, runtime changes
702
- - Example:
703
- ```css
704
- :root {
705
- --color-primary: #3B82F6;
706
- --spacing-md: 1rem;
707
- }
708
- ```
709
-
710
- B) **Yes, JavaScript/TypeScript tokens**
711
- - Exported constants
712
- - Type-safe
713
-
714
- C) **Yes, Component library tokens**
715
- - Use library's theming system (MUI, Chakra, etc.)
716
-
717
- D) **No, hardcoded values**
718
- - Direct colors/sizes in styles
719
- - Best for: Small apps
720
-
721
- **Your choice:** (A/B/C/D)
722
-
723
- **If Yes to tokens:**
724
- - Will you support dark mode? (Yes/No)
725
- - Will you support multiple themes? (Yes/No/Maybe later)
726
- ---
727
- ## Question 2.12: Testing Strategy
728
-
729
- **Question:** What will you test in components?
730
-
731
- **Context:** Testing ensures components work correctly and don't break.
732
-
733
- **Options:**
734
-
735
- A) ⭐ **Unit + Component + E2E** (Recommended - Comprehensive)
736
- - Unit: Vitest / Jest
737
- - Component: Testing Library (React/Vue/Svelte Testing Library)
738
- - E2E: Playwright / Cypress
739
- - Best for: Production apps
185
+ Data Complexity (Record Size):
186
+ A) 📄 Low - Mostly text data (JSON, strings)
187
+ B) 🖼️ Medium - Some images/documents (blobs, small files)
188
+ C) 🎥 High - Heavy media/large files (video, audio, raw data)
740
189
 
741
- B) **Component + E2E** (Pragmatic)
742
- - Skip pure unit tests
743
- - Focus on user behavior
744
- - Best for: Most apps
190
+ Standard for MVP:
191
+ - Records: Low (<10k)
192
+ - Growth: Moderate
193
+ - Complexity: Low (mostly text)
745
194
 
746
- C) **E2E only** (High-level)
747
- - Test critical user paths
748
- - Best for: Small apps, MVPs
195
+ 🏆 Standard for Production/Scale:
196
+ - Records: High (>1M)
197
+ - Growth: Fast
198
+ - Complexity: Medium/High (includes media/files)
199
+ ```
749
200
 
750
- D) **Minimal** (Unit only)
751
- - Test utilities and hooks only
752
- - Best for: Prototypes
201
+ **2.5 Data Retention**
753
202
 
754
- **Your choice:** (A/B/C/D)
203
+ ```
204
+ Data retention policies:
755
205
 
756
- **Component testing framework:**
757
- - **React:** React Testing Library (recommended)
758
- - **Vue:** Vue Test Utils
759
- - **Angular:** Jasmine/Karma (built-in)
760
- - **Svelte:** Svelte Testing Library
761
- - **Solid:** Solid Testing Library
762
-
763
- **E2E testing framework:**
764
- - ⭐ **Playwright** (Recommended - Modern, fast)
765
- - **Cypress** (Popular, DX-focused)
766
- - **None** - Skip E2E for now
767
- ---
768
- ## Question 2.13: API Integration Pattern
769
-
770
- **Question:** How will you integrate with backend APIs?
771
-
772
- **Context:** Define how your frontend communicates with backend services.
773
-
774
- **Options:**
775
-
776
- A) ⭐ **REST API with Fetch/Axios**
777
- - Standard REST endpoints
778
- - Client: Axios, Fetch API, or custom wrapper
779
- - Best for: Most apps, simple integration
780
- - Example: `GET /api/users`, `POST /api/users`
781
-
782
- B) **GraphQL with Apollo/urql**
783
- - Single endpoint, flexible queries
784
- - Client: Apollo Client, urql, or TanStack Query GraphQL
785
- - Best for: Complex data requirements, mobile apps
786
- - Example: `query { users { id name } }`
787
-
788
- C) **tRPC (TypeScript RPC)**
789
- - End-to-end type safety
790
- - Best for: TypeScript monorepos, type-safe APIs
791
- - Example: `trpc.users.getById.useQuery({ id: '1' })`
792
-
793
- D) **gRPC-Web**
794
- - Protocol buffers, efficient binary format
795
- - Best for: High-performance, microservices
796
- - Example: `client.getUser({ id: '1' })`
797
-
798
- **Your choice:** (A/B/C/D)
799
-
800
- **If REST selected:**
801
- - **API Client:** Axios / Fetch API / Custom wrapper
802
- - **Base URL:** __
803
- - **Request interceptors:** [Auth headers, error handling, logging]
804
- - **Response interceptors:** [Error transformation, token refresh]
805
-
806
- **If GraphQL selected:**
807
- - **Client:** Apollo Client / urql / TanStack Query GraphQL
808
- - **Endpoint:** __
809
- - **Subscriptions:** [Yes/No - Real-time updates]
810
-
811
- **API Layer Pattern:**
812
- A) ⭐ **Service Layer** - Separate API functions
813
- ```
814
- services/
815
- api.ts (base client)
816
- users.ts (user endpoints)
817
- products.ts (product endpoints)
818
- ```
819
-
820
- B) **Hooks/Composables Layer** - API calls in hooks
821
- ```
822
- hooks/
823
- useUsers.ts (API calls + state)
824
- useProducts.ts
825
- ```
826
-
827
- C) **Both** - Services + Hooks
828
- ```
829
- services/ (API functions)
830
- hooks/ (React hooks/Vue composables)
831
- ```
832
-
833
- **Your choice:** (A/B/C)
834
- ---
835
- ## Question 2.14: Error Boundaries / Global Error Handling
836
-
837
- **Question:** How will you handle global errors?
838
-
839
- **Context:** Catch and handle errors that occur during rendering, lifecycle methods, and constructors.
206
+ A) ♾️ Keep forever - Never delete data
207
+ B) 🗓️ Regulatory compliance - Specific retention period (e.g., 7 years)
208
+ C) 🔄 Archival strategy - Archive old data after __ months
209
+ D) 🗑️ Auto-deletion - Delete after __ days/months
840
210
 
841
- **Options:**
842
-
843
- **For React:**
844
- A) ⭐ **Error Boundaries** (Recommended)
845
- - Catch component tree errors
846
- - Show fallback UI
847
- - Best for: React apps
848
- - Example: `<ErrorBoundary><App /></ErrorBoundary>`
211
+ For each entity that has special retention needs, specify:
212
+ ```
849
213
 
850
- B) **Global Error Handler + Error Boundary**
851
- - Window error handler + Error Boundaries
852
- - Best for: Comprehensive error handling
214
+ **2.6 Data Migration**
853
215
 
854
- **For Vue:**
855
- A) **errorHandler** (Built-in)
856
- - Global error handler
857
- - Best for: Vue apps
858
- - Example: `app.config.errorHandler = (err, instance, info) => { ... }`
216
+ ```
217
+ Is this a new system or replacing an existing one?
859
218
 
860
- **For Angular:**
861
- A) **ErrorHandler** (Built-in)
862
- - Global error handler service
863
- - Best for: Angular apps
219
+ A) 🆕 New system - No legacy data
220
+ B) 🔄 Replacing existing - Need to migrate from [system name]
221
+ C) 🔌 Integration - Syncing with existing system
864
222
 
865
- **Error Recovery Strategy:**
866
- A) ⭐ **Show fallback UI** - Display error message, retry button
867
- B) **Redirect to error page** - Navigate to `/error`
868
- C) **Log and continue** - Log error, show minimal notification
869
- D) **Combined** - Different strategies for different error types
223
+ If migration needed:
224
+ - Source system: __
225
+ - Data volume to migrate: __
226
+ - Migration strategy: [Big bang / Phased / Parallel run]
227
+ ```
870
228
 
871
- **Error Logging:**
872
- - **Tool:** Sentry / LogRocket / Console only
873
- - **What to log:** [Error message, stack trace, user context, component tree]
874
-
875
- **Your answer:**
876
- ---
877
- ## 📝 Phase 2 Summary
878
-
879
- After all questions, show summary:
229
+ **2.7 Critical Data Patterns**
880
230
 
881
231
  ```
882
- ---
883
- PHASE 2 SUMMARY: Component Architecture
884
- ---
885
- UI Framework: {{UI_FRAMEWORK}} {{VERSION}}
886
- Meta-framework: {{META_FRAMEWORK}}
887
- Build Tool: {{BUILD_TOOL}}
888
- TypeScript: {{TYPESCRIPT}}
232
+ Select data patterns that apply:
233
+
234
+ A) 🔐 Soft deletes - Keep deleted records with deleted_at flag
235
+ B) 📝 Audit trail - Track who changed what and when
236
+ C) 🕐 Temporal data - Track historical versions
237
+ D) 🌍 Multi-tenancy - Data isolation per customer/organization
238
+ E) 🎭 Polymorphic relationships - One entity relates to multiple types
239
+ F) 🔗 Graph relationships - Complex many-to-many networks
240
+ G) 📊 Aggregations/Materialized views - Pre-computed summaries
241
+ H) 🗂️ Partitioning - Split large tables by date/region/etc.
242
+
243
+ For each selected, provide brief detail:
244
+ ```
889
245
 
890
- Component Pattern: {{COMPONENT_PATTERN}}
891
- Component Library: {{COMPONENT_LIBRARY}}
892
- State Management: {{STATE_MANAGEMENT}}
893
- Data Fetching: {{DATA_FETCHING}}
246
+ **2.7.1 Soft Delete Configuration** (if A selected above)
894
247
 
895
- Routing: {{ROUTING}}
896
- Forms: {{FORM_LIBRARY}}
897
- Styling: {{STYLING_APPROACH}}
898
- Design Tokens: {{DESIGN_TOKENS}}
899
- Dark Mode: {{DARK_MODE_SUPPORT}}
248
+ ```
249
+ How will you handle data deletion?
250
+
251
+ Field for soft delete:
252
+ A) ⭐ deleted_at (timestamp, null = active) - Recommended
253
+ B) is_deleted (boolean)
254
+ C) status field (e.g., status = 'deleted')
255
+ D) Custom: __
256
+
257
+ Entities with SOFT delete (keep record, mark as deleted):
258
+ - Users ✅
259
+ - Orders ✅
260
+ - Products ✅
261
+ - [List yours...]
262
+
263
+ Entities with HARD delete (permanent removal):
264
+ - Session tokens
265
+ - Temporary files
266
+ - Cart items after checkout
267
+ - [List yours...]
268
+
269
+ Permanent cleanup policy:
270
+ A) ⭐ Purge soft-deleted after __ days (recommended: 90)
271
+ B) Archive to cold storage after __ days
272
+ C) Never delete (compliance requirement)
273
+
274
+ Default query behavior:
275
+ A) ⭐ Exclude deleted by default (add scope/filter)
276
+ B) Include all, filter explicitly
277
+ ```
900
278
 
901
- Testing:
902
- - Component: {{COMPONENT_TEST_LIBRARY}}
903
- - E2E: {{E2E_FRAMEWORK}}
279
+ **2.7.2 State Machines** (for entities with lifecycle states)
904
280
 
905
- API Integration: {{API_INTEGRATION_PATTERN}}
906
- API Client: {{API_CLIENT}}
907
- Error Handling: {{ERROR_HANDLING_STRATEGY}}
908
- ---
909
281
  ```
282
+ Do any entities have defined state lifecycles?
283
+
284
+ A) ⭐ Yes - Define state machines
285
+ B) No - Simple status fields without transitions
286
+
287
+ If yes, define for each entity:
288
+
289
+ ---
290
+ Entity: Order (example)
291
+ States: [draft, pending, confirmed, shipped, delivered, cancelled, refunded]
292
+
293
+ Valid Transitions:
294
+ - draft → pending (action: submit)
295
+ - pending → confirmed (action: pay) [requires: payment_id]
296
+ - pending → cancelled (action: cancel, or timeout: 24h)
297
+ - confirmed → shipped (action: ship) [requires: tracking_number]
298
+ - shipped → delivered (action: deliver)
299
+ - confirmed → refunded (action: refund)
300
+ - delivered → refunded (action: refund) [within: 30 days]
301
+
302
+ Invalid Transitions (explicitly forbidden):
303
+ - shipped → cancelled (cannot cancel after shipping)
304
+ - delivered → cancelled
305
+
306
+ Side Effects:
307
+ - pending → confirmed: send confirmation email, reserve inventory
308
+ - confirmed → cancelled: release inventory, refund payment
309
+ - shipped → delivered: send delivery notification
310
+ ---
311
+
312
+ Your state machines:
313
+
314
+ Entity: __
315
+ States: __
316
+ Transitions: __
317
+ ```
318
+
319
+ **2.7.1 Domain-Driven Design Concepts** (Production-Ready and Enterprise only)
320
+
321
+ ```
322
+ Will you use Domain-Driven Design (DDD) patterns?
323
+
324
+ A) ⭐ Yes - Using DDD tactical patterns
325
+ - Aggregate Roots for transactional boundaries
326
+ - Value Objects for immutable data
327
+ - Domain Events for decoupling
328
+
329
+ B) 🔥 Partial - Only Aggregate Roots
330
+ - Define aggregate roots for complex domains
331
+ - Keep entities grouped by aggregate
332
+
333
+ C) No - Simple CRUD patterns
334
+ - Standard entity relationships
335
+ - No aggregate boundaries
336
+
337
+ If using DDD (A or B):
338
+
339
+ What are your Aggregate Roots?
340
+ (Aggregate roots are the entry points to groups of related entities)
341
+
342
+ Examples:
343
+ - Order (with OrderItems, Shipping, Payment)
344
+ - User (with Profile, Preferences, Settings)
345
+ - Project (with Tasks, Members, Files)
346
+
347
+ Your Aggregate Roots:
348
+ 1. __ (contains: __)
349
+ 2. __ (contains: __)
350
+ 3. __ (contains: __)
351
+
352
+ Domain Events (things that happen in your domain):
353
+ - UserRegistered
354
+ - OrderPlaced
355
+ - PaymentCompleted
356
+ - etc.
357
+
358
+ Your key domain events:
359
+ 1.
360
+ 2.
361
+ 3.
362
+ ```
363
+
364
+ **2.7.4 Transaction Boundaries**
365
+
366
+ ```
367
+ Which operations require database transactions?
368
+
369
+ List operations that must be atomic (all-or-nothing):
370
+
371
+ 1. User Registration:
372
+ - Create User record
373
+ - Create Profile record
374
+ - Send welcome email (queue, not in transaction)
375
+ → Rollback if: User or Profile creation fails
376
+
377
+ 2. Order Creation:
378
+ - Create Order record
379
+ - Create OrderItems
380
+ - Reserve inventory
381
+ - Charge payment
382
+ → Rollback if: Any step fails
383
+
384
+ 3. [Your operations]:
385
+ - Step 1
386
+ - Step 2
387
+ → Rollback if: __
388
+
389
+ Your transactional operations:
390
+ 1.
391
+ 2.
392
+ 3.
393
+ ```
394
+
395
+ **2.8 Database Indexes**
396
+
397
+ ```
398
+ What indexes will you need for performance optimization?
399
+
400
+ Indexes are critical for query performance. Based on your entities and relationships, consider:
401
+
402
+ Common indexes needed:
403
+ A) Foreign keys (automatically indexed by most ORMs)
404
+ B) Frequently queried columns (email, username, status)
405
+ C) Columns used in WHERE clauses
406
+ D) Columns used in JOIN conditions
407
+ E) Columns used in ORDER BY clauses
408
+ F) Composite indexes for multi-column queries
409
+
410
+ → Your selection (e.g., A, B, C, D): __
411
+
412
+ Do you have specific query patterns that need optimization?
413
+
414
+ Example:
415
+ - User lookup by email: Index on users.email
416
+ - Order search by date range: Index on orders.created_at
417
+ - Product search by category and status: Composite index on (category_id, status)
418
+
419
+ Your specific indexes:
420
+ 1.
421
+ 2.
422
+ 3.
423
+ ```
424
+
425
+ **2.9 Transaction Management**
426
+
427
+ ```
428
+ What transaction isolation level will you use?
429
+
430
+ A) ⭐ READ COMMITTED - Recommended default (PostgreSQL, MySQL default)
431
+ - Prevents dirty reads
432
+ - Allows non-repeatable reads and phantom reads
433
+ - Good balance of consistency and performance
434
+
435
+ B) READ UNCOMMITTED - Lowest isolation (rarely used)
436
+ - Allows dirty reads
437
+ - Fastest but least safe
438
+
439
+ C) REPEATABLE READ - Higher isolation
440
+ - Prevents dirty reads and non-repeatable reads
441
+ - May have phantom reads
442
+ - Better consistency, slightly slower
443
+
444
+ D) 🏆 SERIALIZABLE - Highest isolation (Enterprise)
445
+ - Prevents all concurrency issues
446
+ - Slowest but safest
447
+ - Use only when absolutely necessary
448
+
449
+ Your choice: __
450
+
451
+ Consistency model:
452
+ A) ⭐ Strong consistency - All reads see latest writes (most backends)
453
+ B) Eventual consistency - Acceptable delay for better performance (distributed systems)
454
+
455
+ If eventual consistency:
456
+ - Acceptable delay: __ seconds/minutes
457
+ - Conflict resolution strategy: __
458
+ ```
459
+
460
+ **2.10 Schema Migrations**
461
+
462
+ ```
463
+ What migration tool will you use?
464
+
465
+ A) ⭐ Prisma Migrate (if using Prisma)
466
+ B) TypeORM Migrations (if using TypeORM)
467
+ C) Alembic (Python/SQLAlchemy)
468
+ D) Flyway (Java/Universal)
469
+ E) Liquibase (Java/Universal)
470
+ F) Django Migrations (Django)
471
+ G) Laravel Migrations (Laravel)
472
+ H) Rails Migrations (Ruby on Rails)
473
+ I) Other: __
474
+
475
+ Migration strategy:
476
+ A) ⭐ Versioned migrations - Each change creates a new migration file
477
+ B) Auto-migrations - Tool generates migrations automatically
478
+ C) Manual SQL scripts - Write migrations manually
479
+
480
+ Zero-downtime migrations:
481
+ A) ⭐ Yes - Plan for zero-downtime migrations (Production-Ready/Enterprise)
482
+ B) No - Accept maintenance windows (MVP)
483
+
484
+ If zero-downtime:
485
+ - Strategy: [Expand/Contract, Blue-Green, etc.]
486
+ - Rollback plan: __
487
+ ```
488
+
489
+ ### Phase 2 Output
490
+
491
+ ```
492
+ 📋 PHASE 2 SUMMARY:
493
+
494
+ Database: [type(s)]
495
+ Core Entities: [list with descriptions]
496
+ Relationships: [key relationships]
497
+ Data Volume: [estimates]
498
+ Retention: [policies]
499
+ Migration: [strategy if applicable]
500
+ Data Patterns: [selected patterns with brief details]
501
+ Database Indexes: [list of indexes needed]
502
+ Transaction Isolation: [level + consistency model]
503
+ Schema Migrations: [tool + strategy + zero-downtime approach]
504
+
505
+ Is this correct? (Yes/No)
506
+ ```
507
+
508
+ ---
509
+
510
+ ### 📄 Generate Phase 2 Documents
511
+
512
+ **Before starting generation:**
513
+
514
+ ```
515
+ 📖 Loading context from previous phases...
516
+ ✅ Re-reading project-brief.md
517
+ ```
518
+
519
+ **Generate `docs/data-model.md` automatically:**
520
+
521
+ - Use template: `.ai-flow/templates/docs/data-model.template.md`
522
+ - Fill with all Phase 2 entity and relationship information
523
+ - Include entity catalog, relationships, data patterns
524
+ - Generate entity-relationship diagram (ER diagram) in mermaid format showing all entities and their relationships
525
+ - Write to: `docs/data-model.md`
526
+
527
+ ---
528
+
529
+ #### 🎨 MERMAID ER DIAGRAM FORMAT - CRITICAL
530
+
531
+ > 📎 **Reference:** See [prompts/shared/mermaid-guidelines.md](../shared/mermaid-guidelines.md) for ER diagram syntax, relationship notation, and common mistakes.
532
+
533
+ ## **Example ER Diagram:**
534
+
535
+ ```
536
+ ✅ Generated: docs/data-model.md
537
+
538
+ Document has been created with all Phase 2 information.
539
+
540
+ 📝 Would you like to make any corrections before continuing?
541
+
542
+ → If yes: Edit docs/data-model.md and type "ready" when done. I'll re-read it.
543
+ → If no: Type "continue" to proceed to Phase 3.
544
+ ```
545
+
546
+ **If user edits the file:**
547
+ Execute `read_file('docs/data-model.md')` to refresh context before continuing.
548
+
549
+ ---
910
550
 
911
- **Ask for confirmation:**
912
- "Does this look correct? (Yes to continue, No to restart phase 2)"
551
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in Phase 2. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
913
552
 
914
- **If Yes:**
915
- "✅ Phase 2 complete! Moving to Phase 3: State Management & Data Flow..."
553
+ ---
916
554
 
917
- **If No:**
918
- "Restarting Phase 2..."
919
- ---
920
- ## 🎯 Next Steps
555
+ ## 📝 Generated Documents
921
556
 
922
- After Phase 2 completion, you will:
923
- 1. Update `ai-instructions.md` with tech stack
924
- 2. Generate `docs/components.md` with component patterns
925
- 3. Generate `docs/architecture.md` with system architecture
926
- 4. Continue to Phase 3: State Management & Data Flow
927
- ---
928
- **Phase:** 2 of 7
929
- **Estimated time:** 15-20 minutes
930
- **Documents updated:** ai-instructions.md, docs/components.md, docs/architecture.md
557
+ After Phase 2, generate/update:
558
+ - `docs/data-model.md` - Database schema and entity relationships
931
559
 
560
+ ---
932
561
 
562
+ **Next Phase:** Phase 3 - System Architecture (15-20 min)
933
563
 
564
+ Read: `.ai-flow/prompts/backend/flow-build-phase-3.md`
934
565
 
566
+ ---
935
567
 
568
+ **Last Updated:** 2025-12-20
569
+ **Version:** 2.1.8
936
570
 
571
+ ---
937
572
 
573
+ ## PHASE 3: System Architecture (15-20 min)