# microsoft/powerplatform-build-tools architecture

> Architecture diagram of the GitHub repository microsoft/powerplatform-build-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/powerplatform-build-tools
- Repository: https://github.com/microsoft/powerplatform-build-tools

## Overview

##### Main Components

a. Core Components:
- Power Platform CLI Integration Layer
- Task Execution Engine
- Authentication Handler
- Build Tools Host
- Pipeline Variables Manager

b. Task Categories:
- Solution Management Tasks
- Environment Management Tasks
- Data Operations Tasks
- Security & Governance Tasks
- Portal Management Tasks

##### Component Relationships

Layer 1 - Client Interface:
- Azure DevOps Pipeline Integration
- Azure Pipeline Variables
- Service Connections

Layer 2 - Build Tools Core:
- Task Parser
- Build Tools Host
- Authentication Manager
- CLI Locator

Layer 3 - Task Implementation:
- Tasks by category (Solution, Environment, Data, etc.)
- Common shared components between tasks

Layer 3 - External Integration:
- Power Platform CLI
- Power Platform Environments
- Source Control Systems

##### Specific Implementation Details

- Blue rectangles: Core components
- Green rectangles: Task implementations
- Yellow diamonds: External services
- Purple rectangles: Authentication components
- Gray rectangles: Supporting utilities

##### Connection Types

- Double lines: Two-way communication

##### Key Elements to Highlight

a. Authentication Flow:
- How credentials are handled
- Demonstrate service connection usage
- Environment URL resolution

b. Task Execution Flow:
- Pipeline variable processing
- CLI command generation
- Task execution and monitoring

c. External Integration Points:
- Power Platform CLI interaction
- Environment management
- Source control integration

##### Implementation Notes

- src/host for core hosting functionality
- src/params for parameter handling
- src/tasks for individual task implementations
- src/parser for pipeline definition parsing

##### Technical Details

- TypeScript/Node.js runtime environment
- Azure DevOps extension packaging
- CLI tool dependencies
- Cross-platform support indicators

- Layered architecture representation
- Export to common formats
- Version control friendly format

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#4a90e2,color:white
    classDef task fill:#50c878,color:white
    classDef external fill:#ffd700,color:black
    classDef auth fill:#9370db,color:white
    classDef util fill:#808080,color:white

    %% Layer 1 - Client Interface
    subgraph ClientLayer
        ADO["Azure DevOps Pipeline"]:::external
        AzureVars["Pipeline Variables"]:::external
        ServiceConn["Service Connections"]:::external
    end

    %% Layer 2 - Build Tools Core
    subgraph CoreLayer
        BTHost["Build Tools Host"]:::core
        TaskParser["Task Parser"]:::core
        AuthManager["Authentication Manager"]:::auth
        CLILocator["CLI Locator"]:::core
        PipelineVars["Pipeline Variables Manager"]:::core
    end

    %% Layer 3 - Task Implementation
    subgraph TaskLayer
        subgraph SolutionTasks["Solution Management"]
            ExportSol["Export Solution"]:::task
            ImportSol["Import Solution"]:::task
            PackSol["Pack Solution"]:::task
            UnpackSol["Unpack Solution"]:::task
        end

        subgraph EnvTasks["Environment Management"]
            CreateEnv["Create Environment"]:::task
            DeleteEnv["Delete Environment"]:::task
            CopyEnv["Copy Environment"]:::task
            BackupEnv["Backup Environment"]:::task
        end

        subgraph DataTasks["Data Operations"]
            ExportData["Export Data"]:::task
            ImportData["Import Data"]:::task
        end

        subgraph SecurityTasks["Security & Governance"]
            SetGov["Set Governance Config"]:::task
            AssignUser["Assign User"]:::task
            AssignGroup["Assign Group"]:::task
        end

        subgraph PortalTasks["Portal Management"]
            UploadPortal["Upload Portal"]:::task
            DownloadPortal["Download Portal"]:::task
        end
    end

    %% Layer 4 - External Integration
    subgraph ExternalLayer
        PPCLI["Power Platform CLI"]:::external
        PPEnv["Power Platform Environments"]:::external
        SourceControl["Source Control Systems"]:::external
    end

    %% Relationships
    ADO --> TaskParser
    ADO --> AzureVars
    AzureVars --> PipelineVars
    ServiceConn --> AuthManager
    
    TaskParser --> BTHost
    BTHost --> CLILocator
    BTHost --> AuthManager
    BTHost --> PipelineVars
    
    CLILocator --> PPCLI
    AuthManager --> PPEnv
    
    BTHost --> SolutionTasks
    BTHost --> EnvTasks
    BTHost --> DataTasks
    BTHost --> SecurityTasks
    BTHost --> PortalTasks

    SolutionTasks --> PPCLI
    EnvTasks --> PPCLI
    DataTasks --> PPCLI
    SecurityTasks --> PPCLI
    PortalTasks --> PPCLI

    PPCLI --> PPEnv
    PPEnv --> SourceControl

    %% Click events for component mapping
    click BTHost "https://github.com/microsoft/powerplatform-build-tools/blob/main/src/host/BuildToolsHost.ts"
    click CLILocator "https://github.com/microsoft/powerplatform-build-tools/blob/main/src/host/CliLocator.ts"
    click PipelineVars "https://github.com/microsoft/powerplatform-build-tools/blob/main/src/host/PipelineVariables.ts"
    click AuthManager "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/params/auth/"
    click TaskParser "https://github.com/microsoft/powerplatform-build-tools/blob/main/src/parser/TaskParser.ts"
    click SolutionTasks "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/tasks/export-solution/,src/tasks/import-solution/,src/tasks/pack-solution/,src/tasks/unpack-solution/"
    click EnvTasks "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/tasks/create-environment/,src/tasks/delete-environment/,src/tasks/copy-environment/,src/tasks/backup-environment/"
    click DataTasks "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/tasks/export-data/,src/tasks/import-data/"
    click SecurityTasks "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/tasks/set-governance-config/,src/tasks/assign-user/,src/tasks/assign-group/"
    click PortalTasks "https://github.com/microsoft/powerplatform-build-tools/tree/main/src/tasks/upload-paportal/,src/tasks/download-paportal/"
    click ADO "https://github.com/microsoft/powerplatform-build-tools/blob/main/.azure-pipelines/OfficialBuild.yml"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Task Implementation"]:::task
        L3["External Service"]:::external
        L4["Authentication Component"]:::auth
        L5["Utility Component"]:::util
    end
```
