PRD Management - johnpeterman72/CursorRIPER.sigma GitHub Wiki

📄 PRD Management

Product Requirements Document (PRD) management in BMAD Enterprise provides a structured approach to documenting, tracking, and managing business requirements throughout the development lifecycle.

PRD Lifecycle Integration

// Framework event-driven PRD workflow
class BMADPRDManager {
  constructor(framework) {
    this.framework = framework;
    this.eventBus = framework.getEventBus();
    this.dbService = framework.getDatabase();
    this.initialize();
  }

  initialize() {
    // Subscribe to framework events
    this.eventBus.subscribe('project.created', this.onProjectCreated.bind(this));
    this.eventBus.subscribe('user.role.changed', this.onRoleChanged.bind(this));
    this.eventBus.subscribe('bmad.model.updated', this.onModelUpdated.bind(this));
  }

  async createPRD(projectId, templateType = 'standard') {
    const template = await this.getTemplate(templateType);
    const project = await this.framework.projects.get(projectId);
    
    const prd = {
      id: this.framework.utils.generateId(),
      projectId,
      template: templateType,
      status: 'draft',
      version: '1.0.0',
      created: new Date(),
      sections: this.initializeSections(template),
      metadata: {
        businessModel: project.businessModel,
        stakeholders: project.stakeholders,
        timeline: project.timeline
      }
    };

    await this.dbService.collection('prds').create(prd);
    
    // Emit framework event
    this.eventBus.emit('bmad.prd.created', {
      prd,
      project,
      timestamp: new Date()
    });

    return prd;
  }
}

Document Templates

Business Model PRD Template

template_id: "bmad_business_model"
version: "2.1.0"
framework_integration: true

sections:
  executive_summary:
    required: true
    approvers: ["bmad.strategist", "bmad.project_manager"]
    framework_data: 
      - project.overview
      - stakeholder.summary
      
  business_model_canvas:
    required: true
    approvers: ["bmad.strategist"]
    components:
      - value_propositions
      - customer_segments
      - channels
      - customer_relationships
      - revenue_streams
      - key_resources
      - key_activities
      - key_partnerships
      - cost_structure
    framework_integration:
      - bmad.canvas.export
      - bmad.canvas.import
      
  stakeholder_analysis:
    required: true
    approvers: ["bmad.analyst", "bmad.project_manager"]
    framework_data:
      - stakeholder.roles
      - stakeholder.influence_map
      - stakeholder.engagement_plan
      
  financial_projections:
    required: true
    approvers: ["bmad.strategist", "financial.analyst"]
    framework_integration:
      - bmad.financial.model
      - external.financial_apis
      
  risk_assessment:
    required: true
    approvers: ["bmad.strategist", "risk.manager"]
    framework_data:
      - bmad.risk.matrix
      - bmad.mitigation.plans

Approval Workflows

class BMADApprovalWorkflow {
  constructor(framework, prdManager) {
    this.framework = framework;
    this.prdManager = prdManager;
    this.workflowEngine = framework.getWorkflowEngine();
  }

  async initiatePRDApproval(prdId) {
    const prd = await this.prdManager.getPRD(prdId);
    const workflow = {
      id: `prd_approval_${prdId}`,
      type: 'bmad.prd.approval',
      data: { prdId, currentSection: 0 },
      steps: await this.buildApprovalSteps(prd)
    };

    return await this.workflowEngine.start(workflow);
  }

  async buildApprovalSteps(prd) {
    const steps = [];
    
    for (const [sectionName, section] of Object.entries(prd.sections)) {
      if (section.required && section.approvers) {
        steps.push({
          name: `approve_${sectionName}`,
          type: 'approval',
          approvers: section.approvers,
          data: {
            section: sectionName,
            content: section.content,
            framework_validations: section.framework_validations || []
          },
          onApproval: this.onSectionApproved.bind(this),
          onRejection: this.onSectionRejected.bind(this)
        });
      }
    }

    return steps;
  }

  async onSectionApproved(stepData, approver) {
    // Update PRD section status
    await this.prdManager.updateSectionStatus(
      stepData.prdId, 
      stepData.section, 
      'approved'
    );

    // Emit framework event
    this.framework.getEventBus().emit('bmad.prd.section.approved', {
      prdId: stepData.prdId,
      section: stepData.section,
      approver,
      timestamp: new Date()
    });

    // Check if all sections are approved
    const prd = await this.prdManager.getPRD(stepData.prdId);
    if (this.areAllSectionsApproved(prd)) {
      await this.finalizePRD(prd);
    }
  }
}

Version Control Integration

class BMADVersionControl {
  constructor(framework) {
    this.framework = framework;
    this.gitService = framework.getGitService();
    this.storageService = framework.getStorage();
  }

  async commitPRDVersion(prdId, message, author) {
    const prd = await this.getPRD(prdId);
    const serialized = await this.serializePRD(prd);
    
    // Create framework-compatible commit
    const commit = {
      module: 'bmad',
      type: 'prd_update',
      data: serialized,
      metadata: {
        prdId,
        version: prd.version,
        author,
        businessModel: prd.metadata.businessModel
      }
    };

    return await this.framework.versionControl.commit(commit, message);
  }

  async createPRDBranch(prdId, branchName, baseVersion = 'latest') {
    const prd = await this.getPRD(prdId);
    
    // Use framework's branching system
    return await this.framework.versionControl.createBranch({
      name: `prd/${prdId}/${branchName}`,
      base: baseVersion,
      metadata: {
        type: 'bmad.prd',
        prdId,
        businessModel: prd.metadata.businessModel
      }
    });
  }

  async mergePRDChanges(prdId, sourceBranch, targetBranch) {
    // Framework-assisted merge with conflict resolution
    const mergeResult = await this.framework.versionControl.merge({
      source: sourceBranch,
      target: targetBranch,
      resolver: this.resolvePRDConflicts.bind(this)
    });

    if (mergeResult.conflicts) {
      // Use BMAD-specific conflict resolution
      return await this.handlePRDConflicts(prdId, mergeResult.conflicts);
    }

    return mergeResult;
  }
}