bmad-method 4.13.0 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/GUIDING-PRINCIPLES.md +0 -33
- package/README.md +3 -2
- package/bmad-core/agents/analyst.md +3 -1
- package/bmad-core/agents/dev.md +3 -2
- package/bmad-core/agents/qa.md +15 -14
- package/bmad-core/data/bmad-kb.md +280 -19
- package/bmad-core/tasks/document-project.md +250 -322
- package/bmad-core/tasks/review-story.md +135 -0
- package/bmad-core/templates/story-tmpl.md +8 -0
- package/bmad-core/workflows/brownfield-fullstack.yml +36 -1
- package/bmad-core/workflows/brownfield-service.yml +36 -1
- package/bmad-core/workflows/brownfield-ui.yml +36 -1
- package/bmad-core/workflows/greenfield-fullstack.yml +36 -1
- package/bmad-core/workflows/greenfield-service.yml +36 -1
- package/bmad-core/workflows/greenfield-ui.yml +36 -1
- package/dist/agents/analyst.txt +603 -20
- package/dist/agents/architect.txt +230 -302
- package/dist/agents/bmad-master.txt +543 -328
- package/dist/agents/bmad-orchestrator.txt +280 -19
- package/dist/agents/dev.txt +6 -4
- package/dist/agents/pm.txt +25 -7
- package/dist/agents/po.txt +33 -7
- package/dist/agents/qa.txt +153 -14
- package/dist/agents/sm.txt +8 -0
- package/dist/expansion-packs/bmad-2d-phaser-game-dev/teams/phaser-2d-nodejs-game-team.txt +323 -1
- package/dist/expansion-packs/expansion-creator/agents/bmad-the-creator.txt +4 -12
- package/dist/teams/team-all.txt +1011 -443
- package/dist/teams/team-fullstack.txt +852 -425
- package/dist/teams/team-ide-minimal.txt +472 -44
- package/dist/teams/team-no-ui.txt +708 -421
- package/docs/working-in-the-brownfield.md +362 -0
- package/package.json +1 -1
- package/tools/installer/package.json +1 -1
|
@@ -8,382 +8,310 @@ Generate comprehensive documentation for existing projects optimized for AI deve
|
|
|
8
8
|
|
|
9
9
|
### 1. Initial Project Analysis
|
|
10
10
|
|
|
11
|
-
[[LLM:
|
|
11
|
+
[[LLM: First, check if a PRD or requirements document exists in context. If yes, use it to focus your documentation efforts on relevant areas only.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
2. **Technology Stack Identification**: Look for package.json, requirements.txt, Cargo.toml, pom.xml, etc. to identify languages, frameworks, and dependencies
|
|
15
|
-
3. **Build System Analysis**: Find build scripts, CI/CD configurations, and development commands
|
|
16
|
-
4. **Existing Documentation Review**: Check for README files, docs folders, and any existing documentation
|
|
17
|
-
5. **Code Pattern Analysis**: Sample key files to understand coding patterns, naming conventions, and architectural approaches
|
|
18
|
-
|
|
19
|
-
Ask the user these elicitation questions to better understand their needs:
|
|
20
|
-
|
|
21
|
-
- What is the primary purpose of this project?
|
|
22
|
-
- Are there any specific areas of the codebase that are particularly complex or important for agents to understand?
|
|
23
|
-
- What types of tasks do you expect AI agents to perform on this project? (e.g., bug fixes, feature additions, refactoring, testing)
|
|
24
|
-
- Are there any existing documentation standards or formats you prefer?
|
|
25
|
-
- What level of technical detail should the documentation target? (junior developers, senior developers, mixed team)
|
|
26
|
-
]]
|
|
27
|
-
|
|
28
|
-
### 2. Core Documentation Generation
|
|
29
|
-
|
|
30
|
-
[[LLM: Based on your analysis, generate the following core documentation files. Adapt the content and structure to match the specific project type and context you discovered:
|
|
31
|
-
|
|
32
|
-
**Core Documents (always generate):**
|
|
33
|
-
|
|
34
|
-
1. **docs/index.md** - Master documentation index
|
|
35
|
-
2. **docs/architecture/index.md** - Architecture documentation index
|
|
36
|
-
3. **docs/architecture/coding-standards.md** - Coding conventions and style guidelines
|
|
37
|
-
4. **docs/architecture/tech-stack.md** - Technology stack and version constraints
|
|
38
|
-
5. **docs/architecture/unified-project-structure.md** - Project structure and organization
|
|
39
|
-
6. **docs/architecture/testing-strategy.md** - Testing approaches and requirements
|
|
40
|
-
|
|
41
|
-
**Backend Documents (generate for backend/full-stack projects):**
|
|
42
|
-
|
|
43
|
-
7. **docs/architecture/backend-architecture.md** - Backend service patterns and structure
|
|
44
|
-
8. **docs/architecture/rest-api-spec.md** - API endpoint specifications
|
|
45
|
-
9. **docs/architecture/data-models.md** - Data structures and validation rules
|
|
46
|
-
10. **docs/architecture/database-schema.md** - Database design and relationships
|
|
47
|
-
11. **docs/architecture/external-apis.md** - Third-party integrations
|
|
48
|
-
|
|
49
|
-
**Frontend Documents (generate for frontend/full-stack projects):**
|
|
50
|
-
|
|
51
|
-
12. **docs/architecture/frontend-architecture.md** - Frontend patterns and structure
|
|
52
|
-
13. **docs/architecture/components.md** - UI component specifications
|
|
53
|
-
14. **docs/architecture/core-workflows.md** - User interaction flows
|
|
54
|
-
15. **docs/architecture/ui-ux-spec.md** - UI/UX specifications and guidelines
|
|
55
|
-
|
|
56
|
-
**Additional Documents (generate if applicable):**
|
|
13
|
+
**IF PRD EXISTS**:
|
|
57
14
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
15
|
+
- Review the PRD to understand what enhancement/feature is planned
|
|
16
|
+
- Identify which modules, services, or areas will be affected
|
|
17
|
+
- Focus documentation ONLY on these relevant areas
|
|
18
|
+
- Skip unrelated parts of the codebase to keep docs lean
|
|
62
19
|
|
|
63
|
-
**
|
|
20
|
+
**IF NO PRD EXISTS**:
|
|
21
|
+
Ask the user:
|
|
64
22
|
|
|
65
|
-
|
|
66
|
-
21. **docs/architecture/changelog-conventions.md** - Change management practices
|
|
67
|
-
22. **docs/architecture/code-review-checklist.md** - Review standards and practices
|
|
23
|
+
"I notice you haven't provided a PRD or requirements document. To create more focused and useful documentation, I recommend one of these options:
|
|
68
24
|
|
|
69
|
-
|
|
25
|
+
1. **Create a PRD first** - Would you like me to help create a brownfield PRD before documenting? This helps focus documentation on relevant areas.
|
|
70
26
|
|
|
71
|
-
|
|
27
|
+
2. **Provide existing requirements** - Do you have a requirements document, epic, or feature description you can share?
|
|
72
28
|
|
|
73
|
-
|
|
29
|
+
3. **Describe the focus** - Can you briefly describe what enhancement or feature you're planning? For example:
|
|
30
|
+
- 'Adding payment processing to the user service'
|
|
31
|
+
- 'Refactoring the authentication module'
|
|
32
|
+
- 'Integrating with a new third-party API'
|
|
74
33
|
|
|
75
|
-
|
|
76
|
-
# {{Document Title}}
|
|
34
|
+
4. **Document everything** - Or should I proceed with comprehensive documentation of the entire codebase? (Note: This may create excessive documentation for large projects)
|
|
77
35
|
|
|
78
|
-
|
|
36
|
+
Please let me know your preference, or I can proceed with full documentation if you prefer."
|
|
79
37
|
|
|
80
|
-
|
|
38
|
+
Based on their response:
|
|
81
39
|
|
|
82
|
-
|
|
40
|
+
- If they choose option 1-3: Use that context to focus documentation
|
|
41
|
+
- If they choose option 4 or decline: Proceed with comprehensive analysis below
|
|
83
42
|
|
|
84
|
-
|
|
43
|
+
Begin by conducting analysis of the existing project. Use available tools to:
|
|
85
44
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{{Concrete examples showing proper usage or implementation}}
|
|
93
|
-
|
|
94
|
-
## Common Patterns
|
|
95
|
-
|
|
96
|
-
{{Recurring patterns agents should recognize and follow}}
|
|
97
|
-
|
|
98
|
-
## Things to Avoid
|
|
99
|
-
|
|
100
|
-
{{Anti-patterns, deprecated approaches, or common mistakes}}
|
|
101
|
-
|
|
102
|
-
## Related Resources
|
|
103
|
-
|
|
104
|
-
{{Links to other relevant documentation or external resources}}
|
|
105
|
-
```
|
|
45
|
+
1. **Project Structure Discovery**: Examine the root directory structure, identify main folders, and understand the overall organization
|
|
46
|
+
2. **Technology Stack Identification**: Look for package.json, requirements.txt, Cargo.toml, pom.xml, etc. to identify languages, frameworks, and dependencies
|
|
47
|
+
3. **Build System Analysis**: Find build scripts, CI/CD configurations, and development commands
|
|
48
|
+
4. **Existing Documentation Review**: Check for README files, docs folders, and any existing documentation
|
|
49
|
+
5. **Code Pattern Analysis**: Sample key files to understand coding patterns, naming conventions, and architectural approaches
|
|
106
50
|
|
|
107
|
-
|
|
51
|
+
Ask the user these elicitation questions to better understand their needs:
|
|
108
52
|
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
53
|
+
- What is the primary purpose of this project?
|
|
54
|
+
- Are there any specific areas of the codebase that are particularly complex or important for agents to understand?
|
|
55
|
+
- What types of tasks do you expect AI agents to perform on this project? (e.g., bug fixes, feature additions, refactoring, testing)
|
|
56
|
+
- Are there any existing documentation standards or formats you prefer?
|
|
57
|
+
- What level of technical detail should the documentation target? (junior developers, senior developers, mixed team)
|
|
58
|
+
- Is there a specific feature or enhancement you're planning? (This helps focus documentation)
|
|
114
59
|
]]
|
|
115
60
|
|
|
116
|
-
###
|
|
117
|
-
|
|
118
|
-
#### Core Architecture Documents
|
|
61
|
+
### 2. Deep Codebase Analysis
|
|
119
62
|
|
|
120
|
-
|
|
63
|
+
[[LLM: Before generating documentation, conduct extensive analysis of the existing codebase:
|
|
121
64
|
|
|
122
|
-
|
|
65
|
+
1. **Explore Key Areas**:
|
|
66
|
+
- Entry points (main files, index files, app initializers)
|
|
67
|
+
- Configuration files and environment setup
|
|
68
|
+
- Package dependencies and versions
|
|
69
|
+
- Build and deployment configurations
|
|
70
|
+
- Test suites and coverage
|
|
123
71
|
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
72
|
+
2. **Ask Clarifying Questions**:
|
|
73
|
+
- "I see you're using [technology X]. Are there any custom patterns or conventions I should document?"
|
|
74
|
+
- "What are the most critical/complex parts of this system that developers struggle with?"
|
|
75
|
+
- "Are there any undocumented 'tribal knowledge' areas I should capture?"
|
|
76
|
+
- "What technical debt or known issues should I document?"
|
|
77
|
+
- "Which parts of the codebase change most frequently?"
|
|
128
78
|
|
|
129
|
-
|
|
79
|
+
3. **Map the Reality**:
|
|
80
|
+
- Identify ACTUAL patterns used (not theoretical best practices)
|
|
81
|
+
- Find where key business logic lives
|
|
82
|
+
- Locate integration points and external dependencies
|
|
83
|
+
- Document workarounds and technical debt
|
|
84
|
+
- Note areas that differ from standard patterns
|
|
130
85
|
|
|
131
|
-
|
|
86
|
+
**IF PRD PROVIDED**: Also analyze what would need to change for the enhancement]]
|
|
132
87
|
|
|
133
|
-
|
|
134
|
-
- Where each type of code belongs (backend, frontend, tests, etc.)
|
|
135
|
-
- File naming conventions and patterns
|
|
136
|
-
- Module/package organization
|
|
137
|
-
- Generated vs. source file locations
|
|
138
|
-
- Build output locations]]
|
|
88
|
+
### 3. Core Documentation Generation
|
|
139
89
|
|
|
140
|
-
|
|
90
|
+
[[LLM: Generate a comprehensive BROWNFIELD architecture document that reflects the ACTUAL state of the codebase.
|
|
141
91
|
|
|
142
|
-
|
|
92
|
+
**CRITICAL**: This is NOT an aspirational architecture document. Document what EXISTS, including:
|
|
93
|
+
- Technical debt and workarounds
|
|
94
|
+
- Inconsistent patterns between different parts
|
|
95
|
+
- Legacy code that can't be changed
|
|
96
|
+
- Integration constraints
|
|
97
|
+
- Performance bottlenecks
|
|
143
98
|
|
|
144
|
-
|
|
145
|
-
- Naming conventions (variables, functions, classes, files)
|
|
146
|
-
- Code organization within files
|
|
147
|
-
- Import/export patterns
|
|
148
|
-
- Comment and documentation standards
|
|
149
|
-
- Linting and formatting tool configurations
|
|
150
|
-
- Git commit message conventions]]
|
|
99
|
+
**Document Structure**:
|
|
151
100
|
|
|
152
|
-
|
|
101
|
+
# [Project Name] Brownfield Architecture Document
|
|
153
102
|
|
|
154
|
-
|
|
103
|
+
## Introduction
|
|
104
|
+
This document captures the CURRENT STATE of the [Project Name] codebase, including technical debt, workarounds, and real-world patterns. It serves as a reference for AI agents working on enhancements.
|
|
155
105
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
- Database systems and versions
|
|
160
|
-
- External services and APIs used
|
|
161
|
-
- Browser/runtime requirements]]
|
|
106
|
+
### Document Scope
|
|
107
|
+
[If PRD provided: "Focused on areas relevant to: {enhancement description}"]
|
|
108
|
+
[If no PRD: "Comprehensive documentation of entire system"]
|
|
162
109
|
|
|
163
|
-
|
|
110
|
+
### Change Log
|
|
111
|
+
| Date | Version | Description | Author |
|
|
112
|
+
|------|---------|-------------|--------|
|
|
113
|
+
| [Date] | 1.0 | Initial brownfield analysis | [Analyst] |
|
|
164
114
|
|
|
165
|
-
|
|
115
|
+
## Quick Reference - Key Files and Entry Points
|
|
166
116
|
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
-
|
|
117
|
+
### Critical Files for Understanding the System
|
|
118
|
+
- **Main Entry**: `src/index.js` (or actual entry point)
|
|
119
|
+
- **Configuration**: `config/app.config.js`, `.env.example`
|
|
120
|
+
- **Core Business Logic**: `src/services/`, `src/domain/`
|
|
121
|
+
- **API Definitions**: `src/routes/` or link to OpenAPI spec
|
|
122
|
+
- **Database Models**: `src/models/` or link to schema files
|
|
123
|
+
- **Key Algorithms**: [List specific files with complex logic]
|
|
174
124
|
|
|
175
|
-
|
|
125
|
+
### If PRD Provided - Enhancement Impact Areas
|
|
126
|
+
[Highlight which files/modules will be affected by the planned enhancement]
|
|
176
127
|
|
|
177
|
-
|
|
128
|
+
## High Level Architecture
|
|
178
129
|
|
|
179
|
-
|
|
130
|
+
### Technical Summary
|
|
131
|
+
[Real assessment of architecture - mention if it's well-structured or has issues]
|
|
180
132
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
133
|
+
### Actual Tech Stack (from package.json/requirements.txt)
|
|
134
|
+
| Category | Technology | Version | Notes |
|
|
135
|
+
|----------|------------|---------|--------|
|
|
136
|
+
| Runtime | Node.js | 16.x | [Any constraints] |
|
|
137
|
+
| Framework | Express | 4.18.2 | [Custom middleware?] |
|
|
138
|
+
| Database | PostgreSQL | 13 | [Connection pooling setup] |
|
|
139
|
+
| [etc...] |
|
|
188
140
|
|
|
189
|
-
|
|
141
|
+
### Repository Structure Reality Check
|
|
142
|
+
- Type: [Monorepo/Polyrepo/Hybrid]
|
|
143
|
+
- Package Manager: [npm/yarn/pnpm]
|
|
144
|
+
- Notable: [Any unusual structure decisions]
|
|
190
145
|
|
|
191
|
-
|
|
146
|
+
## Source Tree and Module Organization
|
|
192
147
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
- Core business entities
|
|
208
|
-
- Data validation rules
|
|
209
|
-
- Relationships between entities
|
|
210
|
-
- Computed fields and derivations
|
|
211
|
-
- Data transformation patterns
|
|
212
|
-
- Serialization formats]]
|
|
213
|
-
|
|
214
|
-
##### docs/architecture/database-schema.md
|
|
215
|
-
|
|
216
|
-
[[LLM: Document database design:
|
|
217
|
-
|
|
218
|
-
- Database type and version
|
|
219
|
-
- Table/collection structures
|
|
220
|
-
- Indexes and constraints
|
|
221
|
-
- Relationships and foreign keys
|
|
222
|
-
- Migration patterns
|
|
223
|
-
- Seed data requirements
|
|
224
|
-
- Backup and recovery procedures]]
|
|
225
|
-
|
|
226
|
-
##### docs/architecture/external-apis.md
|
|
227
|
-
|
|
228
|
-
[[LLM: Document third-party integrations:
|
|
229
|
-
|
|
230
|
-
- List of external services used
|
|
231
|
-
- Authentication methods for each
|
|
232
|
-
- API endpoints and usage patterns
|
|
233
|
-
- Rate limits and quotas
|
|
234
|
-
- Error handling strategies
|
|
235
|
-
- Webhook configurations
|
|
236
|
-
- Data synchronization patterns]]
|
|
237
|
-
|
|
238
|
-
#### Frontend Architecture Documents
|
|
239
|
-
|
|
240
|
-
##### docs/architecture/frontend-architecture.md
|
|
241
|
-
|
|
242
|
-
[[LLM: Document frontend application structure:
|
|
243
|
-
|
|
244
|
-
- Component hierarchy and organization
|
|
245
|
-
- State management patterns
|
|
246
|
-
- Routing architecture
|
|
247
|
-
- Data fetching patterns
|
|
248
|
-
- Authentication flow
|
|
249
|
-
- Error boundary strategies
|
|
250
|
-
- Performance optimization patterns]]
|
|
251
|
-
|
|
252
|
-
##### docs/architecture/components.md
|
|
253
|
-
|
|
254
|
-
[[LLM: Specify UI components:
|
|
255
|
-
|
|
256
|
-
- Component library/design system used
|
|
257
|
-
- Custom component specifications
|
|
258
|
-
- Props and state for each component
|
|
259
|
-
- Component composition patterns
|
|
260
|
-
- Styling approaches
|
|
261
|
-
- Accessibility requirements
|
|
262
|
-
- Component testing patterns]]
|
|
263
|
-
|
|
264
|
-
##### docs/architecture/core-workflows.md
|
|
265
|
-
|
|
266
|
-
[[LLM: Document user interaction flows:
|
|
267
|
-
|
|
268
|
-
- Major user journeys
|
|
269
|
-
- Screen flow diagrams
|
|
270
|
-
- Form handling patterns
|
|
271
|
-
- Navigation patterns
|
|
272
|
-
- Data flow through workflows
|
|
273
|
-
- Error states and recovery
|
|
274
|
-
- Loading and transition states]]
|
|
275
|
-
|
|
276
|
-
##### docs/architecture/ui-ux-spec.md
|
|
277
|
-
|
|
278
|
-
[[LLM: Define UI/UX guidelines:
|
|
279
|
-
|
|
280
|
-
- Design system specifications
|
|
281
|
-
- Color palette and typography
|
|
282
|
-
- Spacing and layout grids
|
|
283
|
-
- Responsive breakpoints
|
|
284
|
-
- Animation and transition guidelines
|
|
285
|
-
- Accessibility standards
|
|
286
|
-
- Browser compatibility requirements]]
|
|
287
|
-
|
|
288
|
-
### 5. Adaptive Content Strategy
|
|
289
|
-
|
|
290
|
-
[[LLM: Adapt your documentation approach based on project characteristics:
|
|
291
|
-
|
|
292
|
-
**For Web Applications:**
|
|
293
|
-
|
|
294
|
-
- Focus on component patterns, routing, state management
|
|
295
|
-
- Include build processes, asset handling, and deployment
|
|
296
|
-
- Cover API integration patterns and data fetching
|
|
297
|
-
|
|
298
|
-
**For Backend Services:**
|
|
299
|
-
|
|
300
|
-
- Emphasize service architecture, data models, and API design
|
|
301
|
-
- Include database interaction patterns and migration strategies
|
|
302
|
-
- Cover authentication, authorization, and security patterns
|
|
303
|
-
|
|
304
|
-
**For CLI Tools:**
|
|
305
|
-
|
|
306
|
-
- Focus on command structure, argument parsing, and output formatting
|
|
307
|
-
- Include plugin/extension patterns if applicable
|
|
308
|
-
- Cover configuration file handling and user interaction patterns
|
|
309
|
-
|
|
310
|
-
**For Libraries/Frameworks:**
|
|
311
|
-
|
|
312
|
-
- Emphasize public API design and usage patterns
|
|
313
|
-
- Include extension points and customization approaches
|
|
314
|
-
- Cover versioning, compatibility, and migration strategies
|
|
315
|
-
|
|
316
|
-
**For Mobile Applications:**
|
|
317
|
-
|
|
318
|
-
- Focus on platform-specific patterns and navigation
|
|
319
|
-
- Include state management and data persistence approaches
|
|
320
|
-
- Cover platform integration and native feature usage
|
|
321
|
-
|
|
322
|
-
**For Data Science/ML Projects:**
|
|
323
|
-
|
|
324
|
-
- Emphasize data pipeline patterns and model organization
|
|
325
|
-
- Include experiment tracking and reproducibility approaches
|
|
326
|
-
- Cover data validation and model deployment patterns
|
|
327
|
-
]]
|
|
328
|
-
|
|
329
|
-
### 6. Quality Assurance
|
|
330
|
-
|
|
331
|
-
[[LLM: Before completing each document:
|
|
332
|
-
|
|
333
|
-
1. **Accuracy Check**: Verify all file paths, commands, and code examples work
|
|
334
|
-
2. **Completeness Review**: Ensure the document covers the most important patterns an agent would encounter
|
|
335
|
-
3. **Clarity Assessment**: Check that explanations are clear and actionable
|
|
336
|
-
4. **Consistency Verification**: Ensure terminology and patterns align across all documents
|
|
337
|
-
5. **Agent Perspective**: Review from the viewpoint of an AI agent that needs to contribute to this project
|
|
338
|
-
|
|
339
|
-
Ask the user to review each completed document and use the advanced elicitation task to refine based on their feedback.]]
|
|
148
|
+
### Project Structure (Actual)
|
|
149
|
+
```
|
|
150
|
+
project-root/
|
|
151
|
+
├── src/
|
|
152
|
+
│ ├── controllers/ # HTTP request handlers
|
|
153
|
+
│ ├── services/ # Business logic (NOTE: inconsistent patterns between user and payment services)
|
|
154
|
+
│ ├── models/ # Database models (Sequelize)
|
|
155
|
+
│ ├── utils/ # Mixed bag - needs refactoring
|
|
156
|
+
│ └── legacy/ # DO NOT MODIFY - old payment system still in use
|
|
157
|
+
├── tests/ # Jest tests (60% coverage)
|
|
158
|
+
├── scripts/ # Build and deployment scripts
|
|
159
|
+
└── config/ # Environment configs
|
|
160
|
+
```
|
|
340
161
|
|
|
341
|
-
###
|
|
162
|
+
### Key Modules and Their Purpose
|
|
163
|
+
- **User Management**: `src/services/userService.js` - Handles all user operations
|
|
164
|
+
- **Authentication**: `src/middleware/auth.js` - JWT-based, custom implementation
|
|
165
|
+
- **Payment Processing**: `src/legacy/payment.js` - CRITICAL: Do not refactor, tightly coupled
|
|
166
|
+
- **[List other key modules with their actual files]**
|
|
167
|
+
|
|
168
|
+
## Data Models and APIs
|
|
169
|
+
|
|
170
|
+
### Data Models
|
|
171
|
+
Instead of duplicating, reference actual model files:
|
|
172
|
+
- **User Model**: See `src/models/User.js`
|
|
173
|
+
- **Order Model**: See `src/models/Order.js`
|
|
174
|
+
- **Related Types**: TypeScript definitions in `src/types/`
|
|
175
|
+
|
|
176
|
+
### API Specifications
|
|
177
|
+
- **OpenAPI Spec**: `docs/api/openapi.yaml` (if exists)
|
|
178
|
+
- **Postman Collection**: `docs/api/postman-collection.json`
|
|
179
|
+
- **Manual Endpoints**: [List any undocumented endpoints discovered]
|
|
180
|
+
|
|
181
|
+
## Technical Debt and Known Issues
|
|
182
|
+
|
|
183
|
+
### Critical Technical Debt
|
|
184
|
+
1. **Payment Service**: Legacy code in `src/legacy/payment.js` - tightly coupled, no tests
|
|
185
|
+
2. **User Service**: Different pattern than other services, uses callbacks instead of promises
|
|
186
|
+
3. **Database Migrations**: Manually tracked, no proper migration tool
|
|
187
|
+
4. **[Other significant debt]**
|
|
188
|
+
|
|
189
|
+
### Workarounds and Gotchas
|
|
190
|
+
- **Environment Variables**: Must set `NODE_ENV=production` even for staging (historical reason)
|
|
191
|
+
- **Database Connections**: Connection pool hardcoded to 10, changing breaks payment service
|
|
192
|
+
- **[Other workarounds developers need to know]**
|
|
193
|
+
|
|
194
|
+
## Integration Points and External Dependencies
|
|
195
|
+
|
|
196
|
+
### External Services
|
|
197
|
+
| Service | Purpose | Integration Type | Key Files |
|
|
198
|
+
|---------|---------|------------------|-----------|
|
|
199
|
+
| Stripe | Payments | REST API | `src/integrations/stripe/` |
|
|
200
|
+
| SendGrid | Emails | SDK | `src/services/emailService.js` |
|
|
201
|
+
| [etc...] |
|
|
202
|
+
|
|
203
|
+
### Internal Integration Points
|
|
204
|
+
- **Frontend Communication**: REST API on port 3000, expects specific headers
|
|
205
|
+
- **Background Jobs**: Redis queue, see `src/workers/`
|
|
206
|
+
- **[Other integrations]**
|
|
207
|
+
|
|
208
|
+
## Development and Deployment
|
|
209
|
+
|
|
210
|
+
### Local Development Setup
|
|
211
|
+
1. Actual steps that work (not ideal steps)
|
|
212
|
+
2. Known issues with setup
|
|
213
|
+
3. Required environment variables (see `.env.example`)
|
|
214
|
+
|
|
215
|
+
### Build and Deployment Process
|
|
216
|
+
- **Build Command**: `npm run build` (webpack config in `webpack.config.js`)
|
|
217
|
+
- **Deployment**: Manual deployment via `scripts/deploy.sh`
|
|
218
|
+
- **Environments**: Dev, Staging, Prod (see `config/environments/`)
|
|
219
|
+
|
|
220
|
+
## Testing Reality
|
|
221
|
+
|
|
222
|
+
### Current Test Coverage
|
|
223
|
+
- Unit Tests: 60% coverage (Jest)
|
|
224
|
+
- Integration Tests: Minimal, in `tests/integration/`
|
|
225
|
+
- E2E Tests: None
|
|
226
|
+
- Manual Testing: Primary QA method
|
|
227
|
+
|
|
228
|
+
### Running Tests
|
|
229
|
+
```bash
|
|
230
|
+
npm test # Runs unit tests
|
|
231
|
+
npm run test:integration # Runs integration tests (requires local DB)
|
|
232
|
+
```
|
|
342
233
|
|
|
343
|
-
|
|
234
|
+
## If Enhancement PRD Provided - Impact Analysis
|
|
235
|
+
|
|
236
|
+
### Files That Will Need Modification
|
|
237
|
+
Based on the enhancement requirements, these files will be affected:
|
|
238
|
+
- `src/services/userService.js` - Add new user fields
|
|
239
|
+
- `src/models/User.js` - Update schema
|
|
240
|
+
- `src/routes/userRoutes.js` - New endpoints
|
|
241
|
+
- [etc...]
|
|
242
|
+
|
|
243
|
+
### New Files/Modules Needed
|
|
244
|
+
- `src/services/newFeatureService.js` - New business logic
|
|
245
|
+
- `src/models/NewFeature.js` - New data model
|
|
246
|
+
- [etc...]
|
|
247
|
+
|
|
248
|
+
### Integration Considerations
|
|
249
|
+
- Will need to integrate with existing auth middleware
|
|
250
|
+
- Must follow existing response format in `src/utils/responseFormatter.js`
|
|
251
|
+
- [Other integration points]
|
|
252
|
+
|
|
253
|
+
## Appendix - Useful Commands and Scripts
|
|
254
|
+
|
|
255
|
+
### Frequently Used Commands
|
|
256
|
+
```bash
|
|
257
|
+
npm run dev # Start development server
|
|
258
|
+
npm run build # Production build
|
|
259
|
+
npm run migrate # Run database migrations
|
|
260
|
+
npm run seed # Seed test data
|
|
261
|
+
```
|
|
344
262
|
|
|
345
|
-
|
|
263
|
+
### Debugging and Troubleshooting
|
|
264
|
+
- **Logs**: Check `logs/app.log` for application logs
|
|
265
|
+
- **Debug Mode**: Set `DEBUG=app:*` for verbose logging
|
|
266
|
+
- **Common Issues**: See `docs/troubleshooting.md`]]
|
|
346
267
|
|
|
347
|
-
|
|
348
|
-
- Architecture shards in `docs/architecture/` subdirectory
|
|
349
|
-
- Create the `docs/architecture/` directory if it doesn't exist
|
|
268
|
+
### 4. Document Delivery
|
|
350
269
|
|
|
351
|
-
|
|
270
|
+
[[LLM: After generating the complete architecture document:
|
|
352
271
|
|
|
353
|
-
|
|
354
|
-
-
|
|
272
|
+
1. **In Web UI (Gemini, ChatGPT, Claude)**:
|
|
273
|
+
- Present the entire document in one response (or multiple if too long)
|
|
274
|
+
- Tell user to copy and save as `docs/brownfield-architecture.md` or `docs/project-architecture.md`
|
|
275
|
+
- Mention it can be sharded later in IDE if needed
|
|
355
276
|
|
|
356
|
-
|
|
277
|
+
2. **In IDE Environment**:
|
|
278
|
+
- Create the document as `docs/brownfield-architecture.md`
|
|
279
|
+
- Inform user this single document contains all architectural information
|
|
280
|
+
- Can be sharded later using PO agent if desired
|
|
357
281
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
282
|
+
The document should be comprehensive enough that future agents can understand:
|
|
283
|
+
- The actual state of the system (not idealized)
|
|
284
|
+
- Where to find key files and logic
|
|
285
|
+
- What technical debt exists
|
|
286
|
+
- What constraints must be respected
|
|
287
|
+
- If PRD provided: What needs to change for the enhancement]]
|
|
361
288
|
|
|
362
|
-
|
|
289
|
+
### 5. Quality Assurance
|
|
363
290
|
|
|
364
|
-
|
|
365
|
-
- Create a simple checklist for keeping docs current
|
|
366
|
-
- Suggest automated validation approaches
|
|
291
|
+
[[LLM: Before finalizing the document:
|
|
367
292
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
293
|
+
1. **Accuracy Check**: Verify all technical details match the actual codebase
|
|
294
|
+
2. **Completeness Review**: Ensure all major system components are documented
|
|
295
|
+
3. **Focus Validation**: If user provided scope, verify relevant areas are emphasized
|
|
296
|
+
4. **Clarity Assessment**: Check that explanations are clear for AI agents
|
|
297
|
+
5. **Navigation**: Ensure document has clear section structure for easy reference
|
|
373
298
|
|
|
374
|
-
|
|
299
|
+
Apply the advanced elicitation task after major sections to refine based on user feedback.]]
|
|
375
300
|
|
|
376
301
|
## Success Criteria
|
|
377
302
|
|
|
378
|
-
-
|
|
379
|
-
-
|
|
380
|
-
-
|
|
381
|
-
-
|
|
382
|
-
-
|
|
303
|
+
- Single comprehensive brownfield architecture document created
|
|
304
|
+
- Document reflects REALITY including technical debt and workarounds
|
|
305
|
+
- Key files and modules are referenced with actual paths
|
|
306
|
+
- Models/APIs reference source files rather than duplicating content
|
|
307
|
+
- If PRD provided: Clear impact analysis showing what needs to change
|
|
308
|
+
- Document enables AI agents to navigate and understand the actual codebase
|
|
309
|
+
- Technical constraints and "gotchas" are clearly documented
|
|
383
310
|
|
|
384
311
|
## Notes
|
|
385
312
|
|
|
386
|
-
- This task
|
|
387
|
-
-
|
|
388
|
-
-
|
|
389
|
-
-
|
|
313
|
+
- This task creates ONE document that captures the TRUE state of the system
|
|
314
|
+
- References actual files rather than duplicating content when possible
|
|
315
|
+
- Documents technical debt, workarounds, and constraints honestly
|
|
316
|
+
- For brownfield projects with PRD: Provides clear enhancement impact analysis
|
|
317
|
+
- The goal is PRACTICAL documentation for AI agents doing real work
|