ai-flow-dev 2.7.0 β 2.8.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.
- package/LICENSE +21 -21
- package/README.md +573 -570
- package/package.json +74 -74
- package/prompts/backend/flow-build-phase-0.md +535 -535
- package/prompts/backend/flow-build-phase-1.md +626 -626
- package/prompts/backend/flow-build-phase-10.md +340 -340
- package/prompts/backend/flow-build-phase-2.md +573 -573
- package/prompts/backend/flow-build-phase-3.md +834 -834
- package/prompts/backend/flow-build-phase-4.md +554 -554
- package/prompts/backend/flow-build-phase-5.md +703 -703
- package/prompts/backend/flow-build-phase-6.md +524 -524
- package/prompts/backend/flow-build-phase-7.md +1001 -1001
- package/prompts/backend/flow-build-phase-8.md +1407 -1407
- package/prompts/backend/flow-build-phase-9.md +477 -477
- package/prompts/backend/flow-build.md +137 -137
- package/prompts/backend/flow-check-review.md +656 -20
- package/prompts/backend/flow-check-test.md +526 -14
- package/prompts/backend/flow-check.md +725 -67
- package/prompts/backend/flow-commit.md +88 -119
- package/prompts/backend/flow-docs-sync.md +354 -354
- package/prompts/backend/flow-finish.md +919 -0
- package/prompts/backend/flow-release.md +949 -0
- package/prompts/backend/flow-work-feature.md +61 -61
- package/prompts/backend/flow-work-fix.md +46 -46
- package/prompts/backend/flow-work-refactor.md +48 -48
- package/prompts/backend/flow-work-resume.md +34 -34
- package/prompts/backend/flow-work.md +1098 -1286
- package/prompts/desktop/flow-build-phase-0.md +359 -359
- package/prompts/desktop/flow-build-phase-1.md +295 -295
- package/prompts/desktop/flow-build-phase-10.md +357 -357
- package/prompts/desktop/flow-build-phase-2.md +282 -282
- package/prompts/desktop/flow-build-phase-3.md +291 -291
- package/prompts/desktop/flow-build-phase-4.md +308 -308
- package/prompts/desktop/flow-build-phase-5.md +269 -269
- package/prompts/desktop/flow-build-phase-6.md +350 -350
- package/prompts/desktop/flow-build-phase-7.md +297 -297
- package/prompts/desktop/flow-build-phase-8.md +541 -541
- package/prompts/desktop/flow-build-phase-9.md +439 -439
- package/prompts/desktop/flow-build.md +156 -156
- package/prompts/desktop/flow-check-review.md +656 -20
- package/prompts/desktop/flow-check-test.md +526 -14
- package/prompts/desktop/flow-check.md +725 -67
- package/prompts/desktop/flow-commit.md +88 -119
- package/prompts/desktop/flow-docs-sync.md +354 -354
- package/prompts/desktop/flow-finish.md +910 -0
- package/prompts/desktop/flow-release.md +662 -0
- package/prompts/desktop/flow-work-feature.md +61 -61
- package/prompts/desktop/flow-work-fix.md +46 -46
- package/prompts/desktop/flow-work-refactor.md +48 -48
- package/prompts/desktop/flow-work-resume.md +34 -34
- package/prompts/desktop/flow-work.md +1202 -1390
- package/prompts/frontend/flow-build-phase-0.md +425 -425
- package/prompts/frontend/flow-build-phase-1.md +626 -626
- package/prompts/frontend/flow-build-phase-10.md +33 -33
- package/prompts/frontend/flow-build-phase-2.md +573 -573
- package/prompts/frontend/flow-build-phase-3.md +782 -782
- package/prompts/frontend/flow-build-phase-4.md +554 -554
- package/prompts/frontend/flow-build-phase-5.md +703 -703
- package/prompts/frontend/flow-build-phase-6.md +524 -524
- package/prompts/frontend/flow-build-phase-7.md +1001 -1001
- package/prompts/frontend/flow-build-phase-8.md +872 -872
- package/prompts/frontend/flow-build-phase-9.md +94 -94
- package/prompts/frontend/flow-build.md +137 -137
- package/prompts/frontend/flow-check-review.md +656 -20
- package/prompts/frontend/flow-check-test.md +526 -14
- package/prompts/frontend/flow-check.md +725 -67
- package/prompts/frontend/flow-commit.md +88 -119
- package/prompts/frontend/flow-docs-sync.md +550 -550
- package/prompts/frontend/flow-finish.md +910 -0
- package/prompts/frontend/flow-release.md +519 -0
- package/prompts/frontend/flow-work-api.md +1540 -0
- package/prompts/frontend/flow-work-feature.md +61 -61
- package/prompts/frontend/flow-work-fix.md +38 -38
- package/prompts/frontend/flow-work-refactor.md +48 -48
- package/prompts/frontend/flow-work-resume.md +34 -34
- package/prompts/frontend/flow-work.md +1583 -1320
- package/prompts/mobile/flow-build-phase-0.md +425 -425
- package/prompts/mobile/flow-build-phase-1.md +626 -626
- package/prompts/mobile/flow-build-phase-10.md +32 -32
- package/prompts/mobile/flow-build-phase-2.md +573 -573
- package/prompts/mobile/flow-build-phase-3.md +782 -782
- package/prompts/mobile/flow-build-phase-4.md +554 -554
- package/prompts/mobile/flow-build-phase-5.md +703 -703
- package/prompts/mobile/flow-build-phase-6.md +524 -524
- package/prompts/mobile/flow-build-phase-7.md +1001 -1001
- package/prompts/mobile/flow-build-phase-8.md +888 -888
- package/prompts/mobile/flow-build-phase-9.md +90 -90
- package/prompts/mobile/flow-build.md +135 -135
- package/prompts/mobile/flow-check-review.md +656 -20
- package/prompts/mobile/flow-check-test.md +526 -14
- package/prompts/mobile/flow-check.md +725 -67
- package/prompts/mobile/flow-commit.md +88 -119
- package/prompts/mobile/flow-docs-sync.md +620 -620
- package/prompts/mobile/flow-finish.md +910 -0
- package/prompts/mobile/flow-release.md +751 -0
- package/prompts/mobile/flow-work-api.md +1493 -0
- package/prompts/mobile/flow-work-feature.md +61 -61
- package/prompts/mobile/flow-work-fix.md +46 -46
- package/prompts/mobile/flow-work-refactor.md +48 -48
- package/prompts/mobile/flow-work-resume.md +34 -34
- package/prompts/mobile/flow-work.md +1593 -1329
- package/prompts/shared/mermaid-guidelines.md +102 -102
- package/prompts/shared/scope-levels.md +114 -114
- package/prompts/shared/smart-skip-preflight.md +214 -214
- package/prompts/shared/story-points.md +55 -55
- package/prompts/shared/task-format.md +74 -74
- package/prompts/shared/task-summary-template.md +277 -277
- package/templates/AGENT.template.md +443 -443
- package/templates/backend/.clauderules.template +112 -112
- package/templates/backend/.cursorrules.template +102 -102
- package/templates/backend/README.template.md +2 -2
- package/templates/backend/ai-instructions.template.md +2 -2
- package/templates/backend/copilot-instructions.template.md +2 -2
- package/templates/backend/docs/api.template.md +320 -320
- package/templates/backend/docs/business-flows.template.md +97 -97
- package/templates/backend/docs/code-standards.template.md +2 -2
- package/templates/backend/docs/contributing.template.md +3 -3
- package/templates/backend/docs/data-model.template.md +520 -520
- package/templates/backend/docs/testing.template.md +2 -2
- package/templates/backend/project-brief.template.md +2 -2
- package/templates/backend/specs/configuration.template.md +2 -2
- package/templates/backend/specs/security.template.md +2 -2
- package/templates/desktop/.clauderules.template +112 -112
- package/templates/desktop/.cursorrules.template +102 -102
- package/templates/desktop/README.template.md +170 -170
- package/templates/desktop/ai-instructions.template.md +366 -366
- package/templates/desktop/copilot-instructions.template.md +140 -140
- package/templates/desktop/docs/docs/api.template.md +320 -320
- package/templates/desktop/docs/docs/architecture.template.md +724 -724
- package/templates/desktop/docs/docs/business-flows.template.md +102 -102
- package/templates/desktop/docs/docs/code-standards.template.md +792 -792
- package/templates/desktop/docs/docs/contributing.template.md +149 -149
- package/templates/desktop/docs/docs/data-model.template.md +520 -520
- package/templates/desktop/docs/docs/operations.template.md +720 -720
- package/templates/desktop/docs/docs/testing.template.md +722 -722
- package/templates/desktop/project-brief.template.md +150 -150
- package/templates/desktop/specs/specs/configuration.template.md +121 -121
- package/templates/desktop/specs/specs/security.template.md +392 -392
- package/templates/frontend/README.template.md +2 -2
- package/templates/frontend/ai-instructions.template.md +2 -2
- package/templates/frontend/docs/api-integration.template.md +362 -362
- package/templates/frontend/docs/components.template.md +2 -2
- package/templates/frontend/docs/error-handling.template.md +360 -360
- package/templates/frontend/docs/operations.template.md +107 -107
- package/templates/frontend/docs/performance.template.md +124 -124
- package/templates/frontend/docs/pwa.template.md +119 -119
- package/templates/frontend/docs/state-management.template.md +2 -2
- package/templates/frontend/docs/styling.template.md +2 -2
- package/templates/frontend/docs/testing.template.md +2 -2
- package/templates/frontend/project-brief.template.md +2 -2
- package/templates/frontend/specs/accessibility.template.md +95 -95
- package/templates/frontend/specs/configuration.template.md +2 -2
- package/templates/frontend/specs/security.template.md +175 -175
- package/templates/fullstack/README.template.md +252 -252
- package/templates/fullstack/ai-instructions.template.md +444 -444
- package/templates/fullstack/project-brief.template.md +157 -157
- package/templates/fullstack/specs/configuration.template.md +340 -340
- package/templates/mobile/README.template.md +167 -167
- package/templates/mobile/ai-instructions.template.md +196 -196
- package/templates/mobile/docs/app-store.template.md +135 -135
- package/templates/mobile/docs/architecture.template.md +63 -63
- package/templates/mobile/docs/native-features.template.md +94 -94
- package/templates/mobile/docs/navigation.template.md +59 -59
- package/templates/mobile/docs/offline-strategy.template.md +65 -65
- package/templates/mobile/docs/permissions.template.md +56 -56
- package/templates/mobile/docs/state-management.template.md +85 -85
- package/templates/mobile/docs/testing.template.md +109 -109
- package/templates/mobile/project-brief.template.md +69 -69
- package/templates/mobile/specs/build-configuration.template.md +91 -91
- package/templates/mobile/specs/deployment.template.md +92 -92
- package/templates/work.template.md +47 -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)
|