# microsoft/powerbi-visuals-tools architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/powerbi-visuals-tools
- Repository: https://github.com/microsoft/powerbi-visuals-tools

## Overview

##### Main Components
- CLI Interface Layer:
– Represented by the executable script in the “bin” directory (bin/pbiviz.js).
– This is the main entry point that accepts user commands and orchestrates further actions.

- Core Engine/Modules (src Directory):
– Modules like CommandManager, VisualManager, FeatureManager, Package, and TemplateFetcher form the core of the tool’s functionality.
– Their responsibilities include processing CLI commands, managing visual project generation, handling TypeScript and Less compilation, certificate handling, and packaging.

- Feature Modules (src/features):
– A series of modules are dedicated to individual features (e.g., AdvancedEditMode, DrillDown, Bookmarks, etc.).
– These are plug-ins or extensions that provide specific functionality for PowerBI visuals.

- Template Management (templates Directory):
– This directory supplies various templates (default, rhtml, rvisual, slicer, table) that are used to scaffold new visual projects.
– Show how the TemplateFetcher pulls in the relevant templates for generating project code.

- Build and Configuration:
– Files like webpack.config.ts, tsconfig.json, and config.json indicate that the project uses a TypeScript/webpack based build process.
– This layer also includes ESLint configuration files (e.g., .eslintrc.json, eslint.config.mjs) which affect code quality.

- Testing and Continuous Integration:
– The “spec” directory contains both end-to-end (e2e) and unit tests, along with helper utilities.
– The .github folder (and the workflows within it) represents CI/CD pipelines for build, code analysis, and releases.

- Assets & Documentation:
– Assets (logos etc.) and documentation files (README, CONTRIBUTING, Changelog, etc.) support project maintenance and user adoption.

##### Determining Relationships and Interactions
- The CLI layer (pbiviz.js) parses user commands and passes instructions to the CommandManager module.
- The CommandManager interacts with other core modules (VisualManager, FeatureManager, Package, WebPackWrap) to perform tasks such as generating project files using templates or kicking off a build process.
- The TemplateFetcher pulls templates as needed from the “templates” directory, and these templates feed into how visuals are structured.
- During development, tests in the “spec” directory validate functionality, and CI workflows automatically trigger these tests.
- Build tools like webpack (configured by webpack.config.ts) and compiler settings (tsconfig.json) ensure proper code bundling and type-checking.
- External tools such as NodeJS (as a dependency) and NPM (for package management) set the runtime environment.

##### Architectural Patterns and Design Principles
- Modularity – The separation of concerns is visible through distinct modules for commands, visuals, and features.
- Plugin/Extension Model – The “src/features” directory suggests that the system is extensible, with each feature encapsulated in its own module.
- Template Driven – The “templates” directory drives project generation which is central to the tool’s functionality.
- Test Driven/Continuous Integration – The presence of dedicated test folders and CI/CD workflows indicates a robust development lifecycle is intended.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        cli["CLI Interface"]:::cli
    end

    %% Core Engine
    subgraph "Core Engine"
        cmd["Command Manager"]:::core
        vis["Visual Manager"]:::core
        feat["Feature Manager"]:::core
        pkg["Package Module"]:::core
        tempFetch["Template Fetcher"]:::core
        wb["Build Wrapper"]:::core
    end

    %% Feature Modules Plug-ins
    subgraph "Feature Modules"
        plug["Feature Modules Plug-ins"]:::feature
    end

    %% Template Management
    subgraph "Template Management"
        templMgmt["Template Management"]:::templ
    end

    %% Build & Configuration
    subgraph "Build & Configuration"
        tsconfig["tsconfig.json"]:::build
        webpack["webpack.config.ts"]:::build
        cfg["config.json"]:::build
        eslintrc[".eslintrc.json"]:::build
        eslintmjs["eslint.config.mjs"]:::build
    end

    %% Testing & CI/CD
    subgraph "Testing & CI/CD"
        testing["Testing (spec)"]:::test
        cicd["CI/CD (.github/workflows)"]:::test
    end

    %% Assets & Documentation
    subgraph "Assets & Documentation"
        assets["Assets"]:::assets
        readme["README.md"]:::assets
        contributing["CONTRIBUTING.md"]:::assets
        changelog["Changelog.md"]:::assets
        license["LICENSE"]:::assets
    end

    %% Connections
    cli -->|"parses"| cmd
    cmd -->|"delegates"| vis
    cmd -->|"delegates"| feat
    cmd -->|"delegates"| pkg
    cmd -->|"initiates"| tempFetch
    tempFetch -->|"retrieves"| templMgmt
    feat -->|"integrates"| plug
    cmd -->|"triggers_build"| wb
    wb -->|"uses"| tsconfig
    wb -->|"uses"| webpack
    wb -->|"uses"| cfg
    wb -->|"ensures_lint"| eslintrc
    wb -->|"ensures_lint"| eslintmjs
    cmd -->|"orchestrates"| wb
    pkg -->|"triggers_tests"| testing
    tsconfig -->|"informs"| testing
    webpack -->|"informs"| testing
    cicd -->|"runs_on_push"| pkg
    readme -->|"guides"| cmd

    %% Click Events
    click cli "https://github.com/microsoft/powerbi-visuals-tools/blob/main/bin/pbiviz.js"
    click cmd "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/CommandManager.ts"
    click vis "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/VisualManager.ts"
    click feat "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/FeatureManager.ts"
    click pkg "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/Package.ts"
    click tempFetch "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/TemplateFetcher.ts"
    click wb "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/WebPackWrap.ts"
    click tsconfig "https://github.com/microsoft/powerbi-visuals-tools/blob/main/tsconfig.json"
    click webpack "https://github.com/microsoft/powerbi-visuals-tools/blob/main/src/webpack.config.ts"
    click cfg "https://github.com/microsoft/powerbi-visuals-tools/blob/main/config.json"
    click eslintrc "https://github.com/microsoft/powerbi-visuals-tools/blob/main/.eslintrc.json"
    click eslintmjs "https://github.com/microsoft/powerbi-visuals-tools/blob/main/eslint.config.mjs"
    click plug "https://github.com/microsoft/powerbi-visuals-tools/tree/main/src/features"
    click templMgmt "https://github.com/microsoft/powerbi-visuals-tools/tree/main/templates"
    click testing "https://github.com/microsoft/powerbi-visuals-tools/tree/main/spec"
    click cicd "https://github.com/microsoft/powerbi-visuals-tools/tree/main/.github/workflows"
    click assets "https://github.com/microsoft/powerbi-visuals-tools/tree/main/assets"
    click readme "https://github.com/microsoft/powerbi-visuals-tools/blob/main/README.md"
    click contributing "https://github.com/microsoft/powerbi-visuals-tools/blob/main/CONTRIBUTING.md"
    click changelog "https://github.com/microsoft/powerbi-visuals-tools/blob/main/Changelog.md"
    click license "https://github.com/microsoft/powerbi-visuals-tools/tree/main/LICENSE"

    %% Styles
    classDef cli fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef feature fill:#bff,stroke:#333,stroke-width:2px;
    classDef templ fill:#ffe680,stroke:#333,stroke-width:2px;
    classDef build fill:#ffd699,stroke:#333,stroke-width:2px;
    classDef test fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef assets fill:#fff2cc,stroke:#333,stroke-width:2px;
    
    class cli cli;
    class cmd,vis,feat,pkg,tempFetch,wb core;
    class plug feature;
    class templMgmt templ;
    class tsconfig,webpack,cfg,eslintrc,eslintmjs build;
    class testing,cicd test;
    class assets,readme,contributing,changelog,license assets;
```
