# parreirao2/power-bi-tools architecture

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

- Interactive diagram: https://gitdiagram.com/parreirao2/power-bi-tools
- Repository: https://github.com/parreirao2/power-bi-tools

## Overview

##### Project Type and Purpose
- This repository is not a single monolith but a collection of four standalone desktop utilities and one C# script tool, each designed for specific data‐centric tasks:
- PageSwitcher: a Power BI (.pbix) page‐management GUI.
- InfoHelper: a C# Tabular Editor macro for column profiling.
- Sample Generator + SQL Tools: a PyQt5 GUI for SQL analysis, CSV sample generation, and CREATE TABLE generation.
- Excel Validator: a Python GUI that validates batches of CSV/Excel files against a template.
- Each Python‐based tool is packaged into an .exe via PyInstaller; InfoHelper is a .csx script loaded at runtime by Tabular Editor.

##### File Structure Analysis
- Top‐level folders:
- Excel Validator/
- InfoHelper/
- Page Editor/ (contains PageSwitcher)
- Sample Generator + SQL Tools/
- assets/ (shared README images, GIFs)
- README.md
- `.py` or GUI script files
- `.spec` files (PyInstaller build configs)
- `build/…` subfolders containing the packaged executables, local Python libraries, and Tcl/Tk files for GUI.
- InfoHelper consists of a single `.csx` script—no build folder—as it runs inside Tabular Editor’s C# Scripting host.

##### README Insights
- Each project section details its features, GUI flows (with animated GIFs), how it interacts with files (PBIX, CSV, Excel), and dependencies:
- Python 3.x, PySimpleGUI or PyQt5, Pandas, Faker, regex, Matplotlib.
- Tabular Editor’s scripting engine and DAX for InfoHelper.

