ai-flow-dev 1.0.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.
- package/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +791 -0
- package/dist/cli.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +46 -0
- package/dist/fs-utils.js.map +1 -0
- package/package.json +71 -0
- package/prompts/backend/flow-dev-feature.md +1318 -0
- package/prompts/backend/flow-dev-fix.md +903 -0
- package/prompts/backend/flow-dev-refactor.md +715 -0
- package/prompts/backend/flow-dev-review.md +401 -0
- package/prompts/backend/flow-dev-work.md +1129 -0
- package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
- package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
- package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
- package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
- package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
- package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
- package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
- package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
- package/prompts/backend/flow-docs-gen.md +820 -0
- package/prompts/backend/flow-docs-sync.md +526 -0
- package/prompts/backend/flow-project-init.md +248 -0
- package/prompts/backend/flow-project-roadmap.md +1159 -0
- package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
- package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
- package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
- package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
- package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
- package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
- package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
- package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
- package/prompts/frontend/flow-docs-gen.md +413 -0
- package/prompts/frontend/flow-docs-sync.md +561 -0
- package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
- package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
- package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
- package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
- package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
- package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
- package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
- package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
- package/prompts/mobile/flow-docs-gen.md +430 -0
- package/prompts/mobile/flow-docs-sync.md +634 -0
- package/templates/backend/.clauderules.template +111 -0
- package/templates/backend/.cursorrules.template +102 -0
- package/templates/backend/.env.example.template +122 -0
- package/templates/backend/README.template.md +200 -0
- package/templates/backend/ai-instructions.template.md +354 -0
- package/templates/backend/copilot-instructions.template.md +160 -0
- package/templates/backend/docs/api.template.md +251 -0
- package/templates/backend/docs/architecture.template.md +612 -0
- package/templates/backend/docs/business-flows.template.md +109 -0
- package/templates/backend/docs/code-standards.template.md +828 -0
- package/templates/backend/docs/contributing.template.md +163 -0
- package/templates/backend/docs/data-model.template.md +416 -0
- package/templates/backend/docs/operations.template.md +591 -0
- package/templates/backend/docs/testing.template.md +762 -0
- package/templates/backend/project-brief.template.md +176 -0
- package/templates/backend/specs/configuration.template.md +133 -0
- package/templates/backend/specs/security.template.md +422 -0
- package/templates/frontend/README.template.md +121 -0
- package/templates/frontend/ai-instructions.template.md +368 -0
- package/templates/frontend/docs/api-integration.template.md +390 -0
- package/templates/frontend/docs/components.template.md +567 -0
- package/templates/frontend/docs/error-handling.template.md +385 -0
- package/templates/frontend/docs/operations.template.md +123 -0
- package/templates/frontend/docs/performance.template.md +140 -0
- package/templates/frontend/docs/pwa.template.md +135 -0
- package/templates/frontend/docs/state-management.template.md +394 -0
- package/templates/frontend/docs/styling.template.md +779 -0
- package/templates/frontend/docs/testing.template.md +736 -0
- package/templates/frontend/project-brief.template.md +55 -0
- package/templates/frontend/specs/accessibility.template.md +111 -0
- package/templates/frontend/specs/configuration.template.md +520 -0
- package/templates/frontend/specs/security.template.md +197 -0
- package/templates/fullstack/README.template.md +282 -0
- package/templates/fullstack/ai-instructions.template.md +487 -0
- package/templates/fullstack/project-brief.template.md +197 -0
- package/templates/fullstack/specs/configuration.template.md +380 -0
- package/templates/mobile/AGENT.template.md +251 -0
- package/templates/mobile/README.template.md +195 -0
- package/templates/mobile/ai-instructions.template.md +221 -0
- package/templates/mobile/docs/app-store.template.md +163 -0
- package/templates/mobile/docs/architecture.template.md +100 -0
- package/templates/mobile/docs/native-features.template.md +137 -0
- package/templates/mobile/docs/navigation.template.md +81 -0
- package/templates/mobile/docs/offline-strategy.template.md +90 -0
- package/templates/mobile/docs/permissions.template.md +70 -0
- package/templates/mobile/docs/state-management.template.md +116 -0
- package/templates/mobile/docs/testing.template.md +146 -0
- package/templates/mobile/project-brief.template.md +97 -0
- package/templates/mobile/specs/build-configuration.template.md +116 -0
- package/templates/mobile/specs/deployment.template.md +114 -0
- package/templates/shared/AGENT.template.md +252 -0
|
@@ -0,0 +1,460 @@
|
|
|
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
|
+
> **📌 Note:** If Phase 0 detected database/entities from code, those will be pre-filled. Review and confirm.
|
|
6
|
+
|
|
7
|
+
### Objective
|
|
8
|
+
|
|
9
|
+
Design the database model, entities, and relationships.
|
|
10
|
+
|
|
11
|
+
**2.1 Database Type**
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
[If detected from Phase 0, show:]
|
|
15
|
+
✅ Database Detected: [PostgreSQL/MySQL/MongoDB/etc.]
|
|
16
|
+
✅ Version: [version if found]
|
|
17
|
+
✅ ORM/Client: [Prisma/TypeORM/Sequelize/SQLAlchemy/etc.]
|
|
18
|
+
|
|
19
|
+
Is this correct? (Y/N)
|
|
20
|
+
If no, please provide correct database type.
|
|
21
|
+
|
|
22
|
+
[If NOT detected, ask:]
|
|
23
|
+
What type of database will you use? (Can select multiple)
|
|
24
|
+
|
|
25
|
+
A) ⭐ PostgreSQL - Recommended for most backends (ACID, relational, JSON support)
|
|
26
|
+
B) 🔥 MySQL/MariaDB - Popular, proven, wide ecosystem
|
|
27
|
+
C) ⚡ MongoDB - Modern, NoSQL, flexible schema
|
|
28
|
+
D) 🏆 Multi-database - PostgreSQL + Redis + S3, etc.
|
|
29
|
+
E) Other: [specify]
|
|
30
|
+
|
|
31
|
+
Why this choice?
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**2.2 Core Data Entities**
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
[If detected from Phase 0, show:]
|
|
38
|
+
✅ Entities Detected from Code:
|
|
39
|
+
- [User] - [description if inferred from code]
|
|
40
|
+
- [Product] - [description]
|
|
41
|
+
- [Order] - [description]
|
|
42
|
+
- [etc.]
|
|
43
|
+
|
|
44
|
+
Are these correct? (Y/N)
|
|
45
|
+
Do you need to add more entities? (Y/N)
|
|
46
|
+
|
|
47
|
+
[If NOT detected OR user wants to add more, show:]
|
|
48
|
+
Based on your system type (from Phase 1, question 1.5), here are common entities:
|
|
49
|
+
|
|
50
|
+
🛒 E-commerce typical entities:
|
|
51
|
+
□ User - System users with authentication
|
|
52
|
+
□ Product - Items available for purchase
|
|
53
|
+
□ Category - Product categorization
|
|
54
|
+
□ Cart - Shopping cart items
|
|
55
|
+
□ Order - Customer orders
|
|
56
|
+
□ OrderItem - Individual items in an order
|
|
57
|
+
□ Payment - Payment transactions
|
|
58
|
+
□ Address - Shipping/billing addresses
|
|
59
|
+
□ Review - Product reviews and ratings
|
|
60
|
+
□ Inventory - Stock tracking
|
|
61
|
+
|
|
62
|
+
📱 SaaS typical entities:
|
|
63
|
+
□ User - System users
|
|
64
|
+
□ Organization - Tenant/workspace
|
|
65
|
+
□ Team - Groups within organizations
|
|
66
|
+
□ Role - Access control roles
|
|
67
|
+
□ Permission - Granular permissions
|
|
68
|
+
□ Subscription - Billing plans
|
|
69
|
+
□ Invoice - Payment records
|
|
70
|
+
□ ApiKey - API access credentials
|
|
71
|
+
□ AuditLog - Activity tracking
|
|
72
|
+
|
|
73
|
+
📊 CRM typical entities:
|
|
74
|
+
□ User - System users
|
|
75
|
+
□ Contact - Customers/leads
|
|
76
|
+
□ Company - Organizations
|
|
77
|
+
□ Deal - Sales opportunities
|
|
78
|
+
□ Activity - Calls, emails, meetings
|
|
79
|
+
□ Task - To-do items
|
|
80
|
+
□ Note - Free-form notes
|
|
81
|
+
□ Document - Attachments
|
|
82
|
+
|
|
83
|
+
🎮 Social typical entities:
|
|
84
|
+
□ User - Platform users
|
|
85
|
+
□ Profile - User profiles
|
|
86
|
+
□ Post - Content/publications
|
|
87
|
+
□ Comment - Post comments
|
|
88
|
+
□ Like/Reaction - Engagement
|
|
89
|
+
□ Follow - User connections
|
|
90
|
+
□ Notification - User alerts
|
|
91
|
+
□ Message - Direct messages
|
|
92
|
+
□ Group - Communities
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
Select relevant entities from above OR list your custom entities:
|
|
97
|
+
|
|
98
|
+
1.
|
|
99
|
+
2.
|
|
100
|
+
3.
|
|
101
|
+
4.
|
|
102
|
+
5.
|
|
103
|
+
...
|
|
104
|
+
|
|
105
|
+
(Include brief description for custom entities)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**2.3 Relationships**
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Common relationship patterns (select what applies to your entities):
|
|
112
|
+
|
|
113
|
+
⭐ One-to-Many (most common):
|
|
114
|
+
□ User → Order (one user has many orders)
|
|
115
|
+
□ User → Post (one user creates many posts)
|
|
116
|
+
□ Organization → User (one org has many users)
|
|
117
|
+
□ Category → Product (one category contains many products)
|
|
118
|
+
□ Order → OrderItem (one order has many line items)
|
|
119
|
+
□ Post → Comment (one post has many comments)
|
|
120
|
+
□ Other: __
|
|
121
|
+
|
|
122
|
+
⭐ Many-to-Many (via join table):
|
|
123
|
+
□ Order ↔ Product (via OrderItem)
|
|
124
|
+
□ User ↔ Role (via UserRole)
|
|
125
|
+
□ Post ↔ Tag (via PostTag)
|
|
126
|
+
□ User ↔ User (Follow/Friend via UserFollow)
|
|
127
|
+
□ Course ↔ Student (via Enrollment)
|
|
128
|
+
□ Other: __
|
|
129
|
+
|
|
130
|
+
⭐ One-to-One (less common):
|
|
131
|
+
□ User → Profile (one user has one profile)
|
|
132
|
+
□ User → UserSettings (one user has one settings record)
|
|
133
|
+
□ Order → Payment (one order has one payment)
|
|
134
|
+
□ Other: __
|
|
135
|
+
|
|
136
|
+
⭐ Polymorphic (one entity relates to multiple types):
|
|
137
|
+
□ Comment → (Post | Photo | Video) - comments on different content types
|
|
138
|
+
□ Attachment → (Task | Email | Note) - files attached to different entities
|
|
139
|
+
□ Activity → (User | Organization | Deal) - activities linked to various objects
|
|
140
|
+
□ Other: __
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
Your specific relationships (list main ones):
|
|
145
|
+
-
|
|
146
|
+
-
|
|
147
|
+
-
|
|
148
|
+
|
|
149
|
+
(Format: EntityA → EntityB: Relationship type - description)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**2.4 Data Volume Estimates**
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
Estimated data volume (Year 1):
|
|
156
|
+
|
|
157
|
+
- Total records: [Low (<10k) / Medium (10k-1M) / High (>1M)]
|
|
158
|
+
- Growth rate: [Slow / Moderate / Fast]
|
|
159
|
+
|
|
160
|
+
Data Complexity (Record Size):
|
|
161
|
+
A) 📄 Low - Mostly text data (JSON, strings)
|
|
162
|
+
B) 🖼️ Medium - Some images/documents (blobs, small files)
|
|
163
|
+
C) 🎥 High - Heavy media/large files (video, audio, raw data)
|
|
164
|
+
|
|
165
|
+
⭐ Standard for MVP:
|
|
166
|
+
- Records: Low (<10k)
|
|
167
|
+
- Growth: Moderate
|
|
168
|
+
- Complexity: Low (mostly text)
|
|
169
|
+
|
|
170
|
+
🏆 Standard for Production/Scale:
|
|
171
|
+
- Records: High (>1M)
|
|
172
|
+
- Growth: Fast
|
|
173
|
+
- Complexity: Medium/High (includes media/files)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**2.5 Data Retention**
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
Data retention policies:
|
|
180
|
+
|
|
181
|
+
A) ♾️ Keep forever - Never delete data
|
|
182
|
+
B) 🗓️ Regulatory compliance - Specific retention period (e.g., 7 years)
|
|
183
|
+
C) 🔄 Archival strategy - Archive old data after __ months
|
|
184
|
+
D) 🗑️ Auto-deletion - Delete after __ days/months
|
|
185
|
+
|
|
186
|
+
For each entity that has special retention needs, specify:
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**2.6 Data Migration**
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
Is this a new system or replacing an existing one?
|
|
193
|
+
|
|
194
|
+
A) 🆕 New system - No legacy data
|
|
195
|
+
B) 🔄 Replacing existing - Need to migrate from [system name]
|
|
196
|
+
C) 🔌 Integration - Syncing with existing system
|
|
197
|
+
|
|
198
|
+
If migration needed:
|
|
199
|
+
- Source system: __
|
|
200
|
+
- Data volume to migrate: __
|
|
201
|
+
- Migration strategy: [Big bang / Phased / Parallel run]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**2.7 Critical Data Patterns**
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
Select data patterns that apply:
|
|
208
|
+
|
|
209
|
+
A) 🔐 Soft deletes - Keep deleted records with deleted_at flag
|
|
210
|
+
B) 📝 Audit trail - Track who changed what and when
|
|
211
|
+
C) 🕐 Temporal data - Track historical versions
|
|
212
|
+
D) 🌍 Multi-tenancy - Data isolation per customer/organization
|
|
213
|
+
E) 🎭 Polymorphic relationships - One entity relates to multiple types
|
|
214
|
+
F) 🔗 Graph relationships - Complex many-to-many networks
|
|
215
|
+
G) 📊 Aggregations/Materialized views - Pre-computed summaries
|
|
216
|
+
H) 🗂️ Partitioning - Split large tables by date/region/etc.
|
|
217
|
+
|
|
218
|
+
For each selected, provide brief detail:
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**2.8 Database Indexes**
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
What indexes will you need for performance optimization?
|
|
225
|
+
|
|
226
|
+
Indexes are critical for query performance. Based on your entities and relationships, consider:
|
|
227
|
+
|
|
228
|
+
Common indexes needed:
|
|
229
|
+
□ Foreign keys (automatically indexed by most ORMs)
|
|
230
|
+
□ Frequently queried columns (email, username, status)
|
|
231
|
+
□ Columns used in WHERE clauses
|
|
232
|
+
□ Columns used in JOIN conditions
|
|
233
|
+
□ Columns used in ORDER BY clauses
|
|
234
|
+
□ Composite indexes for multi-column queries
|
|
235
|
+
|
|
236
|
+
Do you have specific query patterns that need optimization?
|
|
237
|
+
|
|
238
|
+
Example:
|
|
239
|
+
- User lookup by email: Index on users.email
|
|
240
|
+
- Order search by date range: Index on orders.created_at
|
|
241
|
+
- Product search by category and status: Composite index on (category_id, status)
|
|
242
|
+
|
|
243
|
+
Your specific indexes:
|
|
244
|
+
1.
|
|
245
|
+
2.
|
|
246
|
+
3.
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**2.9 Transaction Management**
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
What transaction isolation level will you use?
|
|
253
|
+
|
|
254
|
+
A) ⭐ READ COMMITTED - Recommended default (PostgreSQL, MySQL default)
|
|
255
|
+
- Prevents dirty reads
|
|
256
|
+
- Allows non-repeatable reads and phantom reads
|
|
257
|
+
- Good balance of consistency and performance
|
|
258
|
+
|
|
259
|
+
B) READ UNCOMMITTED - Lowest isolation (rarely used)
|
|
260
|
+
- Allows dirty reads
|
|
261
|
+
- Fastest but least safe
|
|
262
|
+
|
|
263
|
+
C) REPEATABLE READ - Higher isolation
|
|
264
|
+
- Prevents dirty reads and non-repeatable reads
|
|
265
|
+
- May have phantom reads
|
|
266
|
+
- Better consistency, slightly slower
|
|
267
|
+
|
|
268
|
+
D) 🏆 SERIALIZABLE - Highest isolation (Enterprise)
|
|
269
|
+
- Prevents all concurrency issues
|
|
270
|
+
- Slowest but safest
|
|
271
|
+
- Use only when absolutely necessary
|
|
272
|
+
|
|
273
|
+
Your choice: __
|
|
274
|
+
|
|
275
|
+
Consistency model:
|
|
276
|
+
A) ⭐ Strong consistency - All reads see latest writes (most backends)
|
|
277
|
+
B) Eventual consistency - Acceptable delay for better performance (distributed systems)
|
|
278
|
+
|
|
279
|
+
If eventual consistency:
|
|
280
|
+
- Acceptable delay: __ seconds/minutes
|
|
281
|
+
- Conflict resolution strategy: __
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**2.10 Schema Migrations**
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
What migration tool will you use?
|
|
288
|
+
|
|
289
|
+
A) ⭐ Prisma Migrate (if using Prisma)
|
|
290
|
+
B) TypeORM Migrations (if using TypeORM)
|
|
291
|
+
C) Alembic (Python/SQLAlchemy)
|
|
292
|
+
D) Flyway (Java/Universal)
|
|
293
|
+
E) Liquibase (Java/Universal)
|
|
294
|
+
F) Django Migrations (Django)
|
|
295
|
+
G) Laravel Migrations (Laravel)
|
|
296
|
+
H) Rails Migrations (Ruby on Rails)
|
|
297
|
+
I) Other: __
|
|
298
|
+
|
|
299
|
+
Migration strategy:
|
|
300
|
+
A) ⭐ Versioned migrations - Each change creates a new migration file
|
|
301
|
+
B) Auto-migrations - Tool generates migrations automatically
|
|
302
|
+
C) Manual SQL scripts - Write migrations manually
|
|
303
|
+
|
|
304
|
+
Zero-downtime migrations:
|
|
305
|
+
A) ⭐ Yes - Plan for zero-downtime migrations (Production-Ready/Enterprise)
|
|
306
|
+
B) No - Accept maintenance windows (MVP)
|
|
307
|
+
|
|
308
|
+
If zero-downtime:
|
|
309
|
+
- Strategy: [Expand/Contract, Blue-Green, etc.]
|
|
310
|
+
- Rollback plan: __
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Phase 2 Output
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
📋 PHASE 2 SUMMARY:
|
|
317
|
+
|
|
318
|
+
Database: [type(s)]
|
|
319
|
+
Core Entities: [list with descriptions]
|
|
320
|
+
Relationships: [key relationships]
|
|
321
|
+
Data Volume: [estimates]
|
|
322
|
+
Retention: [policies]
|
|
323
|
+
Migration: [strategy if applicable]
|
|
324
|
+
Data Patterns: [selected patterns with brief details]
|
|
325
|
+
Database Indexes: [list of indexes needed]
|
|
326
|
+
Transaction Isolation: [level + consistency model]
|
|
327
|
+
Schema Migrations: [tool + strategy + zero-downtime approach]
|
|
328
|
+
|
|
329
|
+
Is this correct? (Yes/No)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
### 📄 Generate Phase 2 Documents
|
|
335
|
+
|
|
336
|
+
**Before starting generation:**
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
📖 Loading context from previous phases...
|
|
340
|
+
✅ Re-reading project-brief.md
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Once confirmed, generate:
|
|
344
|
+
|
|
345
|
+
**1. `docs/data-model.md`**
|
|
346
|
+
|
|
347
|
+
- Use template: `.ai-flow/templates/docs/data-model.template.md`
|
|
348
|
+
- Fill with all Phase 2 entity and relationship information
|
|
349
|
+
- Include entity catalog, relationships, data patterns
|
|
350
|
+
- Generate entity-relationship diagram (ER diagram) in mermaid format showing all entities and their relationships
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
#### 🎨 MERMAID ER DIAGRAM FORMAT - CRITICAL
|
|
355
|
+
|
|
356
|
+
**Use this exact format** (lowercase `mermaid`, no spaces, three backticks):
|
|
357
|
+
|
|
358
|
+
````markdown
|
|
359
|
+
```mermaid
|
|
360
|
+
erDiagram
|
|
361
|
+
USER ||--o{ ORDER : places
|
|
362
|
+
USER ||--o{ REVIEW : writes
|
|
363
|
+
PRODUCT ||--o{ ORDER_ITEM : contains
|
|
364
|
+
ORDER ||--o{ ORDER_ITEM : includes
|
|
365
|
+
|
|
366
|
+
USER {
|
|
367
|
+
string id PK "Primary Key"
|
|
368
|
+
string email UK "Unique Key"
|
|
369
|
+
string name
|
|
370
|
+
string hashedPassword
|
|
371
|
+
datetime createdAt
|
|
372
|
+
datetime updatedAt
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
ORDER {
|
|
376
|
+
string id PK
|
|
377
|
+
string userId FK "Foreign Key to USER"
|
|
378
|
+
decimal total
|
|
379
|
+
string status "pending, completed, cancelled"
|
|
380
|
+
datetime createdAt
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
PRODUCT {
|
|
384
|
+
string id PK
|
|
385
|
+
string name
|
|
386
|
+
text description
|
|
387
|
+
decimal price
|
|
388
|
+
int stock
|
|
389
|
+
datetime createdAt
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
ORDER_ITEM {
|
|
393
|
+
string id PK
|
|
394
|
+
string orderId FK
|
|
395
|
+
string productId FK
|
|
396
|
+
int quantity
|
|
397
|
+
decimal price
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
REVIEW {
|
|
401
|
+
string id PK
|
|
402
|
+
string userId FK
|
|
403
|
+
string productId FK
|
|
404
|
+
int rating "1-5 stars"
|
|
405
|
+
text comment
|
|
406
|
+
datetime createdAt
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
````
|
|
410
|
+
|
|
411
|
+
**Relationship Notation:**
|
|
412
|
+
- `||--o{` = One-to-Many (one to zero or more)
|
|
413
|
+
- `||--||` = One-to-One (one to exactly one)
|
|
414
|
+
- `}o--o{` = Many-to-Many (requires junction table)
|
|
415
|
+
- `||--|{` = One-to-Many (one to one or more)
|
|
416
|
+
|
|
417
|
+
**Field Notation:**
|
|
418
|
+
- `PK` = Primary Key
|
|
419
|
+
- `FK` = Foreign Key
|
|
420
|
+
- `UK` = Unique Key
|
|
421
|
+
- Add descriptions in quotes after field type for clarity
|
|
422
|
+
|
|
423
|
+
**Common Mistakes to Avoid:**
|
|
424
|
+
- ❌ ````Mermaid` (capital M - will not render)
|
|
425
|
+
- ❌ ```` mermaid` (extra space - will not render)
|
|
426
|
+
- ❌ Indenting the entire diagram with spaces/tabs
|
|
427
|
+
- ❌ Missing closing ` ``` ` fence
|
|
428
|
+
- ❌ Invalid entity/relationship syntax
|
|
429
|
+
|
|
430
|
+
**Validation:** Preview your diagram at https://mermaid.live/ or in VS Code markdown preview
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
```
|
|
435
|
+
✅ Generated: docs/data-model.md
|
|
436
|
+
|
|
437
|
+
📝 Please review this document. Do you need to make any corrections?
|
|
438
|
+
|
|
439
|
+
A) ✅ Looks perfect, continue to Phase 3
|
|
440
|
+
B) 📝 I'll edit it now (I'll wait)
|
|
441
|
+
C) 🔄 Regenerate with changes (tell me what to modify)
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**If user selects B:**
|
|
445
|
+
|
|
446
|
+
```
|
|
447
|
+
Perfect. Please edit docs/data-model.md and type "ready" when you're done.
|
|
448
|
+
I'll re-read the file to update my context before continuing.
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Then execute: `read_file('docs/data-model.md')` to refresh context.
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
**Proceed to Phase 3 only after document is validated.**
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## PHASE 3: System Architecture (15-20 min)
|
|
460
|
+
|