step-06-structure.md 11 KB

Step 6: Project Structure & Boundaries

MANDATORY EXECUTION RULES (READ FIRST):

  • ๐Ÿ›‘ NEVER generate content without user input

  • ๐Ÿ“– CRITICAL: ALWAYS read the complete step file before taking any action - partial understanding leads to incomplete decisions

  • ๐Ÿ”„ CRITICAL: When loading next step with 'C', ensure the entire file is read and understood before proceeding

  • โœ… ALWAYS treat this as collaborative discovery between architectural peers

  • ๐Ÿ“‹ YOU ARE A FACILITATOR, not a content generator

  • ๐Ÿ’ฌ FOCUS on defining complete project structure and clear boundaries

  • ๐Ÿ—บ๏ธ MAP requirements/epics to architectural components

  • โš ๏ธ ABSOLUTELY NO TIME ESTIMATES - AI development speed has fundamentally changed

  • โœ… YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config {communication_language}

EXECUTION PROTOCOLS:

  • ๐ŸŽฏ Show your analysis before taking any action
  • ๐Ÿ—บ๏ธ Create complete project tree, not generic placeholders
  • โš ๏ธ Present A/P/C menu after generating project structure
  • ๐Ÿ’พ ONLY save when user chooses C (Continue)
  • ๐Ÿ“– Update frontmatter stepsCompleted: [1, 2, 3, 4, 5, 6] before loading next step
  • ๐Ÿšซ FORBIDDEN to load next step until C is selected

COLLABORATION MENUS (A/P/C):

This step will generate content and present choices:

  • A (Advanced Elicitation): Use discovery protocols to explore innovative project organization approaches
  • P (Party Mode): Bring multiple perspectives to evaluate project structure trade-offs
  • C (Continue): Save the project structure and proceed to validation

PROTOCOL INTEGRATION:

  • When 'A' selected: Execute {project-root}/_bmad/core/workflows/advanced-elicitation/workflow.xml
  • When 'P' selected: Execute {project-root}/_bmad/core/workflows/party-mode/workflow.md
  • PROTOCOLS always return to display this step's A/P/C menu after the A or P have completed
  • User accepts/rejects protocol changes before proceeding

CONTEXT BOUNDARIES:

  • All previous architectural decisions are complete
  • Implementation patterns and consistency rules are defined
  • Focus on physical project structure and component boundaries
  • Map requirements to specific files and directories

YOUR TASK:

Define the complete project structure and architectural boundaries based on all decisions made, creating a concrete implementation guide for AI agents.

PROJECT STRUCTURE SEQUENCE:

1. Analyze Requirements Mapping

Map project requirements to architectural components:

From Epics (if available): "Epic: {{epic_name}} โ†’ Lives in {{module/directory/service}}"

  • User stories within the epic
  • Cross-epic dependencies
  • Shared components needed

From FR Categories (if no epics): "FR Category: {{fr_category_name}} โ†’ Lives in {{module/directory/service}}"

  • Related functional requirements
  • Shared functionality across categories
  • Integration points between categories

2. Define Project Directory Structure

Based on technology stack and patterns, create the complete project structure:

Root Configuration Files:

  • Package management files (package.json, requirements.txt, etc.)
  • Build and development configuration
  • Environment configuration files
  • CI/CD pipeline files
  • Documentation files

Source Code Organization:

  • Application entry points
  • Core application structure
  • Feature/module organization
  • Shared utilities and libraries
  • Configuration and environment files

Test Organization:

  • Unit test locations and structure
  • Integration test organization
  • End-to-end test structure
  • Test utilities and fixtures

Build and Distribution:

  • Build output directories
  • Distribution files
  • Static assets
  • Documentation build

3. Define Integration Boundaries

Map how components communicate and where boundaries exist:

API Boundaries:

  • External API endpoints
  • Internal service boundaries
  • Authentication and authorization boundaries
  • Data access layer boundaries

Component Boundaries:

  • Frontend component communication patterns
  • State management boundaries
  • Service communication patterns
  • Event-driven integration points

Data Boundaries:

  • Database schema boundaries
  • Data access patterns
  • Caching boundaries
  • External data integration points

4. Create Complete Project Tree

Generate a comprehensive directory structure showing all files and directories:

Technology-Specific Structure Examples:

Next.js Full-Stack:

project-name/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ next.config.js
โ”œโ”€โ”€ tailwind.config.js
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ .env.local
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ globals.css
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/
โ”‚   โ”‚   โ”œโ”€โ”€ forms/
โ”‚   โ”‚   โ””โ”€โ”€ features/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ db.ts
โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts
โ”‚   โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ middleware.ts
โ”œโ”€โ”€ prisma/
โ”‚   โ”œโ”€โ”€ schema.prisma
โ”‚   โ””โ”€โ”€ migrations/
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __mocks__/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ””โ”€โ”€ e2e/
โ””โ”€โ”€ public/
    โ””โ”€โ”€ assets/

API Backend (NestJS):

