ai-flow-dev 2.7.0 → 2.8.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 (171) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +573 -570
  3. package/package.json +74 -74
  4. package/prompts/backend/flow-build-phase-0.md +535 -535
  5. package/prompts/backend/flow-build-phase-1.md +626 -626
  6. package/prompts/backend/flow-build-phase-10.md +340 -340
  7. package/prompts/backend/flow-build-phase-2.md +573 -573
  8. package/prompts/backend/flow-build-phase-3.md +834 -834
  9. package/prompts/backend/flow-build-phase-4.md +554 -554
  10. package/prompts/backend/flow-build-phase-5.md +703 -703
  11. package/prompts/backend/flow-build-phase-6.md +524 -524
  12. package/prompts/backend/flow-build-phase-7.md +1001 -1001
  13. package/prompts/backend/flow-build-phase-8.md +1407 -1407
  14. package/prompts/backend/flow-build-phase-9.md +477 -477
  15. package/prompts/backend/flow-build.md +137 -137
  16. package/prompts/backend/flow-check-review.md +656 -20
  17. package/prompts/backend/flow-check-test.md +526 -14
  18. package/prompts/backend/flow-check.md +717 -67
  19. package/prompts/backend/flow-commit.md +88 -119
  20. package/prompts/backend/flow-docs-sync.md +354 -354
  21. package/prompts/backend/flow-finish.md +919 -0
  22. package/prompts/backend/flow-release.md +949 -0
  23. package/prompts/backend/flow-work-feature.md +61 -61
  24. package/prompts/backend/flow-work-fix.md +46 -46
  25. package/prompts/backend/flow-work-refactor.md +48 -48
  26. package/prompts/backend/flow-work-resume.md +34 -34
  27. package/prompts/backend/flow-work.md +1098 -1286
  28. package/prompts/desktop/flow-build-phase-0.md +359 -359
  29. package/prompts/desktop/flow-build-phase-1.md +295 -295
  30. package/prompts/desktop/flow-build-phase-10.md +357 -357
  31. package/prompts/desktop/flow-build-phase-2.md +282 -282
  32. package/prompts/desktop/flow-build-phase-3.md +291 -291
  33. package/prompts/desktop/flow-build-phase-4.md +308 -308
  34. package/prompts/desktop/flow-build-phase-5.md +269 -269
  35. package/prompts/desktop/flow-build-phase-6.md +350 -350
  36. package/prompts/desktop/flow-build-phase-7.md +297 -297
  37. package/prompts/desktop/flow-build-phase-8.md +541 -541
  38. package/prompts/desktop/flow-build-phase-9.md +439 -439
  39. package/prompts/desktop/flow-build.md +156 -156
  40. package/prompts/desktop/flow-check-review.md +656 -20
  41. package/prompts/desktop/flow-check-test.md +526 -14
  42. package/prompts/desktop/flow-check.md +717 -67
  43. package/prompts/desktop/flow-commit.md +88 -119
  44. package/prompts/desktop/flow-docs-sync.md +354 -354
  45. package/prompts/desktop/flow-finish.md +919 -0
  46. package/prompts/desktop/flow-release.md +662 -0
  47. package/prompts/desktop/flow-work-feature.md +61 -61
  48. package/prompts/desktop/flow-work-fix.md +46 -46
  49. package/prompts/desktop/flow-work-refactor.md +48 -48
  50. package/prompts/desktop/flow-work-resume.md +34 -34
  51. package/prompts/desktop/flow-work.md +1202 -1390
  52. package/prompts/frontend/flow-build-phase-0.md +425 -425
  53. package/prompts/frontend/flow-build-phase-1.md +626 -626
  54. package/prompts/frontend/flow-build-phase-10.md +33 -33
  55. package/prompts/frontend/flow-build-phase-2.md +573 -573
  56. package/prompts/frontend/flow-build-phase-3.md +782 -782
  57. package/prompts/frontend/flow-build-phase-4.md +554 -554
  58. package/prompts/frontend/flow-build-phase-5.md +703 -703
  59. package/prompts/frontend/flow-build-phase-6.md +524 -524
  60. package/prompts/frontend/flow-build-phase-7.md +1001 -1001
  61. package/prompts/frontend/flow-build-phase-8.md +872 -872
  62. package/prompts/frontend/flow-build-phase-9.md +94 -94
  63. package/prompts/frontend/flow-build.md +137 -137
  64. package/prompts/frontend/flow-check-review.md +656 -20
  65. package/prompts/frontend/flow-check-test.md +526 -14
  66. package/prompts/frontend/flow-check.md +717 -67
  67. package/prompts/frontend/flow-commit.md +88 -119
  68. package/prompts/frontend/flow-docs-sync.md +550 -550
  69. package/prompts/frontend/flow-finish.md +919 -0
  70. package/prompts/frontend/flow-release.md +519 -0
  71. package/prompts/frontend/flow-work-api.md +1547 -0
  72. package/prompts/frontend/flow-work-feature.md +61 -61
  73. package/prompts/frontend/flow-work-fix.md +38 -38
  74. package/prompts/frontend/flow-work-refactor.md +48 -48
  75. package/prompts/frontend/flow-work-resume.md +34 -34
  76. package/prompts/frontend/flow-work.md +1595 -1320
  77. package/prompts/mobile/flow-build-phase-0.md +425 -425
  78. package/prompts/mobile/flow-build-phase-1.md +626 -626
  79. package/prompts/mobile/flow-build-phase-10.md +32 -32
  80. package/prompts/mobile/flow-build-phase-2.md +573 -573
  81. package/prompts/mobile/flow-build-phase-3.md +782 -782
  82. package/prompts/mobile/flow-build-phase-4.md +554 -554
  83. package/prompts/mobile/flow-build-phase-5.md +703 -703
  84. package/prompts/mobile/flow-build-phase-6.md +524 -524
  85. package/prompts/mobile/flow-build-phase-7.md +1001 -1001
  86. package/prompts/mobile/flow-build-phase-8.md +888 -888
  87. package/prompts/mobile/flow-build-phase-9.md +90 -90
  88. package/prompts/mobile/flow-build.md +135 -135
  89. package/prompts/mobile/flow-check-review.md +656 -20
  90. package/prompts/mobile/flow-check-test.md +526 -14
  91. package/prompts/mobile/flow-check.md +717 -67
  92. package/prompts/mobile/flow-commit.md +88 -119
  93. package/prompts/mobile/flow-docs-sync.md +620 -620
  94. package/prompts/mobile/flow-finish.md +919 -0
  95. package/prompts/mobile/flow-release.md +751 -0
  96. package/prompts/mobile/flow-work-api.md +1500 -0
  97. package/prompts/mobile/flow-work-feature.md +61 -61
  98. package/prompts/mobile/flow-work-fix.md +46 -46
  99. package/prompts/mobile/flow-work-refactor.md +48 -48
  100. package/prompts/mobile/flow-work-resume.md +34 -34
  101. package/prompts/mobile/flow-work.md +1605 -1329
  102. package/prompts/shared/mermaid-guidelines.md +102 -102
  103. package/prompts/shared/scope-levels.md +114 -114
  104. package/prompts/shared/smart-skip-preflight.md +214 -214
  105. package/prompts/shared/story-points.md +55 -55
  106. package/prompts/shared/task-format.md +74 -74
  107. package/prompts/shared/task-summary-template.md +277 -277
  108. package/templates/AGENT.template.md +443 -443
  109. package/templates/backend/.clauderules.template +112 -112
  110. package/templates/backend/.cursorrules.template +102 -102
  111. package/templates/backend/README.template.md +2 -2
  112. package/templates/backend/ai-instructions.template.md +2 -2
  113. package/templates/backend/copilot-instructions.template.md +2 -2
  114. package/templates/backend/docs/api.template.md +320 -320
  115. package/templates/backend/docs/business-flows.template.md +97 -97
  116. package/templates/backend/docs/code-standards.template.md +2 -2
  117. package/templates/backend/docs/contributing.template.md +3 -3
  118. package/templates/backend/docs/data-model.template.md +520 -520
  119. package/templates/backend/docs/testing.template.md +2 -2
  120. package/templates/backend/project-brief.template.md +2 -2
  121. package/templates/backend/specs/configuration.template.md +2 -2
  122. package/templates/backend/specs/security.template.md +2 -2
  123. package/templates/desktop/.clauderules.template +112 -112
  124. package/templates/desktop/.cursorrules.template +102 -102
  125. package/templates/desktop/README.template.md +170 -170
  126. package/templates/desktop/ai-instructions.template.md +366 -366
  127. package/templates/desktop/copilot-instructions.template.md +140 -140
  128. package/templates/desktop/docs/docs/api.template.md +320 -320
  129. package/templates/desktop/docs/docs/architecture.template.md +724 -724
  130. package/templates/desktop/docs/docs/business-flows.template.md +102 -102
  131. package/templates/desktop/docs/docs/code-standards.template.md +792 -792
  132. package/templates/desktop/docs/docs/contributing.template.md +149 -149
  133. package/templates/desktop/docs/docs/data-model.template.md +520 -520
  134. package/templates/desktop/docs/docs/operations.template.md +720 -720
  135. package/templates/desktop/docs/docs/testing.template.md +722 -722
  136. package/templates/desktop/project-brief.template.md +150 -150
  137. package/templates/desktop/specs/specs/configuration.template.md +121 -121
  138. package/templates/desktop/specs/specs/security.template.md +392 -392
  139. package/templates/frontend/README.template.md +2 -2
  140. package/templates/frontend/ai-instructions.template.md +2 -2
  141. package/templates/frontend/docs/api-integration.template.md +362 -362
  142. package/templates/frontend/docs/components.template.md +2 -2
  143. package/templates/frontend/docs/error-handling.template.md +360 -360
  144. package/templates/frontend/docs/operations.template.md +107 -107
  145. package/templates/frontend/docs/performance.template.md +124 -124
  146. package/templates/frontend/docs/pwa.template.md +119 -119
  147. package/templates/frontend/docs/state-management.template.md +2 -2
  148. package/templates/frontend/docs/styling.template.md +2 -2
  149. package/templates/frontend/docs/testing.template.md +2 -2
  150. package/templates/frontend/project-brief.template.md +2 -2
  151. package/templates/frontend/specs/accessibility.template.md +95 -95
  152. package/templates/frontend/specs/configuration.template.md +2 -2
  153. package/templates/frontend/specs/security.template.md +175 -175
  154. package/templates/fullstack/README.template.md +252 -252
  155. package/templates/fullstack/ai-instructions.template.md +444 -444
  156. package/templates/fullstack/project-brief.template.md +157 -157
  157. package/templates/fullstack/specs/configuration.template.md +340 -340
  158. package/templates/mobile/README.template.md +167 -167
  159. package/templates/mobile/ai-instructions.template.md +196 -196
  160. package/templates/mobile/docs/app-store.template.md +135 -135
  161. package/templates/mobile/docs/architecture.template.md +63 -63
  162. package/templates/mobile/docs/native-features.template.md +94 -94
  163. package/templates/mobile/docs/navigation.template.md +59 -59
  164. package/templates/mobile/docs/offline-strategy.template.md +65 -65
  165. package/templates/mobile/docs/permissions.template.md +56 -56
  166. package/templates/mobile/docs/state-management.template.md +85 -85
  167. package/templates/mobile/docs/testing.template.md +109 -109
  168. package/templates/mobile/project-brief.template.md +69 -69
  169. package/templates/mobile/specs/build-configuration.template.md +91 -91
  170. package/templates/mobile/specs/deployment.template.md +92 -92
  171. package/templates/work.template.md +61 -47
