ai-flow-dev 2.6.0 β†’ 2.7.0

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