ai-flow-dev 2.2.0 → 2.2.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 (74) hide show
  1. package/README.md +28 -24
  2. package/dist/cli.js +228 -418
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +286 -4
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-2.md +19 -0
  8. package/prompts/backend/flow-build-phase-3.md +19 -0
  9. package/prompts/backend/flow-build-phase-4.md +19 -0
  10. package/prompts/backend/flow-build-phase-5.md +19 -0
  11. package/prompts/backend/flow-build-phase-6.md +19 -0
  12. package/prompts/backend/flow-build-phase-7.md +19 -0
  13. package/prompts/backend/flow-build-phase-9.md +14 -0
  14. package/prompts/backend/flow-build.md +2 -0
  15. package/prompts/backend/flow-check-review.md +20 -0
  16. package/prompts/backend/flow-check-test.md +14 -0
  17. package/prompts/backend/flow-check.md +67 -0
  18. package/prompts/backend/flow-commit.md +53 -0
  19. package/prompts/backend/flow-docs-sync.md +55 -53
  20. package/prompts/backend/flow-work-feature.md +42 -0
  21. package/prompts/backend/flow-work-fix.md +33 -0
  22. package/prompts/backend/flow-work-refactor.md +32 -0
  23. package/prompts/backend/flow-work-resume.md +32 -0
  24. package/prompts/backend/flow-work.md +129 -0
  25. package/prompts/frontend/flow-build-phase-0.md +363 -35
  26. package/prompts/frontend/flow-build-phase-1.md +433 -404
  27. package/prompts/frontend/flow-build-phase-2.md +508 -872
  28. package/prompts/frontend/flow-build-phase-3.md +629 -562
  29. package/prompts/frontend/flow-build-phase-4.md +438 -382
  30. package/prompts/frontend/flow-build-phase-5.md +559 -362
  31. package/prompts/frontend/flow-build-phase-6.md +383 -452
  32. package/prompts/frontend/flow-build-phase-7.md +818 -392
  33. package/prompts/frontend/flow-build-phase-9.md +14 -0
  34. package/prompts/frontend/flow-build.md +2 -0
  35. package/prompts/frontend/flow-check-review.md +20 -0
  36. package/prompts/frontend/flow-check-test.md +14 -0
  37. package/prompts/frontend/flow-check.md +67 -0
  38. package/prompts/frontend/flow-commit.md +53 -0
  39. package/prompts/frontend/flow-docs-sync.md +39 -35
  40. package/prompts/frontend/flow-work-feature.md +42 -0
  41. package/prompts/frontend/flow-work-fix.md +33 -0
  42. package/prompts/frontend/flow-work-refactor.md +32 -0
  43. package/prompts/frontend/flow-work-resume.md +32 -0
  44. package/prompts/frontend/flow-work.md +129 -0
  45. package/prompts/mobile/flow-build-phase-0.md +366 -37
  46. package/prompts/mobile/flow-build-phase-1.md +438 -493
  47. package/prompts/mobile/flow-build-phase-2.md +458 -464
  48. package/prompts/mobile/flow-build-phase-3.md +613 -487
  49. package/prompts/mobile/flow-build-phase-4.md +439 -258
  50. package/prompts/mobile/flow-build-phase-5.md +582 -250
  51. package/prompts/mobile/flow-build-phase-6.md +389 -359
  52. package/prompts/mobile/flow-build-phase-7.md +871 -285
  53. package/prompts/mobile/flow-build-phase-9.md +14 -0
  54. package/prompts/mobile/flow-build.md +2 -0
  55. package/prompts/mobile/flow-check-review.md +20 -0
  56. package/prompts/mobile/flow-check-test.md +14 -0
  57. package/prompts/mobile/flow-check.md +67 -0
  58. package/prompts/mobile/flow-commit.md +53 -0
  59. package/prompts/mobile/flow-docs-sync.md +39 -40
  60. package/prompts/mobile/flow-work-feature.md +42 -0
  61. package/prompts/mobile/flow-work-fix.md +33 -0
  62. package/prompts/mobile/flow-work-refactor.md +32 -0
  63. package/prompts/mobile/flow-work-resume.md +32 -0
  64. package/prompts/mobile/flow-work.md +129 -0
  65. package/prompts/shared/smart-skip-preflight.md +214 -0
  66. package/templates/AGENT.template.md +13 -3
  67. package/templates/backend/.clauderules.template +5 -4
  68. package/templates/backend/.cursorrules.template +1 -1
  69. package/prompts/backend/flow-dev-commit.md +0 -829
  70. package/prompts/backend/flow-dev-feature.md +0 -1948
  71. package/prompts/backend/flow-dev-fix.md +0 -952
  72. package/prompts/backend/flow-dev-refactor.md +0 -690
  73. package/prompts/backend/flow-dev-review.md +0 -372
  74. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,579 +1,573 @@