@@ -1,573 +1,573 @@
1
- ## PHASE 2: Data Architecture (15-20 min)
2
-
3
- > **Order for this phase:** 2.1 → 2.2 → 2.3 → 2.4 → 2.5 → 2.6 → 2.7
4
-
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.
8
-
9
- ### Objective
10
-
11
- Design the database model, entities, and relationships.
12
-
13
- ---
14
-
15
- ## 🔍 Pre-Flight Check (Smart Skip Logic)
16
-
17
- > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
18
-
19
- **Execute Pre-Flight Check for Phase 2:**
20
-
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
25
-
26
- **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
27
-
28
- ---
29
-
30
- ## Phase 2 Questions (Full Mode)
31
-
32
- **2.1 Database Type**
33
-
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.]
39
-
40
- Is this correct? (Y/N)
41
- If no, please provide correct database type.
42
-
43
- [If NOT detected, ask:]
44
- What type of database will you use? (Can select multiple)
45
-
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]
51
-
52
- Why this choice?
53
- ```
54
-
55
- **2.2 Core Data Entities**
56
-
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
- ```
128
-
129
- **2.3 Relationships**
130
-
131
- ```
132
- Common relationship patterns (select what applies to your entities):
133
-
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: __
142
-
143
- → Your selection (e.g., A, B, D): __
144
-
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: __
150
-
151
- → Your selection (e.g., A, C, E): __
152
-
153
- ⭐ One-to-One (less common):
154
-
155
- ⭐ One-to-One (less common):
156
- C) Order → Payment (one order has one payment)
157
- D) Other: __
158
-
159
- → Your selection (e.g., A, B): __
160
-
161
- ⭐ Polymorphic (one entity relates to multiple types):
162
- C) Activity → (User | Organization | Deal) - activities linked to various objects
163
- D) Other: __
164
-
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
- -
173
-
174
- (Format: EntityA → EntityB: Relationship type - description)
175
- ```
176
-
177
- **2.4 Data Volume Estimates**
178
-
179
- ```
180
- Estimated data volume (Year 1):
181
-
182
- - Total records: [Low (<10k) / Medium (10k-1M) / High (>1M)]
183
- - Growth rate: [Slow / Moderate / Fast]
184
-
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)
189
-
190
- ⭐ Standard for MVP:
191
- - Records: Low (<10k)
192
- - Growth: Moderate
193
- - Complexity: Low (mostly text)
194
-
195
- 🏆 Standard for Production/Scale:
196
- - Records: High (>1M)
197
- - Growth: Fast
198
- - Complexity: Medium/High (includes media/files)
199
- ```
200
-
201
- **2.5 Data Retention**
202
-
203
- ```
204
- Data retention policies:
205
-
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
210
-
211
- For each entity that has special retention needs, specify:
212
- ```
213
-
214
- **2.6 Data Migration**
215
-
216
- ```
217
- Is this a new system or replacing an existing one?
218
-
219
- A) 🆕 New system - No legacy data
220
- B) 🔄 Replacing existing - Need to migrate from [system name]
221
- C) 🔌 Integration - Syncing with existing system
222
-
223
- If migration needed:
224
- - Source system: __
225
- - Data volume to migrate: __
226
- - Migration strategy: [Big bang / Phased / Parallel run]
227
- ```
228
-
229
- **2.7 Critical Data Patterns**
230
-
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
- ```
245
-
246
- **2.7.1 Soft Delete Configuration** (if A selected above)
247
-
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
- ```
278
-
279
- **2.7.2 State Machines** (for entities with lifecycle states)
280
-
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](../../.ai-flow/prompts/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
- ---
550
-
551
- > ⚠️ **CRITICAL:** DO NOT generate README.md in Phase 2. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
552
-
553
- ---
554
-
555
- ## 📝 Generated Documents
556
-
557
- After Phase 2, generate/update:
558
- - `docs/data-model.md` - Database schema and entity relationships
559
-
560
- ---
561
-
562
- **Next Phase:** Phase 3 - System Architecture (15-20 min)
563
-
564
- Read: `.ai-flow/prompts/backend/flow-build-phase-3.md`
565
-
566
- ---
567
-
568
- **Last Updated:** 2025-12-20
569
- **Version:** 2.1.8
570
-
571
- ---
572
-
573
- ## PHASE 3: System Architecture (15-20 min)
1
+ ## PHASE 2: Data Architecture (15-20 min)
2
+
3
+ > **Order for this phase:** 2.1 → 2.2 → 2.3 → 2.4 → 2.5 → 2.6 → 2.7
4
+
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.
8
+
9
+ ### Objective
10
+
11
+ Design the database model, entities, and relationships.
12
+
13
+ ---
14
+
15
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
16
+
17
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
18
+
19
+ **Execute Pre-Flight Check for Phase 2:**
20
+
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
25
+
26
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
27
+
28
+ ---
29
+
30
+ ## Phase 2 Questions (Full Mode)
31
+
32
+ **2.1 Database Type**
33
+
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.]
39
+
40
+ Is this correct? (Y/N)
41
+ If no, please provide correct database type.
42
+
43
+ [If NOT detected, ask:]
44
+ What type of database will you use? (Can select multiple)
45
+
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]
51
+
52
+ Why this choice?
53
+ ```
54
+
55
+ **2.2 Core Data Entities**
56
+
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
+ ```
128
+
129
+ **2.3 Relationships**
130
+
131
+ ```
132
+ Common relationship patterns (select what applies to your entities):
133
+
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: __
142
+
143
+ → Your selection (e.g., A, B, D): __
144
+
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: __
150
+
151
+ → Your selection (e.g., A, C, E): __
152
+
153
+ ⭐ One-to-One (less common):
154
+
155
+ ⭐ One-to-One (less common):
156
+ C) Order → Payment (one order has one payment)
157
+ D) Other: __
158
+
159
+ → Your selection (e.g., A, B): __
160
+
161
+ ⭐ Polymorphic (one entity relates to multiple types):
162
+ C) Activity → (User | Organization | Deal) - activities linked to various objects
163
+ D) Other: __
164
+
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
+ -
173
+
174
+ (Format: EntityA → EntityB: Relationship type - description)
175
+ ```
176
+
177
+ **2.4 Data Volume Estimates**
178
+
179
+ ```
180
+ Estimated data volume (Year 1):
181
+
182
+ - Total records: [Low (<10k) / Medium (10k-1M) / High (>1M)]
183
+ - Growth rate: [Slow / Moderate / Fast]
184
+
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)
189
+
190
+ ⭐ Standard for MVP:
191
+ - Records: Low (<10k)
192
+ - Growth: Moderate
193
+ - Complexity: Low (mostly text)
194
+
195
+ 🏆 Standard for Production/Scale:
196
+ - Records: High (>1M)
197
+ - Growth: Fast
198
+ - Complexity: Medium/High (includes media/files)
199
+ ```
200
+
201
+ **2.5 Data Retention**
202
+
203
+ ```
204
+ Data retention policies:
205
+
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
210
+
211
+ For each entity that has special retention needs, specify:
212
+ ```
213
+
214
+ **2.6 Data Migration**
215
+
216
+ ```
217
+ Is this a new system or replacing an existing one?
218
+
219
+ A) 🆕 New system - No legacy data
220
+ B) 🔄 Replacing existing - Need to migrate from [system name]
221
+ C) 🔌 Integration - Syncing with existing system
222
+
223
+ If migration needed:
224
+ - Source system: __
225
+ - Data volume to migrate: __
226
+ - Migration strategy: [Big bang / Phased / Parallel run]
227
+ ```
228
+
229
+ **2.7 Critical Data Patterns**
230
+
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
+ ```
245
+
246
+ **2.7.1 Soft Delete Configuration** (if A selected above)
247
+
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
+ ```
278
+
279
+ **2.7.2 State Machines** (for entities with lifecycle states)
280
+
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](../../.ai-flow/prompts/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
+ ---
550
+
551
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in Phase 2. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
552
+
553
+ ---
554
+
555
+ ## 📝 Generated Documents
556
+
557
+ After Phase 2, generate/update:
558
+ - `docs/data-model.md` - Database schema and entity relationships
559
+
560
+ ---
561
+
562
+ **Next Phase:** Phase 3 - System Architecture (15-20 min)
563
+
564
+ Read: `.ai-flow/prompts/backend/flow-build-phase-3.md`
565
+
566
+ ---
567
+
568
+ **Last Updated:** 2025-12-20
569
+ **Version:** 2.1.8
570
+
571
+ ---
572
+
573
+ ## PHASE 3: System Architecture (15-20 min)