##### Main Components & Interactions
A. PageSwitcher (Python + PySimpleGUI)
- UI Layer: menus, pop-ups for page/visual edits
- Logic Layer: PBIX parsing, JSON manipulation
- File I/O: reads .pbix, writes new .pbix versions
B. Sample Generator + SQL Tools (Python + PyQt5)
- UI Layer: forms for word search, CSV generation, file upload
- Logic Layer: regex word finder, Faker data generator, CSV analyzer → CREATE TABLE DDL
- File I/O: reads/writes CSV, produces SQL scripts
C. Excel Validator (Python + PySimpleGUI)
- UI Layer: folder & template selectors, progress bar
- Logic Layer: Pandas validation engine, Matplotlib graphing
- File I/O: reads CSVs, template .xlsx, writes multi-sheet analysis .xlsx
D. InfoHelper (C# script)
- Runtime: Tabular Editor host
- Logic Layer: inspects selected Tabular model column, generates DAX measures
- UI: Tabular Editor pop-up output window
- Shared Runtime Environment
- Python 3 Interpreter + Embedded stdlib (via PyInstaller) + Tcl/Tk (for GUIs)
- .NET CLR hosting InfoHelper.

##### Architectural Patterns
- Each tool follows a simple two-layer pattern: UI Layer (GUI toolkit) ↔ Business Logic Layer
- File‐system boundary: all file inputs/outputs are via local FS (no network or DB).
- Packaging pipeline: source `→` PyInstaller (.spec) build `→` single‐folder exe distribution.

##### Essential Elements
- Clear labels: tool name, UI vs. logic, packaging.
- Rounded rectangles for GUIs
- Rectangles for processing modules
- Parallelogram for the build pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% PageSwitcher Tool
    subgraph "PageSwitcher" 
        PS_UI["UI Layer\n(PySimpleGUI)"]:::tool1
        PS_Logic["Logic Layer\n(PBIX parsing, JSON)"]:::tool1
        PS_UI -->|"user action"| PS_Logic
        PS_Logic -->|read/write| FS
        PS_Bundle["Bundle\n(build/PageSwitcher_6/)"]:::bundle
        PS_Logic --> PS_Bundle
        PS_Exec["Executable\nPageSwitcher.exe"]:::exe
        PS_Bundle --> PS_Exec
        PS_Spec["PyInstaller Spec\nPageSwitcher.spec"]:::spec
    end

    %% Sample Generator + SQL Tools
    subgraph "Sample Generator + SQL Tools"
        SG_UI["UI Layer\n(PyQt5)"]:::tool2
        SG_Logic["Logic Layer\n(regex, Faker, CSV analyzer)"]:::tool2
        SG_UI -->|"user action"| SG_Logic
        SG_Logic -->|read/write| FS
        SG_Bundle["Internal Runtime\n(_internal/)"]:::bundle
        SG_Logic --> SG_Bundle
        SG_Main["Python Script\nSQL_Tools.py"]:::spec
        SG_Bundle --> SG_Main
        SG_Exec["Executable\nSQL_Tools.exe"]:::exe
        SG_Bundle --> SG_Exec
    end

    %% Excel Validator
    subgraph "Excel Validator"
        EV_UI["UI Layer\n(PySimpleGUI)"]:::tool3
        EV_Logic["Logic Layer\n(Pandas, Matplotlib)"]:::tool3
        EV_UI -->|"user action"| EV_Logic
        EV_Logic -->|read/write| FS
        EV_Bundle["Bundle\n(build/ExcelValidator2/)"]:::bundle
        EV_Logic --> EV_Bundle
        EV_Exec["Executable\nExcelValidator2.exe"]:::exe
        EV_Bundle --> EV_Exec
        EV_Spec["PyInstaller Spec\nExcelValidator2.spec"]:::spec
    end

    %% InfoHelper Tool
    subgraph "InfoHelper"
        IH_CSX["C# Script\nInfoHelper.csx\n(.csx + DAX)"]:::tool4
    end
    TE["Tabular Editor Host"]:::host
    TE -->|"load script"| IH_CSX
    IH_CSX -->|"output DAX measures"| TE

    %% Shared Runtime
    Runtime["Python Runtime\n(Python 3, stdlib, Tcl/Tk)"]:::runtime
    PS_Exec --> Runtime
    SG_Exec --> Runtime
    EV_Exec --> Runtime

    %% Local File System
    FS["Local File System"]:::fs

    %% Packaging Pipeline
    subgraph "Build Pipeline"
        SRC1["Source\n(python/.csx)"]:::pipeline
        SPEC1["PyInstaller Spec\n(.spec)"]:::pipeline
        BLD["PyInstaller Build\n→ bundle"]:::pipeline
        EXE1["Distribution\n(exe)"]:::pipeline
        SRC1 --> SPEC1 --> BLD --> EXE1
    end

    %% Click Events
    click PS_Exec "https://github.com/parreirao2/power-bi-tools/blob/main/Page Editor/PageSwitcher.exe"
    click PS_Spec "https://github.com/parreirao2/power-bi-tools/blob/main/Page Editor/PageSwitcher.spec"
    click PS_Bundle "https://github.com/parreirao2/power-bi-tools/tree/main/Page Editor/build/PageSwitcher_6/"
    click IH_CSX "https://github.com/parreirao2/power-bi-tools/blob/main/InfoHelper/InfoHelper.csx"
    click SG_Main "https://github.com/parreirao2/power-bi-tools/blob/main/Sample Generator + SQL Tools/Python Script/SQL_Tools.py"
    click SG_Exec "https://github.com/parreirao2/power-bi-tools/blob/main/Sample Generator + SQL Tools/SQL_Tools.exe"
    click SG_Bundle "https://github.com/parreirao2/power-bi-tools/tree/main/Sample Generator + SQL Tools/_internal/"
    click EV_Exec "https://github.com/parreirao2/power-bi-tools/blob/main/Excel Validator/ExcelValidator2.exe"
    click EV_Spec "https://github.com/parreirao2/power-bi-tools/blob/main/Excel Validator/ExcelValidator2.spec"
    click EV_Bundle "https://github.com/parreirao2/power-bi-tools/tree/main/Excel Validator/build/ExcelValidator2/"

    %% Styles
    classDef tool1 fill:#ffdddd,stroke:#ff0000,stroke-width:2px
    classDef tool2 fill:#ddffdd,stroke:#00aa00,stroke-width:2px
    classDef tool3 fill:#ddddff,stroke:#0000ff,stroke-width:2px
    classDef tool4 fill:#fff0aa,stroke:#ffaa00,stroke-width:2px
    classDef bundle fill:#f0f0f0,stroke:#888888,stroke-width:1px,stroke-dasharray: 5 5
    classDef exe fill:#ffeeee,stroke:#dd0000,stroke-width:1px
    classDef spec fill:#eeffee,stroke:#00dd00,stroke-width:1px
    classDef fs fill:#ffffcc,stroke:#999900,stroke-width:2px
    classDef runtime fill:#f5f5f5,stroke:#666666,stroke-width:2px
    classDef host fill:#e0e0e0,stroke:#333333,stroke-width:2px
    classDef pipeline fill:#fdf6e3,stroke:#b58900,stroke-width:1px,stroke-dasharray: 2 2
```