1
- # Phase 2: Navigation & Architecture
1
+ ## PHASE 2: Data Architecture (15-20 min)
2
2
 
3
- **Duration:** 15-20 minutes
4
- **Questions:** ~10 questions
5
- **Output:** docs/navigation.md, docs/architecture.md, parts of ai-instructions.md
6
- ---
7
- ## 🎯 Objective
3
+ > **Order for this phase:** 2.1 → 2.2 → 2.3 → 2.4 → 2.5 → 2.6 → 2.7
8
4
 
9
- Define the **navigation structure and architecture** for your mobile app:
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.
10
8
 
11
- 1. What navigation patterns will you use?
12
- 2. How will you organize screens and components?
13
- 3. What architecture pattern will you follow?
14
- 4. How will you structure your codebase?
15
- ---
16
- ## 📋 Questions
9
+ ### Objective
17
10
 
18
- ### Question 2.1: Navigation Pattern
11
+ Design the database model, entities, and relationships.
19
12
 
20
- **What navigation pattern will your app use?**
13
+ ---
21
14
 
22
- **For React Native:**
15
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
23
16
 
24
- - A) **Stack Navigation** (Recommended)
25
- - Hierarchical navigation (push/pop)
26
- - Best for: Most apps, detail screens
27
- - Library: React Navigation Stack
17
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../shared/smart-skip-preflight.md) for the complete smart skip logic.
28
18
 
29
- - B) 🔥 **Tab Navigation**
30
- - Bottom tabs or top tabs
31
- - Best for: Multi-section apps (Home, Search, Profile, etc.)
32
- - Library: React Navigation Tabs
19
+ **Execute Pre-Flight Check for Phase 2:**
33
20
 
34
- - C) **Drawer Navigation**
35
- - Side menu drawer
36
- - Best for: Apps with many sections
37
- - Library: React Navigation Drawer
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
38
25
 
39
- - D) **Combined (Tab + Stack)** (Most Common)
40
- - Bottom tabs with stack navigators per tab
41
- - Best for: Complex apps with multiple sections
42
- - Example: Instagram, Twitter
26
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
43
27
 
44
- **For Flutter:**
28
+ ---
45
29
 
46
- - A) ⭐ **Navigator 2.0 / GoRouter** (Recommended)
47
- - Declarative routing
48
- - Best for: Modern Flutter apps
30
+ ## Phase 2 Questions (Full Mode)
49
31
 
50
- - B) **AutoRoute**
51
- - Code generation for routes
52
- - Best for: Type-safe routing
32
+ **2.1 Database Type**
53
33
 
54
- - C) **Traditional Navigator**
55
- - Imperative navigation
56
- - Best for: Simple apps
57
-
58
- **For Native iOS:**
59
-
60
- - A) ⭐ **UINavigationController** (Standard)
61
- - B) **UITabBarController** (Tabs)
62
- - C) **Coordinator Pattern** (Advanced)
63
-
64
- **For Native Android:**
65
-
66
- - A) ⭐ **Navigation Component** (Recommended)
67
- - B) **Jetpack Compose Navigation** (If using Compose)
68
-
69
- **Your answer:**
70
-
71
- **If Combined selected, ask:**
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.]
72
39
 
73
- - How many bottom tabs? (3-5 recommended)
74
- - What are the main sections? (e.g., Home, Search, Profile, Settings)
75
- ---
76
- ### Question 2.2: Screen Organization
40
+ Is this correct? (Y/N)
41
+ If no, please provide correct database type.
77
42
 
78
- **How will you organize your screens?**
43
+ [If NOT detected, ask:]
44
+ What type of database will you use? (Can select multiple)
79
45
 
80
- A) ⭐ **Feature-based** (Recommended)
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]
81
51
 