project-name/
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ nest-cli.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.ts
โ”‚   โ”œโ”€โ”€ app.module.ts
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ modules/
โ”‚   โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”‚   โ”œโ”€โ”€ users/
โ”‚   โ”‚   โ””โ”€โ”€ common/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ repositories/
โ”‚   โ”œโ”€โ”€ decorators/
โ”‚   โ”œโ”€โ”€ pipes/
โ”‚   โ”œโ”€โ”€ guards/
โ”‚   โ””โ”€โ”€ interceptors/
โ”œโ”€โ”€ test/
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ”œโ”€โ”€ integration/
โ”‚   โ””โ”€โ”€ e2e/
โ”œโ”€โ”€ prisma/
โ”‚   โ”œโ”€โ”€ schema.prisma
โ”‚   โ””โ”€โ”€ migrations/
โ””โ”€โ”€ docker-compose.yml

5. Map Requirements to Structure

Create explicit mapping from project requirements to specific files/directories:

Epic/Feature Mapping: "Epic: User Management

  • Components: src/components/features/users/
  • Services: src/services/users/
  • API Routes: src/app/api/users/
  • Database: prisma/migrations/users
  • Tests: tests/features/users/"

Cross-Cutting Concerns: "Authentication System

  • Components: src/components/auth/
  • Services: src/services/auth/
  • Middleware: src/middleware/auth.ts
  • Guards: src/guards/auth.guard.ts
  • Tests: tests/auth/"

6. Generate Structure Content

Prepare the content to append to the document:

Content Structure:

## Project Structure & Boundaries

### Complete Project Directory Structure

{{complete_project_tree_with_all_files_and_directories}}


### Architectural Boundaries

**API Boundaries:**
{{api_boundary_definitions_and_endpoints}}

**Component Boundaries:**
{{component_communication_patterns_and_boundaries}}

**Service Boundaries:**
{{service_integration_patterns_and_boundaries}}

**Data Boundaries:**
{{data_access_patterns_and_boundaries}}

### Requirements to Structure Mapping

**Feature/Epic Mapping:**
{{mapping_of_epics_or_features_to_specific_directories}}

**Cross-Cutting Concerns:**
{{mapping_of_shared_functionality_to_locations}}

### Integration Points

**Internal Communication:**
{{how_components_within_the_project_communicate}}

**External Integrations:**
{{third_party_service_integration_points}}

**Data Flow:**
{{how_data_flows_through_the_architecture}}

### File Organization Patterns

**Configuration Files:**
{{where_and_how_config_files_are_organized}}

**Source Organization:**
{{how_source_code_is_structured_and_organized}}

**Test Organization:**
{{how_tests_are_structured_and_organized}}

**Asset Organization:**
{{how_static_and_dynamic_assets_are_organized}}

### Development Workflow Integration

**Development Server Structure:**
{{how_the_project_is organized_for_development}}

**Build Process Structure:**
{{how_the_build_process_uses_the_project_structure}}

**Deployment Structure:**
{{how_the_project_structure_supports_deployment}}

7. Present Content and Menu

Show the generated project structure content and present choices:

"I've created a complete project structure based on all our architectural decisions.

Here's what I'll add to the document:

[Show the complete markdown content from step 6]

What would you like to do? [A] Advanced Elicitation - Explore innovative project organization approaches [P] Party Mode - Review structure from different development perspectives [C] Continue - Save this structure and move to architecture validation"

8. Handle Menu Selection

If 'A' (Advanced Elicitation):

  • Execute {project-root}/_bmad/core/workflows/advanced-elicitation/workflow.xml with current project structure
  • Process enhanced organizational insights that come back
  • Ask user: "Accept these changes to the project structure? (y/n)"
  • If yes: Update content, then return to A/P/C menu
  • If no: Keep original content, then return to A/P/C menu

If 'P' (Party Mode):

  • Execute {project-root}/_bmad/core/workflows/party-mode/workflow.md with project structure context
  • Process collaborative insights about organization trade-offs
  • Ask user: "Accept these changes to the project structure? (y/n)"
  • If yes: Update content, then return to A/P/C menu
  • If no: Keep original content, then return to A/P/C menu

If 'C' (Continue):

  • Append the final content to {planning_artifacts}/architecture.md
  • Update frontmatter: stepsCompleted: [1, 2, 3, 4, 5, 6]
  • Load ./step-07-validation.md

APPEND TO DOCUMENT:

When user selects 'C', append the content directly to the document using the structure from step 6.

SUCCESS METRICS:

โœ… Complete project tree defined with all files and directories โœ… All architectural boundaries clearly documented โœ… Requirements/epics mapped to specific locations โœ… Integration points and communication patterns defined โœ… Project structure aligned with chosen technology stack โœ… A/P/C menu presented and handled correctly โœ… Content properly appended to document when C selected

FAILURE MODES:

โŒ Creating generic placeholder structure instead of specific, complete tree โŒ Not mapping requirements to specific files and directories โŒ Missing important integration boundaries โŒ Not considering the chosen technology stack in structure design โŒ Not defining how components communicate across boundaries โŒ Not presenting A/P/C menu after content generation

โŒ CRITICAL: Reading only partial step file - leads to incomplete understanding and poor decisions โŒ CRITICAL: Proceeding with 'C' without fully reading and understanding the next step file โŒ CRITICAL: Making decisions without complete understanding of step requirements and protocols

NEXT STEP:

After user selects 'C' and content is saved to document, load ./step-07-validation.md to validate architectural coherence and completeness.

Remember: Do NOT proceed to step-07 until user explicitly selects 'C' from the A/P/C menu and content is saved!