# coolorangelabs/powerloadpublic architecture

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

- Interactive diagram: https://gitdiagram.com/coolorangelabs/powerloadpublic
- Repository: https://github.com/coolorangelabs/powerloadpublic

## Overview

##### Project Type and Purpose
- This is a PowerShell extension (a PowerShell module) named **powerLoad**.
- Purpose: automate data-loading workflows into Autodesk Vault using the DTU/BCP toolkit, with an intermediate SQL Server “powerLoad” database for high-speed manipulation, validation, and packaging into BCP files.

##### Main Components
a. PowerShell Client Layer
- PowerShell console or script (.ps1) that imports **powerload.dll** and invokes CmdLets.
- Sample scripts live under `Samples/`.
b. Business Logic Layer (CmdLets Module)
- `powerload.dll` exposes CmdLets (Connect-PowerLoadDatabase, Import-BCP, Import-FilesToDatabase, Resolve-AutoCadReferences, Resolve-InventorReferences, Test-PowerLoadDatabase, Test-PowerLoadVaultBehaviors, Export-BCP, plus UDP management).
- Underlying .NET code orchestrates ETL, SQL operations, Vault API calls, and BCP toolkit calls.
c. Data Layer
- **powerLoad Database** on MS SQL Server 2017+ – a temporary relational store for imported Vault data, file metadata, user-defined properties, reference-resolution results.
d. External Systems
- **Autodesk Vault Server**: target system for final DTU/BCP packages and for validation via Vault behaviors.
- **BCP Toolkit** (coolOrange powerLoad/bcpToolkit): external library/CLI used to import/export BCP packages.
- **File System**: source files for import, Inventor project files for reference resolution, output directory for BCP packages and error CSVs.
- **AutoCAD/Inventor** processes: external executables/libraries invoked by Resolve-AutoCadReferences and Resolve-InventorReferences to check file references.

##### Relationships and Data Flows
- CmdLets communicate with SQL Server to create/alter/read temp tables.
- When importing Vault data: CmdLet → Vault API → retrieves data → writes to SQL Server.
- When importing files: CmdLet → reads file system → writes metadata/blobs to SQL Server.
- Reference checks: CmdLet → AutoCAD/Inventor APIs → results back into SQL Server or CSV.
- Validation: CmdLet → queries target Vault (Vault behaviors) → errors to CSV.
- Export: CmdLet → BCP toolkit → reads SQL Server → generates DTU/BCP packages to file system.