82
- - Group by feature/domain
83
- - Example: `screens/auth/`, `screens/home/`, `screens/profile/`
84
- - Best for: Medium to large apps
52
+ Why this choice?
53
+ ```
85
54
 
86
- B) **Flat Structure**
55
+ **2.2 Core Data Entities**
87
56
 
88
- - All screens in one folder
89
- - Example: `screens/LoginScreen.tsx`, `screens/HomeScreen.tsx`
90
- - Best for: Small apps (<10 screens)
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
+ ```
91
128
 
92
- C) **Domain-driven**
129
+ **2.3 Relationships**
93
130
 
94
- - Group by business domain
95
- - Example: `screens/user/`, `screens/product/`, `screens/order/`
96
- - Best for: Large, complex apps
131
+ ```
132
+ Common relationship patterns (select what applies to your entities):
97
133
 
98
- D) **Route-based**
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: __
99
142
 
100
- - Match folder structure to routes
101
- - Example: `screens/(tabs)/home/`, `screens/(tabs)/profile/`
102
- - Best for: File-based routing (Expo Router)
143
+ Your selection (e.g., A, B, D): __
103
144
 
104
- **Your answer:**
105
- ---
106
- ### Question 2.3: Component Organization
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: __
107
150
 
108
- **How will you organize your components?**
151
+ Your selection (e.g., A, C, E): __
109
152
 
110
- A) **Atomic Design** (Recommended)
153
+ One-to-One (less common):
111
154
 
112
- - atoms/, molecules/, organisms/, templates/
113
- - Best for: Design system consistency
155
+ ⭐ One-to-One (less common):
156
+ C) Order Payment (one order has one payment)
157
+ D) Other: __
114
158
 
115
- B) **Feature-based Components**
159
+ → Your selection (e.g., A, B): __
116
160
 
117
- - components/ shared across features
118
- - features/[feature]/components/ for feature-specific
119
- - Best for: Feature isolation
161
+ Polymorphic (one entity relates to multiple types):
162
+ C) Activity → (User | Organization | Deal) - activities linked to various objects
163
+ D) Other: __
120
164
 
121
- C) **Flat Structure**
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
+ -
122
173
 
123
- - All components in components/
124
- - Best for: Small apps
174
+ (Format: EntityA EntityB: Relationship type - description)
175
+ ```
125
176
 
126
- D) **Type-based**
177
+ **2.4 Data Volume Estimates**
127
178
 
128
- - components/buttons/, components/cards/, components/forms/
129
- - Best for: Component library approach
179
+ ```
180
+ Estimated data volume (Year 1):
130
181
 
131
- **Your answer:**
132
- ---
133
- ### Question 2.4: Architecture Pattern
182
+ - Total records: [Low (<10k) / Medium (10k-1M) / High (>1M)]
183
+ - Growth rate: [Slow / Moderate / Fast]
134
184
 
135
- **What architecture pattern will you follow?**
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)
136
189
 
137
- A) **Feature-based Architecture** (Recommended)
190
+ Standard for MVP:
191
+ - Records: Low (<10k)
192
+ - Growth: Moderate
193
+ - Complexity: Low (mostly text)
138
194
 
139
- - Each feature is self-contained
140
- - Example: features/auth/, features/home/
141
- - Best for: Most React Native/Flutter apps
195
+ 🏆 Standard for Production/Scale:
196
+ - Records: High (>1M)
197
+ - Growth: Fast
198
+ - Complexity: Medium/High (includes media/files)
199
+ ```
142
200
 
143
- B) 🔥 **Clean Architecture** (Popular)
201
+ **2.5 Data Retention**
144
202
 
145
- - Separation: Presentation / Domain / Data layers
146
- - Best for: Complex apps, testability
203
+ ```
204
+ Data retention policies:
147
205
 
148
- C) **MVVM (Model-View-ViewModel)**
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
149
210
 
150
- - Common in Flutter and Native
151
- - Best for: State-heavy apps
211
+ For each entity that has special retention needs, specify:
212
+ ```
152
213
 
153
- D) **MVI (Model-View-Intent)**
214
+ **2.6 Data Migration**
154
215
 
155
- - Unidirectional data flow
156
- - Best for: Predictable state management
216
+ ```
217
+ Is this a new system or replacing an existing one?
157
218
 
158
- E) **Simple (No strict pattern)**
219
+ A) 🆕 New system - No legacy data
220
+ B) 🔄 Replacing existing - Need to migrate from [system name]
221
+ C) 🔌 Integration - Syncing with existing system
159
222
 
160
- - Organize as needed
161
- - Best for: Small apps, MVPs
223
+ If migration needed:
224
+ - Source system: __
225
+ - Data volume to migrate: __
226
+ - Migration strategy: [Big bang / Phased / Parallel run]
227
+ ```
162
228
 
