# favdv/powerquery architecture

> Architecture diagram of the GitHub repository favdv/powerquery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/favdv/powerquery
- Repository: https://github.com/favdv/powerquery

## Overview

##### Project Type & Purpose
- This is an open-source utility repository focused on Power Query functions.
- Its main goal is to offer a set of reusable functions that enable Power BI developers to perform data transformations and manage queries easily.
- The repository allows both “bulk” processing (via Record.GetAllQueries.pt) as well as individual function usage by copying specific query code.

##### Key Components
- Query Registry Component:
- Main entry point “Record.GetAllQueries.pt” which aggregates or retrieves all available functions.
- That this component lists the functions and serves as the central registry for the query functions in the repo.
- Function Categories:
- Within this node, list the individual functions (e.g., Table.CombineData, Table.ConvertBase64, Table.ConvertColumnType, etc.), which are Power Query scripts (.pq) used for various table manipulations.
- Integration with Power BI:
- How a developer can copy the content from the repository and invoke them in a local Power BI environment through syntax like:
- Functions[Table.ExpandAllColumns](Source)
- Or calling the function by name if it was loaded into a blank query.

##### Architectural Relationships & Data Flow
- That the Query Registry component can interface with any additional utility modules (if present or planned for future expansion) to auto-update and maintain the function list.
- That each function is designed to work without modifications and readily integrates with the Power BI data refresh and auto-update mechanisms.

##### Architectural Patterns & Design Principles
- Modular Design:
- The functions are kept modular and classified into categories to quickly target transformations like API handling or data management.
- Extensibility:
- The structure suggests an easily extendible model where more directories/categories can be added to support additional types of queries.
- Revenue of Concerns:
- There is a clear separation between the orchestration component (the record getting all queries) and the individual processing functions contained within each category folder.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Power BI Environment"
        BI["Power BI Query Editor"]:::powerbi
    end

    subgraph "Library Components"
        REG["Query Registry (Record.GetAllQueries.pt)"]:::registry
        TF["Table Functions (Directory)"]:::directory
    end

    BI -->|"retrievesFunctions"| REG
    REG -->|"accesses"| TF

    subgraph "Table Functions List"
        direction TB
        COMB["Table.CombineData"]:::function
        CONV64["Table.ConvertBase64"]:::function
        CONVCT["Table.ConvertColumnType"]:::function
        EXP["Table.ExpandAllColumns"]:::function
        GETFN["Table.GetFieldNames"]:::function
        NESTTXT["Table.NestedDataToText"]:::function
        REMAP["Table.RemapColumns"]:::function
        REMEMPTY["Table.RemoveEmptyColumns"]:::function
        TEXTJSON["Table.TextToJson"]:::function
    end

    TF -->|"contains"| COMB
    TF -->|"contains"| CONV64
    TF -->|"contains"| CONVCT
    TF -->|"contains"| EXP
    TF -->|"contains"| GETFN
    TF -->|"contains"| NESTTXT
    TF -->|"contains"| REMAP
    TF -->|"contains"| REMEMPTY
    TF -->|"contains"| TEXTJSON

    click REG "https://github.com/favdv/powerquery/blob/main/Record.GetAllQueries.pt"
    click TF "https://github.com/favdv/powerquery/tree/main/Table Functions"
    click COMB "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.CombineData.pq"
    click CONV64 "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.ConvertBase64.pq"
    click CONVCT "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.ConvertColumnType.pq"
    click EXP "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.ExpandAllColumns.pq"
    click GETFN "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.GetFieldNames.pq"
    click NESTTXT "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.NestedDataToText.pq"
    click REMAP "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.RemapColumns.pq"
    click REMEMPTY "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.RemoveEmptyColumns.pq"
    click TEXTJSON "https://github.com/favdv/powerquery/blob/main/Table Functions/Table.TextToJson.pq"

    classDef registry fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef directory fill:#90be6d,stroke:#000,stroke-width:2px;
    classDef function fill:#f94144,stroke:#000,stroke-width:2px;
    classDef powerbi fill:#577590,stroke:#000,stroke-width:2px;
```
