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,782 +1,782 @@
1
- ## PHASE 3: System Architecture (15-20 min)
2
-
3
- > **Order for this phase:** 3.1 β†’ 3.2 β†’ 3.3 β†’ 3.4 β†’ 3.5 β†’ 3.6 β†’ 3.7 β†’ 3.8 β†’ 3.9 β†’ 3.10 β†’ 3.11 β†’ 3.12
4
-
5
- > **πŸ“Œ Scope-based behavior:**
6
- >
7
- > - **MVP:** Ask 3.1-3.6 (tech stack essentials) and 3.12 (API structure), skip 3.7-3.11 (advanced features), mark as "TBD"
8
- > - **Production-Ready:** Ask all questions 3.1-3.12
9
- > - **Enterprise:** Ask all questions 3.1-3.12 with emphasis on scalability and integrations
10
-
11
- > **πŸ“Œ Note:** If Phase 0 detected framework/language/dependencies, those will be pre-filled. Review and confirm.
12
-
13
- ### Objective
14
-
15
- Define the technical stack, architecture patterns, and system design.
16
-
17
- > **Note:** At the end of this phase, the AI will automatically generate a system architecture diagram in mermaid format, based on your answers. This diagram will be included in the docs/architecture.md document.
18
-
19
- ---
20
-
21
- ## πŸ” Pre-Flight Check (Smart Skip Logic)
22
-
23
- > πŸ“Ž **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
24
-
25
- **Execute Pre-Flight Check for Phase 3:**
26
-
27
- - **Target File**: `docs/architecture.md`
28
- - **Phase Name**: "SYSTEM ARCHITECTURE"
29
- - **Key Items**: Framework, architecture pattern, API style, database, caching, background jobs, integrations
30
- - **Typical Gaps**: API versioning, rate limiting, caching strategy
31
-
32
- **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
33
-
34
- ---
35
-
36
- ## Phase 3 Questions (Full Mode)
37
-
38
- ---
39
-
40
- #### 🎨 MERMAID ARCHITECTURE DIAGRAM FORMAT - CRITICAL
41
-
42
- > πŸ“Ž **Reference:** See [prompts/shared/mermaid-guidelines.md](../../.ai-flow/prompts/shared/mermaid-guidelines.md) for architecture diagram syntax, node shapes, and styling.
43
-
44
- **Example Architecture Diagram:**
45
-
46
- **Common Architecture Patterns:**
47
-
48
- ```mermaid
49
- graph TD
50
- subgraph "Client Layer"
51
- Web[Web App]
52
- Mobile[Mobile App]
53
- end
54
-
55
- subgraph "API Layer"
56
- Gateway[API Gateway]
57
- Auth[Auth Service]
58
- end
59
-
60
- subgraph "Business Layer"
61
- Service1[User Service]
62
- Service2[Order Service]
63
- Service3[Payment Service]
64
- end
65
-
66
- subgraph "Data Layer"
67
- DB[(PostgreSQL)]
68
- Cache[(Redis)]
69
- end
70
-
71
- Web --> Gateway
72
- Mobile --> Gateway
73
- Gateway --> Auth
74
- Gateway --> Service1
75
- Gateway --> Service2
76
- Service2 --> Service3
77
- Service1 --> DB
78
- Service2 --> DB
79
- Service3 --> DB
80
- Service1 --> Cache
81
- Service2 --> Cache
82
- ```
83
-
84
- **Best Practices:**
85
-
86
- - Group related components using `subgraph`
87
- - Show external services (Email, SMS, Payment gateways)
88
- - Include monitoring and logging components
89
- - Label protocols on connections (HTTPS, gRPC, WebSocket)
90
- - Use consistent naming conventions
91
-
92
- ## **Validation:** Preview at https://mermaid.live/ before committing
93
-
94
- **3.1 Backend Framework**
95
-
96
- ```
97
- [If detected from Phase 0, show:]
98
- βœ… Framework Detected: [NestJS/FastAPI/Spring Boot/etc.]
99
- βœ… Language: [TypeScript 5.3/Python 3.11/Java 21/etc.]
100
- βœ… Runtime: [Node 20/Python 3.11/JVM 21/etc.]
101
-
102
- Is this correct? (Y/N)
103
- If no, please specify the correct framework and language.
104
-
105
- [If NOT detected, ask:]
106
- Which backend framework will you use?
107
-
108
- Node.js (JavaScript):
109
- A) πŸ”₯ Express.js - Popular (minimal, flexible, lightweight)
110
- B) Hapi.js - Enterprise (configuration-driven)
111
-
112
- TypeScript (Node.js):
113
- C) ⭐ NestJS - Recommended (structured, enterprise-ready, decorators)
114
- D) ⚑ Fastify - Modern (high performance, schema validation)
115
-
116
- Python:
117
- E) ⭐ FastAPI - Recommended (modern, fast, auto-docs)
118
- F) πŸ”₯ Django - Popular (batteries included, admin panel)
119
- G) Flask - Minimal (micro-framework, flexible)
120
-
121
- Java:
122
- H) πŸ† Spring Boot - Enterprise standard
123
- I) Quarkus - Modern (cloud-native, fast startup)
124
-
125
- Go:
126
- J) ⚑ Gin - Popular (fast, minimalist)
127
- K) Echo - Feature-rich (middleware, routing)
128
- L) Fiber - Express-like (high performance)
129
-
130
- Rust:
131
- M) ⚑ Actix-web - High performance (async, type-safe)
132
- N) Rocket - Developer-friendly (macros, type-safe)
133
- O) Axum - Modern (tokio-based, ergonomic)
134
-
135
- Kotlin:
136
- P) Ktor - Native Kotlin (coroutines, DSL)
137
- Q) Spring Boot - Java interop (Kotlin support)
138
-
139
- Other:
140
- R) Ruby (Rails)
141
- S) PHP (Laravel)
142
- T) C# (.NET Core)
143
-
144
- Your choice: __
145
- Why?
146
- ```
147
-
148
- **3.2 Language & Version**
149
-
150
- ```
151
- Primary programming language and version:
152
-
153
- Language: **
154
- Version: ** (e.g., Node 20, Python 3.11, Java 21)
155
-
156
- Type system:
157
- A) ⭐ Strongly typed - TypeScript, Java, Go (Recommended for large projects)
158
- B) Dynamically typed - JavaScript, Python, Ruby
159
- C) Gradually typed - Python with type hints
160
-
161
- Package Manager:
162
- A) ⭐ npm - Standard, comes with Node
163
- B) πŸ”₯ pnpm - Fast, disk efficient
164
- C) ⚑ yarn - Popular alternative
165
- D) πŸš€ bun - Ultra fast (if using Bun runtime)
166
- E) 🐍 pip/poetry (Python)
167
- F) β˜• Maven/Gradle (Java)
168
- ```
169
-
170
- **3.3 Architecture Pattern**
171
-
172
- ```
173
- What architecture pattern will you follow?
174
-
175
- A) ⭐ Layered Architecture (Recommended for most projects)
176
- - Presentation β†’ Business Logic β†’ Data Access
177
- - Easy to understand and maintain
178
-
179
- B) πŸ† Hexagonal/Clean Architecture (Enterprise)
180
- - Core domain isolated from infrastructure
181
- - Highly testable and flexible
182
-
183
- C) πŸ”₯ MVC (Popular, traditional)
184
- - Model-View-Controller separation
185
- - Good for traditional web apps
186
-
187
- D) πŸ“¦ Modular Monolith (Modern, scalable)
188
- - Single deployment with independent modules
189
- - Easier than microservices, more structured than monolith
190
- - Good middle ground for growing applications
191
-
192
- E) ⚑ Microservices (Modern, complex)
193
- - Multiple independent services
194
- - Best for large-scale distributed systems
195
-
196
- F) Other: __
197
-
198
- Your choice: __
199
- Why this pattern?
200
- ```
201
-
202
- **3.4 API Style**
203
-
204
- ```
205
- What API style will you expose?
206
-
207
- A) ⭐ REST API - Recommended (HTTP/JSON, standard, well-understood)
208
- B) πŸ”₯ GraphQL - Popular (flexible queries, single endpoint)
209
- C) ⚑ gRPC - Modern (high performance, protobuf, microservices)
210
- D) Mixed - REST + GraphQL or REST + gRPC
211
-
212
- Your choice: __
213
-
214
- API versioning strategy:
215
- A) URL versioning (/v1/users, /v2/users)
216
- B) Header versioning (Accept: application/vnd.api.v1+json)
217
- C) No versioning yet (will add when needed)
218
- ```
219
-
220
- **3.5 API Reference (Automated)**
221
-
222
- ````
223
- The AI will automatically generate standard CRUD endpoints for each entity defined in Phase 2.
224
-
225
- Please answer the following questions to define the global API conventions (these will apply to all endpoints unless otherwise specified):
226
-
227
- **A) Authentication and Access Control**
228
- 1. Do all CRUD endpoints require authentication?
229
- A) ⭐ Yes, all endpoints require authentication (recommended)
230
- B) Only some (specify which ones)
231
- C) No authentication required
232
-
233
- 2. Which roles can access each CRUD operation?
234
- - GET (list): [admin, manager, user]
235
- - GET (detail): [admin, manager, user]
236
- - POST (create): [admin, manager, user]
237
- - PUT (update): [admin, manager]
238
- - DELETE (delete): [admin]
239
- (Standard example: admin, manager, user. Adjust as needed.)
240
-
241
- **B) Listing and Filter Conventions**
242
- 3. Which pagination scheme do you prefer?
243
- A) ⭐ offset/limit (recommended)
244
- B) cursor-based
245
- C) No pagination
246
-
247
- 4. Which filter and sorting fields will be supported by default?
248
- - Filters: [id, name, date, etc.]
249
- - Sorting: [field, asc/desc]
250
-
251
- 5. How will filters be passed for GET list endpoints?
252
- A) ⭐ Query parameters (recommended for simple filters)
253
- Example: GET /users?name=John&status=active&page=1&limit=10
254
-
255
- B) POST /search endpoint with body (for complex filters)
256
- Example: POST /users/search
257
- Body: { "filters": { "name": "John", "status": "active" }, "page": 1, "limit": 10 }
258
-
259
- C) Both (query params for simple, POST /search for complex)
260
-
261
- 6. For POST/PUT/PATCH endpoints, will you use DTOs for request validation?
262
- A) ⭐ Yes, strict DTOs with validation (recommended)
263
- B) Accept raw JSON without strict schema
264
-
265
- If yes, validation library: [from Phase 3.6 - class-validator, Zod, Pydantic, Joi]
266
-
267
- **C) Error and Response Structure**
268
- 7. What error response format will be used?
269
- A) Standard JSON:
270
- ```json
271
- {
272
- "error": "Descriptive message",
273
- "code": 400,
274
- "details": {}
275
- }
276
- ```
277
-
278
- B) Other (specify)
279
-
280
- 8. Which fields will be included in the default successful response?
281
- - data, meta (pagination), links, etc.
282
-
283
- **D) Relationships and Expansions**
284
- 9. Allow expanding relationships (include/expand)?
285
- A) ⭐ Yes, support `include` parameter (recommended)
286
- B) No, flat data only
287
-
288
- **E) Custom Endpoint Example**
289
- 10. If you want to customize an endpoint (e.g., add special logic, validations, or unique parameters), describe the case here:
290
-
291
- - [Brief description, example endpoint, parameters, special logic]
292
- ---
293
- The AI will use these conventions to automatically document all CRUD endpoints for each entity in api.md. If you need additional or custom endpoints, you can add them manually later.
294
- ````
295
-
296
- **3.5.1 Error Codes Catalog**
297
-
298
- ```
299
- Will you use standardized error codes?
300
-
301
- A) ⭐ Yes - Domain-specific error codes (recommended for APIs)
302
- B) No - HTTP status codes only
303
-
304
- If yes, define your error code format:
305
-
306
- Format:
307
- A) ⭐ Prefixed by domain: USER_001, ORDER_003, PAYMENT_005
308
- B) Numeric ranges: 1000-1999 (Users), 2000-2999 (Orders)
309
- C) Other: __
310
-
311
- Define your error codes:
312
-
313
- | Code | HTTP | Message | Resolution |
314
- |---------------|------|--------------------------------|-------------------------------|
315
- | USER_001 | 404 | User not found | Verify user ID exists |
316
- | USER_002 | 409 | Email already registered | Use different email or login |
317
- | USER_003 | 400 | Invalid email format | Provide valid email |
318
- | AUTH_001 | 401 | Invalid credentials | Check username/password |
319
- | AUTH_002 | 401 | Token expired | Refresh or re-authenticate |
320
- | AUTH_003 | 403 | Insufficient permissions | Contact administrator |
321
- | ORDER_001 | 400 | Empty cart | Add items before checkout |
322
- | ORDER_002 | 400 | Insufficient stock | Reduce quantity or wait |
323
- | PAYMENT_001 | 402 | Payment declined | Try different payment method |
324
- | VALIDATION_001| 400 | Required field missing | Provide all required fields |
325
-
326
- Your error codes:
327
- | Code | HTTP | Message | Resolution |
328
- |------|------|---------|------------|
329
- | | | | |
330
- ```
331
-
332
- **3.5.2 Input Validation Rules Catalog**
333
-
334
- ```
335
- Define validation rules for common fields across your API:
336
-
337
- | Field Type | Rules | Error Message |
338
- |----------------|------------------------------------------|----------------------------------|
339
- | email | valid format, max 255, lowercase | Invalid email format |
340
- | password | min 8, uppercase, lowercase, number | Password too weak |
341
- | username | min 3, max 30, alphanumeric, no spaces | Invalid username format |
342
- | phone | E.164 format or local format | Invalid phone number |
343
- | url | valid URL, https only (optional) | Invalid URL format |
344
- | date | ISO 8601 format, not in past (optional) | Invalid date format |
345
- | price/amount | positive, max 2 decimals | Invalid amount |
346
- | quantity | positive integer, max 9999 | Invalid quantity |
347
- | id (UUID) | valid UUID v4 format | Invalid ID format |
348
- | slug | lowercase, hyphens only, max 100 | Invalid slug format |
349
-
350
- Entity-specific validation (example):
351
-
352
- User:
353
- - firstName: required, min 2, max 50, letters only
354
- - lastName: required, min 2, max 50, letters only
355
- - birthDate: valid date, must be 18+ years ago
356
-
357
- Product:
358
- - name: required, min 3, max 100
359
- - price: required, positive, max 999999.99
360
- - sku: required, unique, uppercase, alphanumeric
361
-
362
- Your entity validations:
363
-
364
- Entity: __
365
- - field: [rules]
366
-
367
- Entity: __
368
- - field: [rules]
369
- ```
370
-
371
- **3.5.3 Idempotency Strategy**
372
-
373
- ```
374
- How will you handle duplicate requests (critical for payments, orders)?
375
-
376
- A) ⭐ Idempotency keys - Client sends unique key per request
377
- B) Natural idempotency - Use unique constraints (email, etc.)
378
- C) Not needed - Operations are naturally idempotent
379
- D) Combination of A + B
380
-
381
- If using idempotency keys (A):
382
-
383
- Header name:
384
- A) ⭐ Idempotency-Key (standard)
385
- B) X-Request-ID
386
- C) Custom: __
387
-
388
- Key storage:
389
- A) ⭐ Redis with TTL (recommended)
390
- B) Database table
391
-
392
- TTL: __ hours (recommended: 24)
393
-
394
- Which endpoints require idempotency?
395
- - POST /orders βœ…
396
- - POST /payments βœ…
397
- - POST /users βœ…
398
- - [Your endpoints]: __
399
- ```
400
-
401
- **3.6 Key Dependencies**
402
-
403
- ```
404
- What major libraries/tools will you use?
405
-
406
- ORM/Database:
407
- A) TypeORM (Node.js)
408
- B) Prisma (Node.js) ⭐
409
- C) Sequelize (Node.js)
410
- D) SQLAlchemy (Python)
411
- E) Hibernate (Java)
412
- F) Other: __
413
-
414
- Validation:
415
- A) class-validator + class-transformer (NestJS) ⭐
416
- B) Joi (Node.js)
417
- C) Zod (TypeScript)
418
- D) Pydantic (Python) ⭐
419
- E) Yup (JavaScript)
420
-
421
- Authentication:
422
- A) Passport.js (Node.js) πŸ”₯
423
- B) JWT libraries
424
- C) Auth0/Clerk/Supabase Auth (External service)
425
- D) Framework built-in
426
-
427
- Other critical libraries:
428
- -
429
- ```
430
-
431
- **3.7 Caching Strategy**
432
-
433
- ```
434
- Will you use caching?
435
-
436
- A) ⭐ Redis - Recommended (in-memory, fast, pub/sub)
437
- B) Memcached - Simple key-value cache
438
- C) Application-level - In-process caching (node-cache, etc.)
439
- D) Database query cache
440
- E) No caching (simple projects)
441
-
442
- If using cache:
443
- - What will be cached? (sessions, query results, computed data)
444
- - Cache invalidation strategy? (TTL, manual, event-driven)
445
- ```
446
-
447
- **3.8 Background Jobs**
448
-
449
- ```
450
- Do you need background/async jobs?
451
-
452
- A) ⭐ Yes - Using queue system (Bull, BullMQ, Celery, Sidekiq)
453
- B) Yes - Using cron jobs
454
- C) Yes - Using serverless functions (Lambda, Cloud Functions)
455
- D) No - All operations are synchronous
456
-
457
- If yes, common job types:
458
- - Email sending
459
- - Report generation
460
- - Data processing
461
- - External API calls
462
- - Cleanup tasks
463
- - Other: __
464
- ```
465
-
466
- **3.9 File Storage**
467
-
468
- ```
469
- How will you handle file uploads?
470
-
471
- A) ⭐ Cloud storage - S3, Google Cloud Storage, Azure Blob ⭐
472
- B) Local filesystem - Storing on server disk
473
- C) Database - Storing binary data in DB (not recommended for large files)
474
- D) CDN - Cloudflare, CloudFront, etc.
475
- E) Not needed
476
-
477
- If storing files:
478
- - File types: [images, PDFs, videos, documents, etc.]
479
- - Max file size: __ MB
480
- - Storage quota estimate: __ GB
481
- ```
482
-
483
- **3.10 API Gateway**
484
-
485
- ```
486
- Will you use an API Gateway?
487
-
488
- A) ⭐ Yes - Using API Gateway (Kong, AWS API Gateway, Azure API Management, etc.)
489
- B) No - Direct API access
490
-
491
- If yes:
492
- - Gateway: __
493
- - Purpose: [Rate limiting, Authentication, Request routing, Load balancing, etc.]
494
- - Routes: __
495
- ```
496
-
497
- **3.11 Real-time Communication**
498
-
499
- ```
500
- Do you need real-time communication?
501
-
502
- A) ⭐ WebSockets - Bidirectional communication (chat, notifications, live updates)
503
- B) Server-Sent Events (SSE) - Server-to-client streaming (live feeds, updates)
504
- C) Both - Different use cases
505
- D) No - Standard HTTP requests only
506
-
507
- If WebSockets or SSE:
508
- - Use cases: __
509
- - Library: __
510
- - Authentication: __
511
- ```
512
-
513
- **3.12 Message Broker Details** (if using background jobs from 3.8)
514
-
515
- ```
516
- What message broker will you use?
517
-
518
- A) ⭐ RabbitMQ - Popular, reliable, feature-rich
519
- B) πŸ”₯ Apache Kafka - High throughput, event streaming
520
- C) ⚑ AWS SQS - Managed, serverless
521
- D) Google Pub/Sub - Managed, scalable
522
- E) Redis Streams - Simple, fast
523
- F) Other: __
524
-
525
- Message patterns:
526
- A) ⭐ Queue - Point-to-point messaging
527
- B) Pub/Sub - Publish-subscribe pattern
528
- C) Both - Different use cases
529
-
530
- Delivery guarantees:
531
- A) ⭐ At-least-once - Messages delivered at least once (may have duplicates)
532
- B) Exactly-once - Messages delivered exactly once (more complex)
533
- C) At-most-once - Messages may be lost (rarely used)
534
-
535
- Dead letter queue:
536
- A) ⭐ Yes - Handle failed messages
537
- B) No
538
- ```
539
-
540
- **3.13 API Documentation**
541
-
542
- ```
543
- How will you document your API?
544
-
545
- A) ⭐ Swagger/OpenAPI - Auto-generated from code (code-first)
546
- - Tool: [@nestjs/swagger, FastAPI docs, Swagger UI, etc.]
547
- - Endpoint: /api-docs or /swagger
548
-
549
- B) πŸ“ OpenAPI Spec - Write spec first, generate code (design-first)
550
- - File: openapi.yaml
551
- - Tool: [OpenAPI Generator, etc.]
552
-
553
- C) Manual - Markdown documentation
554
- - Not recommended (hard to keep in sync)
555
-
556
- Your choice: __
557
- ```
558
-
559
- **3.14 Service Mesh** (if microservices architecture)
560
-
561
- ```
562
- Will you use a Service Mesh?
563
-
564
- A) ⭐ Yes - Using Service Mesh (Istio, Linkerd, Consul Connect)
565
- B) No - Not needed (monolith or simple microservices)
566
-
567
- If yes:
568
- - Mesh: __
569
- - Features: [Service discovery, Load balancing, mTLS, Observability]
570
- ```
571
-
572
- **3.15 External Integrations**
573
-
574
- ```
575
- Will you integrate with external services?
576
-
577
- Select all that apply:
578
-
579
- πŸ’³ Payment Providers:
580
- A) Stripe - Credit cards, subscriptions ⭐
581
- B) PayPal - Popular payment method
582
- C) Square - POS and online payments
583
- D) Mercado Pago - Latin America
584
- E) Other: __
585
-
586
- β†’ Your selection (e.g., A): __
587
-
588
- πŸ“§ Email Services:
589
- A) AWS SES - Cost-effective, scalable ⭐
590
- B) SendGrid - Feature-rich, analytics
591
- C) Mailgun - Developer-friendly
592
- D) Postmark - Transactional focus
593
- E) Resend - Modern, simple API ⚑
594
- F) Other: __
595
-
596
- β†’ Your selection (e.g., A, B): __
597
-
598
- πŸ“± SMS/Messaging:
599
- C) MessageBird - Multi-channel
600
- D) Other: __
601
-
602
- β†’ Your selection (e.g., A): __
603
-
604
- ☁️ Cloud Storage:
605
-
606
- D) Cloudflare R2 - S3-compatible, no egress fees ⚑
607
- E) Other: __
608
-
609
- β†’ Your selection (e.g., A): __
610
-
611
- πŸ“Š Analytics: Storage
612
- D) Cloudflare R2 - S3-compatible, no egress fees ⚑
613
- E) Other: __
614
-
615
- πŸ“Š Analytics:
616
- E) Amplitude - Behavioral analytics
617
- F) Other: __
618
-
619
- β†’ Your selection (e.g., B, C): __
620
-
621
- πŸ” Monitoring/Error Tracking:ytics ⚑
622
- E) Amplitude - Behavioral analytics
623
- D) LogRocket - Session replay
624
- E) Other: __
625
-
626
- β†’ Your selection (e.g., A): __
627
-
628
- πŸ—ΊοΈ Maps/Location:tracking ⭐
629
- B) Datadog - Full observability πŸ†
630
- C) New Relic - APM
631
- C) OpenStreetMap
632
- D) Other: __
633
-
634
- β†’ Your selection (e.g., A): __
635
-
636
- πŸ” Authentication:
637
- A) Google Maps API
638
- D) Firebase Auth - Google ecosystem
639
- E) Other: __
640
-
641
- β†’ Your selection (e.g., A, B): __
642
-
643
- πŸ€– AI/ML Services:
644
- πŸ” Authentication:
645
- D) AWS Bedrock - Managed AI
646
- E) Other: __
647
-
648
- β†’ Your selection (e.g., A): __
649
-
650
- πŸ“ž Communication:- Google ecosystem
651
- E) Other: __
652
-
653
- C) Webhooks - Custom integrations
654
- D) Other: __
655
-
656
- β†’ Your selection (e.g., A, B): __
657
-
658
- πŸ”„ Other Integrations:timodal AI
659
- D) AWS Bedrock - Managed AI
660
- D) Accounting (QuickBooks, Xero)
661
- E) Other: __
662
-
663
- β†’ Your selection (e.g., A, B, C): __
664
- ---
665
- For each selected, briefly describe the use case:
666
- D) Other: __
667
-
668
- πŸ”„ Other Integrations:
669
- A) GitHub/GitLab API
670
- B) Calendar (Google/Outlook)
671
- C) CRM (Salesforce, HubSpot)
672
- D) Accounting (QuickBooks, Xero)
673
- E) Other: __
674
- ---
675
- For each selected, briefly describe the use case:
676
-
677
- Example:
678
- - Stripe: Process credit card payments for subscriptions
679
- - AWS SES: Send transactional emails (order confirmations, password resets)
680
- - Sentry: Track and alert on production errors
681
- ```
682
-
683
- ### Phase 3 Output
684
-
685
- ```
686
- πŸ“‹ PHASE 3 SUMMARY:
687
-
688
- Framework: [name + version]
689
- Language: [name + version]
690
- Architecture: [pattern]
691
- API Style: [REST/GraphQL/gRPC]
692
- API Versioning: [strategy]
693
- API Conventions: [auth, pagination, error format, expansions]
694
- API Gateway: [yes/no + tool + purpose]
695
- Real-time Communication: [WebSockets/SSE/none + use cases]
696
- Message Broker: [tool + patterns + delivery guarantees]
697
- API Documentation: [Swagger/OpenAPI/manual + strategy]
698
- Service Mesh: [yes/no + tool if applicable]
699
- Database: [from Phase 2]
700
- ORM: [name]
701
- Validation: [library]
702
- Auth: [method]
703
- Caching: [strategy]
704
- Background Jobs: [yes/no + method]
705
- File Storage: [strategy]
706
- External Services: [list with use cases]
707
-
708
- Is this correct? (Yes/No)
709
- ```
710
-
711
- ---
712
-
713
- ### πŸ“„ Generate Phase 3 Documents
714
-
715
- **Before starting generation:**
716
-
717
- ```
718
- πŸ“– Loading context from previous phases...
719
- βœ… Re-reading project-brief.md
720
- βœ… Re-reading docs/data-model.md
721
- ```
722
-
723
- **Generate documents automatically:**
724
-
725
- **1. `docs/architecture.md`**
726
-
727
- - Use template: `.ai-flow/templates/docs/architecture.template.md`
728
- - Fill with system architecture, patterns, tech stack
729
- - Include architecture diagram (mermaid format)
730
- - Write to: `docs/architecture.md`
731
-
732
- **2. `ai-instructions.md`**
733
-
734
- - Use template: `.ai-flow/templates/ai-instructions.template.md`
735
- - Fill with tech stack, framework, language, key dependencies
736
- - Include NEVER/ALWAYS rules specific to chosen stack
737
- - Generate idiomatic code examples for Controller, Service, Repository, DTO and Module placeholders, strictly following the selected Architecture Pattern (e.g., if Hexagonal, show Ports & Adapters)
738
- - Write to: `ai-instructions.md`
739
-
740
- ```
741
- βœ… Generated: docs/architecture.md
742
- βœ… Generated: ai-instructions.md
743
-
744
- Documents have been created with all Phase 3 information.
745
-
746
- πŸ“ Would you like to make any corrections before continuing?
747
-
748
- β†’ If yes: Edit the files and type "ready" when done. I'll re-read them.
749
- β†’ If no: Type "continue" to proceed to Phase 4.
750
- ```
751
-
752
- **If user edits files:**
753
- Execute `read_file()` for both documents to refresh context before continuing.
754
-
755
- ---
756
-
757
- **Proceed to Phase 4 only after documents are validated.**
758
-
759
- > ⚠️ **CRITICAL:** DO NOT generate README.md in this phase. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
760
-
761
- ---
762
-
763
- ## πŸ“ Generated Documents
764
-
765
- After Phase 3, generate/update:
766
- - `docs/architecture.md` - Technical stack and patterns
767
- - `ai-instructions.md` - Instructions for AI agents
768
-
769
- ---
770
-
771
- **Next Phase:** Phase 4 - Security & Authentication (15-20 min)
772
-
773
- Read: `.ai-flow/prompts/backend/flow-build-phase-4.md`
774
-
775
- ---
776
-
777
- **Last Updated:** 2025-12-20
778
- **Version:** 2.1.8
779
-
780
- ---
781
-
782
- ## PHASE 4: Security & Authentication (15-20 min)
1
+ ## PHASE 3: System Architecture (15-20 min)
2
+
3
+ > **Order for this phase:** 3.1 β†’ 3.2 β†’ 3.3 β†’ 3.4 β†’ 3.5 β†’ 3.6 β†’ 3.7 β†’ 3.8 β†’ 3.9 β†’ 3.10 β†’ 3.11 β†’ 3.12
4
+
5
+ > **πŸ“Œ Scope-based behavior:**
6
+ >
7
+ > - **MVP:** Ask 3.1-3.6 (tech stack essentials) and 3.12 (API structure), skip 3.7-3.11 (advanced features), mark as "TBD"
8
+ > - **Production-Ready:** Ask all questions 3.1-3.12
9
+ > - **Enterprise:** Ask all questions 3.1-3.12 with emphasis on scalability and integrations
10
+
11
+ > **πŸ“Œ Note:** If Phase 0 detected framework/language/dependencies, those will be pre-filled. Review and confirm.
12
+
13
+ ### Objective
14
+
15
+ Define the technical stack, architecture patterns, and system design.
16
+
17
+ > **Note:** At the end of this phase, the AI will automatically generate a system architecture diagram in mermaid format, based on your answers. This diagram will be included in the docs/architecture.md document.
18
+
19
+ ---
20
+
21
+ ## πŸ” Pre-Flight Check (Smart Skip Logic)
22
+
23
+ > πŸ“Ž **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
24
+
25
+ **Execute Pre-Flight Check for Phase 3:**
26
+
27
+ - **Target File**: `docs/architecture.md`
28
+ - **Phase Name**: "SYSTEM ARCHITECTURE"
29
+ - **Key Items**: Framework, architecture pattern, API style, database, caching, background jobs, integrations
30
+ - **Typical Gaps**: API versioning, rate limiting, caching strategy
31
+
32
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
33
+
34
+ ---
35
+
36
+ ## Phase 3 Questions (Full Mode)
37
+
38
+ ---
39
+
40
+ #### 🎨 MERMAID ARCHITECTURE DIAGRAM FORMAT - CRITICAL
41
+
42
+ > πŸ“Ž **Reference:** See [prompts/shared/mermaid-guidelines.md](../../.ai-flow/prompts/shared/mermaid-guidelines.md) for architecture diagram syntax, node shapes, and styling.
43
+
44
+ **Example Architecture Diagram:**
45
+
46
+ **Common Architecture Patterns:**
47
+
48
+ ```mermaid
49
+ graph TD
50
+ subgraph "Client Layer"
51
+ Web[Web App]
52
+ Mobile[Mobile App]
53
+ end
54
+
55
+ subgraph "API Layer"
56
+ Gateway[API Gateway]
57
+ Auth[Auth Service]
58
+ end
59
+
60
+ subgraph "Business Layer"
61
+ Service1[User Service]
62
+ Service2[Order Service]
63
+ Service3[Payment Service]
64
+ end
65
+
66
+ subgraph "Data Layer"
67
+ DB[(PostgreSQL)]
68
+ Cache[(Redis)]
69
+ end
70
+
71
+ Web --> Gateway
72
+ Mobile --> Gateway
73
+ Gateway --> Auth
74
+ Gateway --> Service1
75
+ Gateway --> Service2
76
+ Service2 --> Service3
77
+ Service1 --> DB
78
+ Service2 --> DB
79
+ Service3 --> DB
80
+ Service1 --> Cache
81
+ Service2 --> Cache
82
+ ```
83
+
84
+ **Best Practices:**
85
+
86
+ - Group related components using `subgraph`
87
+ - Show external services (Email, SMS, Payment gateways)
88
+ - Include monitoring and logging components
89
+ - Label protocols on connections (HTTPS, gRPC, WebSocket)
90
+ - Use consistent naming conventions
91
+
92
+ ## **Validation:** Preview at https://mermaid.live/ before committing
93
+
94
+ **3.1 Backend Framework**
95
+
96
+ ```
97
+ [If detected from Phase 0, show:]
98
+ βœ… Framework Detected: [NestJS/FastAPI/Spring Boot/etc.]
99
+ βœ… Language: [TypeScript 5.3/Python 3.11/Java 21/etc.]
100
+ βœ… Runtime: [Node 20/Python 3.11/JVM 21/etc.]
101
+
102
+ Is this correct? (Y/N)
103
+ If no, please specify the correct framework and language.
104
+
105
+ [If NOT detected, ask:]
106
+ Which backend framework will you use?
107
+
108
+ Node.js (JavaScript):
109
+ A) πŸ”₯ Express.js - Popular (minimal, flexible, lightweight)
110
+ B) Hapi.js - Enterprise (configuration-driven)
111
+
112
+ TypeScript (Node.js):
113
+ C) ⭐ NestJS - Recommended (structured, enterprise-ready, decorators)
114
+ D) ⚑ Fastify - Modern (high performance, schema validation)
115
+
116
+ Python:
117
+ E) ⭐ FastAPI - Recommended (modern, fast, auto-docs)
118
+ F) πŸ”₯ Django - Popular (batteries included, admin panel)
119
+ G) Flask - Minimal (micro-framework, flexible)
120
+
121
+ Java:
122
+ H) πŸ† Spring Boot - Enterprise standard
123
+ I) Quarkus - Modern (cloud-native, fast startup)
124
+
125
+ Go:
126
+ J) ⚑ Gin - Popular (fast, minimalist)
127
+ K) Echo - Feature-rich (middleware, routing)
128
+ L) Fiber - Express-like (high performance)
129
+
130
+ Rust:
131
+ M) ⚑ Actix-web - High performance (async, type-safe)
132
+ N) Rocket - Developer-friendly (macros, type-safe)
133
+ O) Axum - Modern (tokio-based, ergonomic)
134
+
135
+ Kotlin:
136
+ P) Ktor - Native Kotlin (coroutines, DSL)
137
+ Q) Spring Boot - Java interop (Kotlin support)
138
+
139
+ Other:
140
+ R) Ruby (Rails)
141
+ S) PHP (Laravel)
142
+ T) C# (.NET Core)
143
+
144
+ Your choice: __
145
+ Why?
146
+ ```
147
+
148
+ **3.2 Language & Version**
149
+
150
+ ```
151
+ Primary programming language and version:
152
+
153
+ Language: **
154
+ Version: ** (e.g., Node 20, Python 3.11, Java 21)
155
+
156
+ Type system:
157
+ A) ⭐ Strongly typed - TypeScript, Java, Go (Recommended for large projects)
158
+ B) Dynamically typed - JavaScript, Python, Ruby
159
+ C) Gradually typed - Python with type hints
160
+
161
+ Package Manager:
162
+ A) ⭐ npm - Standard, comes with Node
163
+ B) πŸ”₯ pnpm - Fast, disk efficient
164
+ C) ⚑ yarn - Popular alternative
165
+ D) πŸš€ bun - Ultra fast (if using Bun runtime)
166
+ E) 🐍 pip/poetry (Python)
167
+ F) β˜• Maven/Gradle (Java)
168
+ ```
169
+
170
+ **3.3 Architecture Pattern**
171
+
172
+ ```
173
+ What architecture pattern will you follow?
174
+
175
+ A) ⭐ Layered Architecture (Recommended for most projects)
176
+ - Presentation β†’ Business Logic β†’ Data Access
177
+ - Easy to understand and maintain
178
+
179
+ B) πŸ† Hexagonal/Clean Architecture (Enterprise)
180
+ - Core domain isolated from infrastructure
181
+ - Highly testable and flexible
182
+
183
+ C) πŸ”₯ MVC (Popular, traditional)
184
+ - Model-View-Controller separation
185
+ - Good for traditional web apps
186
+
187
+ D) πŸ“¦ Modular Monolith (Modern, scalable)
188
+ - Single deployment with independent modules
189
+ - Easier than microservices, more structured than monolith
190
+ - Good middle ground for growing applications
191
+
192
+ E) ⚑ Microservices (Modern, complex)
193
+ - Multiple independent services
194
+ - Best for large-scale distributed systems
195
+
196
+ F) Other: __
197
+
198
+ Your choice: __
199
+ Why this pattern?
200
+ ```
201
+
202
+ **3.4 API Style**
203
+
204
+ ```
205
+ What API style will you expose?
206
+
207
+ A) ⭐ REST API - Recommended (HTTP/JSON, standard, well-understood)
208
+ B) πŸ”₯ GraphQL - Popular (flexible queries, single endpoint)
209
+ C) ⚑ gRPC - Modern (high performance, protobuf, microservices)
210
+ D) Mixed - REST + GraphQL or REST + gRPC
211
+
212
+ Your choice: __
213
+
214
+ API versioning strategy:
215
+ A) URL versioning (/v1/users, /v2/users)
216
+ B) Header versioning (Accept: application/vnd.api.v1+json)
217
+ C) No versioning yet (will add when needed)
218
+ ```
219
+
220
+ **3.5 API Reference (Automated)**
221
+
222
+ ````
223
+ The AI will automatically generate standard CRUD endpoints for each entity defined in Phase 2.
224
+
225
+ Please answer the following questions to define the global API conventions (these will apply to all endpoints unless otherwise specified):
226
+
227
+ **A) Authentication and Access Control**
228
+ 1. Do all CRUD endpoints require authentication?
229
+ A) ⭐ Yes, all endpoints require authentication (recommended)
230
+ B) Only some (specify which ones)
231
+ C) No authentication required
232
+
233
+ 2. Which roles can access each CRUD operation?
234
+ - GET (list): [admin, manager, user]
235
+ - GET (detail): [admin, manager, user]
236
+ - POST (create): [admin, manager, user]
237
+ - PUT (update): [admin, manager]
238
+ - DELETE (delete): [admin]
239
+ (Standard example: admin, manager, user. Adjust as needed.)
240
+
241
+ **B) Listing and Filter Conventions**
242
+ 3. Which pagination scheme do you prefer?
243
+ A) ⭐ offset/limit (recommended)
244
+ B) cursor-based
245
+ C) No pagination
246
+
247
+ 4. Which filter and sorting fields will be supported by default?
248
+ - Filters: [id, name, date, etc.]
249
+ - Sorting: [field, asc/desc]
250
+
251
+ 5. How will filters be passed for GET list endpoints?
252
+ A) ⭐ Query parameters (recommended for simple filters)
253
+ Example: GET /users?name=John&status=active&page=1&limit=10
254
+
255
+ B) POST /search endpoint with body (for complex filters)
256
+ Example: POST /users/search
257
+ Body: { "filters": { "name": "John", "status": "active" }, "page": 1, "limit": 10 }
258
+
259
+ C) Both (query params for simple, POST /search for complex)
260
+
261
+ 6. For POST/PUT/PATCH endpoints, will you use DTOs for request validation?
262
+ A) ⭐ Yes, strict DTOs with validation (recommended)
263
+ B) Accept raw JSON without strict schema
264
+
265
+ If yes, validation library: [from Phase 3.6 - class-validator, Zod, Pydantic, Joi]
266
+
267
+ **C) Error and Response Structure**
268
+ 7. What error response format will be used?
269
+ A) Standard JSON:
270
+ ```json
271
+ {
272
+ "error": "Descriptive message",
273
+ "code": 400,
274
+ "details": {}
275
+ }
276
+ ```
277
+
278
+ B) Other (specify)
279
+
280
+ 8. Which fields will be included in the default successful response?
281
+ - data, meta (pagination), links, etc.
282
+
283
+ **D) Relationships and Expansions**
284
+ 9. Allow expanding relationships (include/expand)?
285
+ A) ⭐ Yes, support `include` parameter (recommended)
286
+ B) No, flat data only
287
+
288
+ **E) Custom Endpoint Example**
289
+ 10. If you want to customize an endpoint (e.g., add special logic, validations, or unique parameters), describe the case here:
290
+
291
+ - [Brief description, example endpoint, parameters, special logic]
292
+ ---
293
+ The AI will use these conventions to automatically document all CRUD endpoints for each entity in api.md. If you need additional or custom endpoints, you can add them manually later.
294
+ ````
295
+
296
+ **3.5.1 Error Codes Catalog**
297
+
298
+ ```
299
+ Will you use standardized error codes?
300
+
301
+ A) ⭐ Yes - Domain-specific error codes (recommended for APIs)
302
+ B) No - HTTP status codes only
303
+
304
+ If yes, define your error code format:
305
+
306
+ Format:
307
+ A) ⭐ Prefixed by domain: USER_001, ORDER_003, PAYMENT_005
308
+ B) Numeric ranges: 1000-1999 (Users), 2000-2999 (Orders)
309
+ C) Other: __
310
+
311
+ Define your error codes:
312
+
313
+ | Code | HTTP | Message | Resolution |
314
+ |---------------|------|--------------------------------|-------------------------------|
315
+ | USER_001 | 404 | User not found | Verify user ID exists |
316
+ | USER_002 | 409 | Email already registered | Use different email or login |
317
+ | USER_003 | 400 | Invalid email format | Provide valid email |
318
+ | AUTH_001 | 401 | Invalid credentials | Check username/password |
319
+ | AUTH_002 | 401 | Token expired | Refresh or re-authenticate |
320
+ | AUTH_003 | 403 | Insufficient permissions | Contact administrator |
321
+ | ORDER_001 | 400 | Empty cart | Add items before checkout |
322
+ | ORDER_002 | 400 | Insufficient stock | Reduce quantity or wait |
323
+ | PAYMENT_001 | 402 | Payment declined | Try different payment method |
324
+ | VALIDATION_001| 400 | Required field missing | Provide all required fields |
325
+
326
+ Your error codes:
327
+ | Code | HTTP | Message | Resolution |
328
+ |------|------|---------|------------|
329
+ | | | | |
330
+ ```
331
+
332
+ **3.5.2 Input Validation Rules Catalog**
333
+
334
+ ```
335
+ Define validation rules for common fields across your API:
336
+
337
+ | Field Type | Rules | Error Message |
338
+ |----------------|------------------------------------------|----------------------------------|
339
+ | email | valid format, max 255, lowercase | Invalid email format |
340
+ | password | min 8, uppercase, lowercase, number | Password too weak |
341
+ | username | min 3, max 30, alphanumeric, no spaces | Invalid username format |
342
+ | phone | E.164 format or local format | Invalid phone number |
343
+ | url | valid URL, https only (optional) | Invalid URL format |
344
+ | date | ISO 8601 format, not in past (optional) | Invalid date format |
345
+ | price/amount | positive, max 2 decimals | Invalid amount |
346
+ | quantity | positive integer, max 9999 | Invalid quantity |
347
+ | id (UUID) | valid UUID v4 format | Invalid ID format |
348
+ | slug | lowercase, hyphens only, max 100 | Invalid slug format |
349
+
350
+ Entity-specific validation (example):
351
+
352
+ User:
353
+ - firstName: required, min 2, max 50, letters only
354
+ - lastName: required, min 2, max 50, letters only
355
+ - birthDate: valid date, must be 18+ years ago
356
+
357
+ Product:
358
+ - name: required, min 3, max 100
359
+ - price: required, positive, max 999999.99
360
+ - sku: required, unique, uppercase, alphanumeric
361
+
362
+ Your entity validations:
363
+
364
+ Entity: __
365
+ - field: [rules]
366
+
367
+ Entity: __
368
+ - field: [rules]
369
+ ```
370
+
371
+ **3.5.3 Idempotency Strategy**
372
+
373
+ ```
374
+ How will you handle duplicate requests (critical for payments, orders)?
375
+
376
+ A) ⭐ Idempotency keys - Client sends unique key per request
377
+ B) Natural idempotency - Use unique constraints (email, etc.)
378
+ C) Not needed - Operations are naturally idempotent
379
+ D) Combination of A + B
380
+
381
+ If using idempotency keys (A):
382
+
383
+ Header name:
384
+ A) ⭐ Idempotency-Key (standard)
385
+ B) X-Request-ID
386
+ C) Custom: __
387
+
388
+ Key storage:
389
+ A) ⭐ Redis with TTL (recommended)
390
+ B) Database table
391
+
392
+ TTL: __ hours (recommended: 24)
393
+
394
+ Which endpoints require idempotency?
395
+ - POST /orders βœ…
396
+ - POST /payments βœ…
397
+ - POST /users βœ…
398
+ - [Your endpoints]: __
399
+ ```
400
+
401
+ **3.6 Key Dependencies**
402
+
403
+ ```
404
+ What major libraries/tools will you use?
405
+
406
+ ORM/Database:
407
+ A) TypeORM (Node.js)
408
+ B) Prisma (Node.js) ⭐
409
+ C) Sequelize (Node.js)
410
+ D) SQLAlchemy (Python)
411
+ E) Hibernate (Java)
412
+ F) Other: __
413
+
414
+ Validation:
415
+ A) class-validator + class-transformer (NestJS) ⭐
416
+ B) Joi (Node.js)
417
+ C) Zod (TypeScript)
418
+ D) Pydantic (Python) ⭐
419
+ E) Yup (JavaScript)
420
+
421
+ Authentication:
422
+ A) Passport.js (Node.js) πŸ”₯
423
+ B) JWT libraries
424
+ C) Auth0/Clerk/Supabase Auth (External service)
425
+ D) Framework built-in
426
+
427
+ Other critical libraries:
428
+ -
429
+ ```
430
+
431
+ **3.7 Caching Strategy**
432
+
433
+ ```
434
+ Will you use caching?
435
+
436
+ A) ⭐ Redis - Recommended (in-memory, fast, pub/sub)
437
+ B) Memcached - Simple key-value cache
438
+ C) Application-level - In-process caching (node-cache, etc.)
439
+ D) Database query cache
440
+ E) No caching (simple projects)
441
+
442
+ If using cache:
443
+ - What will be cached? (sessions, query results, computed data)
444
+ - Cache invalidation strategy? (TTL, manual, event-driven)
445
+ ```
446
+
447
+ **3.8 Background Jobs**
448
+
449
+ ```
450
+ Do you need background/async jobs?
451
+
452
+ A) ⭐ Yes - Using queue system (Bull, BullMQ, Celery, Sidekiq)
453
+ B) Yes - Using cron jobs
454
+ C) Yes - Using serverless functions (Lambda, Cloud Functions)
455
+ D) No - All operations are synchronous
456
+
457
+ If yes, common job types:
458
+ - Email sending
459
+ - Report generation
460
+ - Data processing
461
+ - External API calls
462
+ - Cleanup tasks
463
+ - Other: __
464
+ ```
465
+
466
+ **3.9 File Storage**
467
+
468
+ ```
469
+ How will you handle file uploads?
470
+
471
+ A) ⭐ Cloud storage - S3, Google Cloud Storage, Azure Blob ⭐
472
+ B) Local filesystem - Storing on server disk
473
+ C) Database - Storing binary data in DB (not recommended for large files)
474
+ D) CDN - Cloudflare, CloudFront, etc.
475
+ E) Not needed
476
+
477
+ If storing files:
478
+ - File types: [images, PDFs, videos, documents, etc.]
479
+ - Max file size: __ MB
480
+ - Storage quota estimate: __ GB
481
+ ```
482
+
483
+ **3.10 API Gateway**
484
+
485
+ ```
486
+ Will you use an API Gateway?
487
+
488
+ A) ⭐ Yes - Using API Gateway (Kong, AWS API Gateway, Azure API Management, etc.)
489
+ B) No - Direct API access
490
+
491
+ If yes:
492
+ - Gateway: __
493
+ - Purpose: [Rate limiting, Authentication, Request routing, Load balancing, etc.]
494
+ - Routes: __
495
+ ```
496
+
497
+ **3.11 Real-time Communication**
498
+
499
+ ```
500
+ Do you need real-time communication?
501
+
502
+ A) ⭐ WebSockets - Bidirectional communication (chat, notifications, live updates)
503
+ B) Server-Sent Events (SSE) - Server-to-client streaming (live feeds, updates)
504
+ C) Both - Different use cases
505
+ D) No - Standard HTTP requests only
506
+
507
+ If WebSockets or SSE:
508
+ - Use cases: __
509
+ - Library: __
510
+ - Authentication: __
511
+ ```
512
+
513
+ **3.12 Message Broker Details** (if using background jobs from 3.8)
514
+
515
+ ```
516
+ What message broker will you use?
517
+
518
+ A) ⭐ RabbitMQ - Popular, reliable, feature-rich
519
+ B) πŸ”₯ Apache Kafka - High throughput, event streaming
520
+ C) ⚑ AWS SQS - Managed, serverless
521
+ D) Google Pub/Sub - Managed, scalable
522
+ E) Redis Streams - Simple, fast
523
+ F) Other: __
524
+
525
+ Message patterns:
526
+ A) ⭐ Queue - Point-to-point messaging
527
+ B) Pub/Sub - Publish-subscribe pattern
528
+ C) Both - Different use cases
529
+
530
+ Delivery guarantees:
531
+ A) ⭐ At-least-once - Messages delivered at least once (may have duplicates)
532
+ B) Exactly-once - Messages delivered exactly once (more complex)
533
+ C) At-most-once - Messages may be lost (rarely used)
534
+
535
+ Dead letter queue:
536
+ A) ⭐ Yes - Handle failed messages
537
+ B) No
538
+ ```
539
+
540
+ **3.13 API Documentation**
541
+
542
+ ```
543
+ How will you document your API?
544
+
545
+ A) ⭐ Swagger/OpenAPI - Auto-generated from code (code-first)
546
+ - Tool: [@nestjs/swagger, FastAPI docs, Swagger UI, etc.]
547
+ - Endpoint: /api-docs or /swagger
548
+
549
+ B) πŸ“ OpenAPI Spec - Write spec first, generate code (design-first)
550
+ - File: openapi.yaml
551
+ - Tool: [OpenAPI Generator, etc.]
552
+
553
+ C) Manual - Markdown documentation
554
+ - Not recommended (hard to keep in sync)
555
+
556
+ Your choice: __
557
+ ```
558
+
559
+ **3.14 Service Mesh** (if microservices architecture)
560
+
561
+ ```
562
+ Will you use a Service Mesh?
563
+
564
+ A) ⭐ Yes - Using Service Mesh (Istio, Linkerd, Consul Connect)
565
+ B) No - Not needed (monolith or simple microservices)
566
+
567
+ If yes:
568
+ - Mesh: __
569
+ - Features: [Service discovery, Load balancing, mTLS, Observability]
570
+ ```
571
+
572
+ **3.15 External Integrations**
573
+
574
+ ```
575
+ Will you integrate with external services?
576
+
577
+ Select all that apply:
578
+
579
+ πŸ’³ Payment Providers:
580
+ A) Stripe - Credit cards, subscriptions ⭐
581
+ B) PayPal - Popular payment method
582
+ C) Square - POS and online payments
583
+ D) Mercado Pago - Latin America
584
+ E) Other: __
585
+
586
+ β†’ Your selection (e.g., A): __
587
+
588
+ πŸ“§ Email Services:
589
+ A) AWS SES - Cost-effective, scalable ⭐
590
+ B) SendGrid - Feature-rich, analytics
591
+ C) Mailgun - Developer-friendly
592
+ D) Postmark - Transactional focus
593
+ E) Resend - Modern, simple API ⚑
594
+ F) Other: __
595
+
596
+ β†’ Your selection (e.g., A, B): __
597
+
598
+ πŸ“± SMS/Messaging:
599
+ C) MessageBird - Multi-channel
600
+ D) Other: __
601
+
602
+ β†’ Your selection (e.g., A): __
603
+
604
+ ☁️ Cloud Storage:
605
+
606
+ D) Cloudflare R2 - S3-compatible, no egress fees ⚑
607
+ E) Other: __
608
+
609
+ β†’ Your selection (e.g., A): __
610
+
611
+ πŸ“Š Analytics: Storage
612
+ D) Cloudflare R2 - S3-compatible, no egress fees ⚑
613
+ E) Other: __
614
+
615
+ πŸ“Š Analytics:
616
+ E) Amplitude - Behavioral analytics
617
+ F) Other: __
618
+
619
+ β†’ Your selection (e.g., B, C): __
620
+
621
+ πŸ” Monitoring/Error Tracking:ytics ⚑
622
+ E) Amplitude - Behavioral analytics
623
+ D) LogRocket - Session replay
624
+ E) Other: __
625
+
626
+ β†’ Your selection (e.g., A): __
627
+
628
+ πŸ—ΊοΈ Maps/Location:tracking ⭐
629
+ B) Datadog - Full observability πŸ†
630
+ C) New Relic - APM
631
+ C) OpenStreetMap
632
+ D) Other: __
633
+
634
+ β†’ Your selection (e.g., A): __
635
+
636
+ πŸ” Authentication:
637
+ A) Google Maps API
638
+ D) Firebase Auth - Google ecosystem
639
+ E) Other: __
640
+
641
+ β†’ Your selection (e.g., A, B): __
642
+
643
+ πŸ€– AI/ML Services:
644
+ πŸ” Authentication:
645
+ D) AWS Bedrock - Managed AI
646
+ E) Other: __
647
+
648
+ β†’ Your selection (e.g., A): __
649
+
650
+ πŸ“ž Communication:- Google ecosystem
651
+ E) Other: __
652
+
653
+ C) Webhooks - Custom integrations
654
+ D) Other: __
655
+
656
+ β†’ Your selection (e.g., A, B): __
657
+
658
+ πŸ”„ Other Integrations:timodal AI
659
+ D) AWS Bedrock - Managed AI
660
+ D) Accounting (QuickBooks, Xero)
661
+ E) Other: __
662
+
663
+ β†’ Your selection (e.g., A, B, C): __
664
+ ---
665
+ For each selected, briefly describe the use case:
666
+ D) Other: __
667
+
668
+ πŸ”„ Other Integrations:
669
+ A) GitHub/GitLab API
670
+ B) Calendar (Google/Outlook)
671
+ C) CRM (Salesforce, HubSpot)
672
+ D) Accounting (QuickBooks, Xero)
673
+ E) Other: __
674
+ ---
675
+ For each selected, briefly describe the use case:
676
+
677
+ Example:
678
+ - Stripe: Process credit card payments for subscriptions
679
+ - AWS SES: Send transactional emails (order confirmations, password resets)
680
+ - Sentry: Track and alert on production errors
681
+ ```
682
+
683
+ ### Phase 3 Output
684
+
685
+ ```
686
+ πŸ“‹ PHASE 3 SUMMARY:
687
+
688
+ Framework: [name + version]
689
+ Language: [name + version]
690
+ Architecture: [pattern]
691
+ API Style: [REST/GraphQL/gRPC]
692
+ API Versioning: [strategy]
693
+ API Conventions: [auth, pagination, error format, expansions]
694
+ API Gateway: [yes/no + tool + purpose]
695
+ Real-time Communication: [WebSockets/SSE/none + use cases]
696
+ Message Broker: [tool + patterns + delivery guarantees]
697
+ API Documentation: [Swagger/OpenAPI/manual + strategy]
698
+ Service Mesh: [yes/no + tool if applicable]
699
+ Database: [from Phase 2]
700
+ ORM: [name]
701
+ Validation: [library]
702
+ Auth: [method]
703
+ Caching: [strategy]
704
+ Background Jobs: [yes/no + method]
705
+ File Storage: [strategy]
706
+ External Services: [list with use cases]
707
+
708
+ Is this correct? (Yes/No)
709
+ ```
710
+
711
+ ---
712
+
713
+ ### πŸ“„ Generate Phase 3 Documents
714
+
715
+ **Before starting generation:**
716
+
717
+ ```
718
+ πŸ“– Loading context from previous phases...
719
+ βœ… Re-reading project-brief.md
720
+ βœ… Re-reading docs/data-model.md
721
+ ```
722
+
723
+ **Generate documents automatically:**
724
+
725
+ **1. `docs/architecture.md`**
726
+
727
+ - Use template: `.ai-flow/templates/docs/architecture.template.md`
728
+ - Fill with system architecture, patterns, tech stack
729
+ - Include architecture diagram (mermaid format)
730
+ - Write to: `docs/architecture.md`
731
+
732
+ **2. `ai-instructions.md`**
733
+
734
+ - Use template: `.ai-flow/templates/ai-instructions.template.md`
735
+ - Fill with tech stack, framework, language, key dependencies
736
+ - Include NEVER/ALWAYS rules specific to chosen stack
737
+ - Generate idiomatic code examples for Controller, Service, Repository, DTO and Module placeholders, strictly following the selected Architecture Pattern (e.g., if Hexagonal, show Ports & Adapters)
738
+ - Write to: `ai-instructions.md`
739
+
740
+ ```
741
+ βœ… Generated: docs/architecture.md
742
+ βœ… Generated: ai-instructions.md
743
+
744
+ Documents have been created with all Phase 3 information.
745
+
746
+ πŸ“ Would you like to make any corrections before continuing?
747
+
748
+ β†’ If yes: Edit the files and type "ready" when done. I'll re-read them.
749
+ β†’ If no: Type "continue" to proceed to Phase 4.
750
+ ```
751
+
752
+ **If user edits files:**
753
+ Execute `read_file()` for both documents to refresh context before continuing.
754
+
755
+ ---
756
+
757
+ **Proceed to Phase 4 only after documents are validated.**
758
+
759
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in this phase. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
760
+
761
+ ---
762
+
763
+ ## πŸ“ Generated Documents
764
+
765
+ After Phase 3, generate/update:
766
+ - `docs/architecture.md` - Technical stack and patterns
767
+ - `ai-instructions.md` - Instructions for AI agents
768
+
769
+ ---
770
+
771
+ **Next Phase:** Phase 4 - Security & Authentication (15-20 min)
772
+
773
+ Read: `.ai-flow/prompts/backend/flow-build-phase-4.md`
774
+
775
+ ---
776
+
777
+ **Last Updated:** 2025-12-20
778
+ **Version:** 2.1.8
779
+
780
+ ---
781
+
782
+ ## PHASE 4: Security & Authentication (15-20 min)