163
- **Your answer:**
164
- ---
165
- ### Question 2.5: Folder Structure
229
+ **2.7 Critical Data Patterns**
166
230
 
167
- **What folder structure will you use?**
231
+ ```
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
+ ```
168
245
 
169
- **Example for Feature-based:**
246
+ **2.7.1 Soft Delete Configuration** (if A selected above)
170
247
 
171
248
  ```
172
- src/
173
- ├── features/
174
- │ ├── auth/
175
- │ │ ├── screens/
176
- │ │ ├── components/
177
- │ │ ├── hooks/
178
- │ │ └── store/
179
- │ ├── home/
180
- │ └── profile/
181
- ├── components/ (shared)
182
- ├── navigation/
183
- ├── services/
184
- ├── utils/
185
- └── types/
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
186
277
  ```
187
278
 
188
- **Example for Clean Architecture:**
279
+ **2.7.2 State Machines** (for entities with lifecycle states)
189
280
 
190
281
  ```
191
- lib/
192
- ├── presentation/
193
- │ ├── pages/
194
- │ ├── widgets/
195
- │ └── providers/
196
- ├── domain/
197
- │ ├── entities/
198
- │ ├── repositories/
199
- │ └── usecases/
200
- └── data/
201
- ├── models/
202
- ├── repositories/
203
- └── datasources/
204
- ```
282
+ Do any entities have defined state lifecycles?
283
+
284
+ A) ⭐ Yes - Define state machines
285
+ B) No - Simple status fields without transitions
205
286
 
206
- **Your preference:** (Describe or select from examples)
207
- ---
208
- ### Question 2.6: Navigation Library
287
+ If yes, define for each entity:
209
288
 
210
- **Which navigation library will you use?**
289
+ ---
290
+ Entity: Order (example)
291
+ States: [draft, pending, confirmed, shipped, delivered, cancelled, refunded]
211
292
 
212
- **If React Native:**
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]
213
301
 
214
- - A) **React Navigation** (Recommended)
215
- - Most popular, well-maintained
216
- - Works with Expo and bare React Native
217
- - Version: 6.x
302
+ Invalid Transitions (explicitly forbidden):
303
+ - shipped cancelled (cannot cancel after shipping)
304
+ - delivered cancelled
218
305
 
219
- - B) **React Native Navigation** (Wix)
220
- - Native navigation, better performance
221
- - Requires native setup
222
- - Best for: Performance-critical apps
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
+ ---
223
311
 
224
- **If Flutter:**
312
+ Your state machines:
225
313
 
226
- - A) ⭐ **GoRouter** (Recommended)
227
- - Declarative, type-safe
228
- - Best for: Modern Flutter apps
314
+ Entity: __
315
+ States: __
316
+ Transitions: __
317
+ ```
229
318
 
230
- - B) **AutoRoute**
231
- - Code generation
232
- - Best for: Complex routing
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
+ ```
233
363
 
234
- **Your answer:**
235
- ---
236
- ### Question 2.7: Deep Linking Strategy
364
+ **2.7.4 Transaction Boundaries**
237
365
 
238
- **How will you handle deep links?**
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
+ ```
239
394
 
240
- A) ⭐ **Universal Links (iOS) + App Links (Android)** (Recommended)
395
+ **2.8 Database Indexes**
241
396
 
242
- - Standard deep linking
243
- - Opens app directly
244
- - Best for: Most apps
397
+ ```
398
+ What indexes will you need for performance optimization?
245
399
 
246
- B) **Custom URL Scheme**
400
+ Indexes are critical for query performance. Based on your entities and relationships, consider:
247
401
 
248
- - myapp://path/to/screen
249
- - Simpler but less secure
250
- - Best for: Internal links
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
251
409
 
252
- C) **No Deep Linking**
410
+ → Your selection (e.g., A, B, C, D): __
253
411
 
254
- - App only, no external links
255
- - Best for: Standalone apps
412
+ Do you have specific query patterns that need optimization?
256
413
 
257
- **Your answer:**
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)
258
418
 