##### Architectural Patterns and Design Principles
- Layered Architecture: CLI layer, business logic (.NET CmdLets), data persistence (SQL), external integration.
- ETL Pattern: Extract (Vault, file system), Transform (SQL operations, reference resolution), Load (BCP package).
- Modular: each CmdLet focuses on a single responsibility (connect, import, validate, export).
- Extensibility: new CmdLets can be added.
- Error handling via standardized CSV exports for each step.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% PowerShell Client Layer
    subgraph "PowerShell Client Layer"
        PS["PowerShell Host / Script"]:::internal
        subgraph "Sample Scripts"
            S1["Get-Data-From-Vault-Search.ps1"]:::internal
            S2["Import-From-File-System.ps1"]:::internal
            S3["powerLoad-sample-ImportFromFileSystem.ps1"]:::internal
            S4["powerLoad-sample-Load-BCP.ps1"]:::internal
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        CmdLets["powerload.dll (CmdLets Module)"]:::internal
        subgraph "CmdLets Documentation"
            D1["Connect-PowerLoadDatabase.md"]:::internal
            D2["Import-BCP.md"]:::internal
            D3["Import-FilesToDatabase.md"]:::internal
            D4["Resolve-AutoCadReferences.md"]:::internal
            D5["Resolve-InventorReferences.md"]:::internal
            D6["Test-PowerLoadDataBase.md"]:::internal
            D7["Test-PowerLoadVaultBehaviors.md"]:::internal
            D8["Export-BCP.md"]:::internal
            D9["Add-PowerLoadUDP.md"]:::internal
            D10["Remove-PowerLoadUDP.md"]:::internal
            D11["Rename-PowerLoadUDP.md"]:::internal
            D12["Invoke-PowerLoadSql.md"]:::internal
            D13["Get-VaultData.md"]:::internal
        end
    end

    %% CI / Docs Workflow
    subgraph "CI / Documentation Workflow"
        CI1["main.yml"]:::internal
        CI2["onlyDocu.yml"]:::internal
        CI3["test.yml"]:::internal
    end

    %% Project Overview
    README["README.md"]:::internal

    %% Data & External Systems
    subgraph "Data & External Systems"
        DB[(powerLoad DB)]:::db
        Vault["Autodesk Vault Server"]:::external
        BCP["BCP Toolkit"]:::external
        FS["File System"]:::external
        CAD["AutoCAD/Inventor Engines"]:::external
    end

    %% Interactions
    S1 -->|"loads DLL"| CmdLets
    S2 -->|"loads DLL"| CmdLets
    S3 -->|"loads DLL"| CmdLets
    S4 -->|"loads DLL"| CmdLets
    PS -->|"executes script"| S1

    CmdLets -->|"Connect-PowerLoadDatabase"| DB
    CmdLets -->|"Get-VaultData"| Vault
    Vault -->|"Vault Data"| DB
    CmdLets -->|"Import-FilesToDatabase"| FS
    FS -->|"File Metadata/Blobs"| DB
    CmdLets -->|"Resolve-References"| CAD
    CAD -->|"Reference Results"| DB
    CmdLets -->|"Test-PowerLoadVaultBehaviors"| Vault
    CmdLets -->|"Test-PowerLoadDataBase"| DB
    CmdLets -->|"Export-BCP"| BCP
    BCP -->|"BCP Packages"| FS

    %% Click Events
    click S1 "https://github.com/coolorangelabs/powerloadpublic/blob/main/Samples/Get-Data-From-Vault-Search.ps1"
    click S2 "https://github.com/coolorangelabs/powerloadpublic/blob/main/Samples/Import-From-File-System.ps1"
    click S3 "https://github.com/coolorangelabs/powerloadpublic/blob/main/Samples/powerLoad-sample-ImportFromFileSystem.ps1"
    click S4 "https://github.com/coolorangelabs/powerloadpublic/blob/main/Samples/powerLoad-sample-Load-BCP.ps1"

    click D1 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Connect-PowerLoadDatabase.md"
    click D2 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Import-BCP.md"
    click D3 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Import-FilesToDatabase.md"
    click D4 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Resolve-AutoCadReferences.md"
    click D5 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Resolve-InventorReferences.md"
    click D6 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Test-PowerLoadDataBase.md"
    click D7 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Test-PowerLoadVaultBehaviors.md"
    click D8 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Export-BCP.md"
    click D9 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Add-PowerLoadUDP.md"
    click D10 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Remove-PowerLoadUDP.md"
    click D11 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Rename-PowerLoadUDP.md"
    click D12 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Invoke-PowerLoadSql.md"
    click D13 "https://github.com/coolorangelabs/powerloadpublic/blob/main/CmdLets/doc/Get-VaultData.md"

    click CI1 "https://github.com/coolorangelabs/powerloadpublic/blob/main/.github/workflows/main.yml"
    click CI2 "https://github.com/coolorangelabs/powerloadpublic/blob/main/.github/workflows/onlyDocu.yml"
    click CI3 "https://github.com/coolorangelabs/powerloadpublic/blob/main/.github/workflows/test.yml"

    click README "https://github.com/coolorangelabs/powerloadpublic/blob/main/README.md"

    %% Styles
    classDef internal fill:#E0F7FA,stroke:#0288D1,color:#000;
    classDef external fill:#E8F5E9,stroke:#388E3C,color:#000;
    classDef db fill:#FFF176,stroke:#F57F17,color:#000;
```