259
- **If deep linking selected, ask:**
419
+ Your specific indexes:
420
+ 1.
421
+ 2.
422
+ 3.
423
+ ```
260
424
 
261
- - What URL scheme? (e.g., `myapp://`, `https://myapp.com`)
262
- - What screens need deep links? (e.g., product details, user profiles)
263
- ---
264
- ### Question 2.8: Navigation State Management
425
+ **2.9 Transaction Management**
265
426
 
266
- **How will you manage navigation state?**
427
+ ```
428
+ What transaction isolation level will you use?
267
429
 
268
- A) ⭐ **Navigation Library Built-in** (Recommended)
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
269
434
 
270
- - React Navigation manages its own state
271
- - Flutter Navigator manages its own state
272
- - Best for: Most apps
435
+ B) READ UNCOMMITTED - Lowest isolation (rarely used)
436
+ - Allows dirty reads
437
+ - Fastest but least safe
273
438
 
274
- B) **Redux / State Management Library**
439
+ C) REPEATABLE READ - Higher isolation
440
+ - Prevents dirty reads and non-repeatable reads
441
+ - May have phantom reads
442
+ - Better consistency, slightly slower
275
443
 
276
- - Centralized navigation state
277
- - Best for: Complex navigation flows
444
+ D) 🏆 SERIALIZABLE - Highest isolation (Enterprise)
445
+ - Prevents all concurrency issues
446
+ - Slowest but safest
447
+ - Use only when absolutely necessary
278
448
 
279
- C) **Custom State Management**
449
+ Your choice: __
280
450
 
281
- - Your own navigation state
282
- - Best for: Advanced use cases
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)
283
454
 
284
- **Your answer:**
285
- ---
286
- ### Question 2.9: Screen Transitions
455
+ If eventual consistency:
456
+ - Acceptable delay: __ seconds/minutes
457
+ - Conflict resolution strategy: __
458
+ ```
287
459
 
288
- **What screen transition animations will you use?**
460
+ **2.10 Schema Migrations**
289
461
 
290
- A) ⭐ **Default Transitions** (Recommended)
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
+ ```
291
488
 
292
- - Platform-native transitions
293
- - iOS: Slide from right
294
- - Android: Slide up/fade
295
- - Best for: Most apps
489
+ ### Phase 2 Output
296
490
 
297
- B) **Custom Transitions**
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
+ ```
298
507
 
299
- - Fade, scale, slide custom directions
300
- - Best for: Branded experience
508
+ ---
301
509
 
302
- C) **No Animations**
510
+ ### 📄 Generate Phase 2 Documents
303
511
 
304
- - Instant transitions
305
- - Best for: Performance-critical apps
512
+ **Before starting generation:**
306
513
 
307
- **Your answer:**
308
- ---
309
- ### Question 2.10: Navigation Guards / Authentication Flow
514
+ ```
515
+ 📖 Loading context from previous phases...
516
+ Re-reading project-brief.md
517
+ ```
310
518
 
311
- **How will you handle protected routes?**
519
+ **Generate `docs/data-model.md` automatically:**
312
520
 
313
- A) **Navigation Guards** (Recommended)
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`
314
526
 
315
- - Check auth state before navigation
316
- - Redirect to login if not authenticated
317
- - Best for: Most apps
527
+ ---
318
528
 
319
- B) **Separate Navigation Stacks**
529
+ #### 🎨 MERMAID ER DIAGRAM FORMAT - CRITICAL
320
530
 
321
- - Auth stack vs App stack
322
- - Switch between stacks based on auth state
323
- - Best for: Clear separation
531
+ > 📎 **Reference:** See [prompts/shared/mermaid-guidelines.md](../shared/mermaid-guidelines.md) for ER diagram syntax, relationship notation, and common mistakes.
324
532
 
325
- C) **No Protection**
533
+ ## **Example ER Diagram:**
326
534
 
327
- - All screens accessible
328
- - Handle auth in components
329
- - Best for: Simple apps
535
+ ```
536
+ Generated: docs/data-model.md
330
537
 
331
- **Your answer:**
332
- ---
333
- #### 🎨 MERMAID NAVIGATION DIAGRAM FORMATS - CRITICAL
538
+ Document has been created with all Phase 2 information.
334
539
 
335
- **Use these exact formats** for mobile navigation diagrams:
336
- ---
337
- ##### 1️⃣ Navigation Structure (Tab + Stack Pattern)
540
+ 📝 Would you like to make any corrections before continuing?
338
541
 
339
- Use `graph TD` to show navigation hierarchy:
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
+ ```
340
545
 
341
- ```mermaid
342
- graph TD
343
- subgraph "App Navigation"
344
- ROOT[Root Navigator]
345
- end
546
+ **If user edits the file:**
547
+ Execute `read_file('docs/data-model.md')` to refresh context before continuing.
346
548
 
347
- subgraph "Tab Navigator"
348
- TAB1[Home Tab]
349
- TAB2[Search Tab]
350
- TAB3[Profile Tab]
351
- TAB4[Settings Tab]
352
- end
549
+ ---
353
550
 
354
- subgraph "Stack Navigators"
355
- subgraph "Home Stack"
356
- H1[Home Screen]
357
- H2[Product Detail]
358
- H3[Cart]
359
- H4[Checkout]
360
- end
551
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in Phase 2. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
361
552
 
362
- subgraph "Search Stack"
363
- S1[Search Screen]
364
- S2[Results]
365
- S3[Filter]
366
- end
553
+ ---
367
554
 
368
- subgraph "Profile Stack"
369
- P1[Profile Screen]
370
- P2[Edit Profile]
371
- P3[Orders History]
372
- end
373
- end
374
-
375
- ROOT --> TAB1
376
- ROOT --> TAB2
377
- ROOT --> TAB3
378
- ROOT --> TAB4
379
-
380
- TAB1 --> H1
381
- H1 --> H2
382
- H2 --> H3
383
- H3 --> H4
384
-
385
- TAB2 --> S1
386
- S1 --> S2
387
- S2 --> S3
388
-
389
- TAB3 --> P1
390
- P1 --> P2
391
- P1 --> P3
392
-
393
- style ROOT fill:#e3f2fd
394
- style TAB1 fill:#e1f5ff
395
- style TAB2 fill:#e1f5ff
396
- style TAB3 fill:#e1f5ff
397
- style TAB4 fill:#e1f5ff
398
- style H1 fill:#fff4e6
399
- style S1 fill:#fff4e6
400
- style P1 fill:#fff4e6
401
- ```
402
-
403
- **Use for:** Tab-based apps with nested stacks (Instagram, Twitter pattern)
404
- ---
405
- ##### 2️⃣ Authentication Flow
406
-
407
- Use `graph LR` to show auth-protected navigation:
408
-
409
- ```mermaid
410
- graph LR
411
- subgraph "Unauthenticated"
412
- SPLASH[Splash Screen]
413
- ONBOARD[Onboarding]
414
- LOGIN[Login Screen]
415
- REGISTER[Register Screen]
416
- end
417
-
418
- subgraph "Authenticated"
419
- MAIN[Main App<br/>Tab Navigator]
420
- HOME[Home]
421
- PROFILE[Profile]
422
- end
423
-
424
- SPLASH -->|First Launch| ONBOARD
425
- SPLASH -->|Returning User| CHECK{Authenticated?}
426
- ONBOARD --> LOGIN
427
- LOGIN --> REGISTER
428
- LOGIN -->|Success| MAIN
429
- REGISTER -->|Success| MAIN
430
-
431
- CHECK -->|Yes| MAIN
432
- CHECK -->|No| LOGIN
433
-
434
- MAIN --> HOME
435
- MAIN --> PROFILE
436
-
437
- style SPLASH fill:#e3f2fd
438
- style CHECK fill:#fff9c4
439
- style MAIN fill:#e8f5e9
440
- style LOGIN fill:#fce4ec
441
- style REGISTER fill:#fce4ec
442
- ```
443
-
444
- **Use for:** Apps with authentication/onboarding flows
445
- ---
446
- ##### 3️⃣ Deep Linking Routes
447
-
448
- Use `graph TD` to show deep link structure:
449
-
450
- ```mermaid
451
- graph TD
452
- subgraph "Deep Link Routes"
453
- ROOT[myapp://]
454
- end
455
-
456
- subgraph "Public Routes"
457
- PRODUCT[/product/:id]
458
- CATEGORY[/category/:slug]
459
- PROMO[/promo/:code]
460
- end
461
-
462
- subgraph "Protected Routes"
463
- ORDER[/order/:id<br/>⚠️ Auth Required]
464
- PROFILE_VIEW[/profile/:userId<br/>⚠️ Auth Required]
465
- end
466
-
467
- ROOT --> PRODUCT
468
- ROOT --> CATEGORY
469
- ROOT --> PROMO
470
- ROOT --> ORDER
471
- ROOT --> PROFILE_VIEW
472
-
473
- PRODUCT -->|Opens| PD[Product Detail Screen]
474
- CATEGORY -->|Opens| CL[Category List Screen]
475
- ORDER -->|Opens| OD[Order Detail Screen]
476
-
477
- style ROOT fill:#e3f2fd
478
- style PRODUCT fill:#e8f5e9
479
- style CATEGORY fill:#e8f5e9
480
- style PROMO fill:#e8f5e9
481
- style ORDER fill:#fce4ec
482
- style PROFILE_VIEW fill:#fce4ec
483
- ```
484
-
485
- **Use for:** Apps with universal links/app links
486
- ---
487
- ##### 4️⃣ Screen Hierarchy (Feature-based)
488
-
489
- Use `graph TB` to show folder/screen organization:
490
-
491
- ```mermaid
492
- graph TB
493
- subgraph "Mobile App Structure"
494
- subgraph "screens/"
495
- subgraph "auth/"
496
- A1[LoginScreen.tsx]
497
- A2[RegisterScreen.tsx]
498
- A3[ForgotPasswordScreen.tsx]
499
- end
500
-
501
- subgraph "home/"
502
- H1[HomeScreen.tsx]
503
- H2[ProductDetailScreen.tsx]
504
- end
505
-
506
- subgraph "profile/"
507
- P1[ProfileScreen.tsx]
508
- P2[EditProfileScreen.tsx]
509
- P3[OrdersScreen.tsx]
510
- end
511
- end
512
-
513
- subgraph "navigation/"
514
- NAV[RootNavigator.tsx]
515
- TAB[TabNavigator.tsx]
516
- STACK[StackNavigators.tsx]
517
- end
518
- end
519
-
520
- NAV --> TAB
521
- TAB --> STACK
522
- STACK -.-> H1
523
- STACK -.-> P1
524
- STACK -.-> A1
525
-
526
- style NAV fill:#e3f2fd
527
- style TAB fill:#e1f5ff
528
- style STACK fill:#fff4e6
529
- ```
530
-
531
- **Use for:** Documenting folder structure and file organization
532
- ---
533
- **Diagram Guidelines:**
534
-
535
- - Color code by level (Root=light blue, Tabs=blue, Stacks=orange, Screens=default)
536
- - Use subgraphs to group related screens
537
- - Show authentication checks with decision diamonds
538
- - Include deep link routes with ⚠️ for protected routes
539
- - Update screen names based on actual app structure
540
- ---
541
- ## ✅ Phase 2 Completion
542
-
543
- After answering all questions, summarize:
544
-
545
- ```
546
- ---
547
- ✅ Phase 2 Complete: Navigation & Architecture
548
- ---
549
- Selected Architecture:
550
- - Navigation: Tab + Stack Navigation
551
- - Library: React Navigation 6.0
552
- - Architecture: Feature-based
553
- - Component Organization: Atomic Design
554
- - Folder Structure: Feature-based
555
- - Deep Linking: Universal Links + App Links
556
- - Auth Flow: Navigation Guards
557
-
558
- Proceed to Phase 3 (State & Data Management)? (Y/n)
559
- ```
560
- ---
561
555
  ## 📝 Generated Documents
562
556
 
563
557
  After Phase 2, generate/update:
558
+ - `docs/data-model.md` - Database schema and entity relationships
564
559
 
565
- - `docs/navigation.md` - Navigation patterns and setup guide
566
- - `docs/architecture.md` - System architecture overview
567
- - `ai-instructions.md` - Add navigation and architecture rules
568
- ---
569
- **Next Phase:** Phase 3 - State & Data Management
560
+ ---
570
561
 
571
- Read: `.ai-flow/prompts/mobile/flow-build-phase-3-state.md`
572
- ---
573
- **Last Updated:** 2025-01-XX
562
+ **Next Phase:** Phase 3 - System Architecture (15-20 min)
574
563
 
575
- **Version:** 1.4.0
564
+ Read: `.ai-flow/prompts/backend/flow-build-phase-3.md`
576
565
 
566
+ ---
577
567
 
568
+ **Last Updated:** 2025-12-20
569
+ **Version:** 2.1.8
578
570
 
571
+ ---
579
572
 
573
+ ## PHASE 3: System Architecture (15-20 min)