# lagoesp/lowcodebutton architecture

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

- Interactive diagram: https://gitdiagram.com/lagoesp/lowcodebutton
- Repository: https://github.com/lagoesp/lowcodebutton

## Overview

##### Project Type & Purpose
- This project is a specialized Dynamics 365 extension (managed solution), designed to allow custom button integration into Dynamics environments.
- It enables developers and Dynamics customizers to register buttons, configure advanced settings, and tailor the payloads sent during user interactions (for forms, grids, and subgrids).
- The project bundles both TypeScript source code (in the src folder) and ready-to-deploy JavaScript assets (in the dist folder) along with generated metadata from Dataverse entities.

- User Interface Integration:
- Dynamics 365 Command Bar Designer / Ribbon Workbench: This is where the registered button is exposed to users.
- LowCodeButtonBase.js is the core JavaScript resource referenced in Dynamics that triggers the button click.

- Application Core (under src):
- Base Cases (src/Base_Cases): Contains base implementations to support different types of buttons (Form and Grid scenarios).
- Helpers (src/Helpers): Includes functions to prepare payloads and assist with form/grid related logic (e.g., ButtonFormHelper, ButtonGridHelper).
- Exceptions (src/Exceptions): Contains exception handling logic specific to button operations.
- Models (src/Models): Defines data structures and response models for button interactions.

- Dataverse Integration:
- dataverse-gen (src/dataverse-gen): Houses generated code for Dynamics metadata, including entities and enums. This module represents how the managed solution interacts with Dynamics data definitions.

- Build & Deployment:
- Webpack configuration files (webpack.common.js, webpack.dev.js, webpack.prod.js) along with tsconfig.json guide the build process from TypeScript source into distributable JavaScript (dist folder).
- The configuration files and package.json ensure consistency for deployment into the Dynamics environment.

- Supporting Artifacts:
- DataStructure folder: Contains additional supporting documentation (e.g., ERD text file, LCID Excel list) which provides reference data and design documents.

##### Visualizing Relationships & Interactions
- From user interactions on the Dynamics 365 UI to the registered JavaScript function (LowCodeButtonBase).
- From LowCodeButtonBase to specialized base cases (Form, Grid, Subgrid) that handle the event based on the type.

##### Architectural Patterns & Technologies
- The project follows a modular pattern:
- Separation of concerns by splitting logical functionality into Base Cases, Helpers, Exceptions, and Models.
- Clear division between design-time (source and build configuration) and deployment-time (dist folder used by Dynamics).
- Technology labels such as:
- TypeScript for the core logic.
- Webpack for bundling assets.
- Dynamics 365 integration via Command Bar Designer / Ribbon Workbench.
- Dataverse (MS Dynamics) metadata, represented in the generated dataverse-gen folder.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Components
    UI["Dynamics 365 UI"]:::external
    Ribbon["Command Bar Designer / Ribbon Workbench"]:::external

    %% Web Resource deployed to Dynamics (dist)
    LowCodeButtonBase["LowCodeButtonBase"]:::app

    %% Application Core (src Modules)
    subgraph "Application Core"
        FormBase["Base_Cases - Form"]:::app
        GridBase["Base_Cases - Grid"]:::app
        ButtonFormHelper["Helpers - ButtonFormHelper"]:::helper
        ButtonGridHelper["Helpers - ButtonGridHelper"]:::helper
        BaseHelper["Helpers - BaseHelper"]:::helper
        ButtonException["Exceptions - ButtonException"]:::app
        Models["Models - BaseButtonResponseModels"]:::app
        Dataverse["Dataverse Integration"]:::integration
    end

    %% Build & Deployment Configuration
    subgraph "Build & Deployment"
        WebpackCommon["Webpack Common"]:::build
        WebpackDev["Webpack Dev"]:::build
        WebpackProd["Webpack Prod"]:::build
        TSConfig["TS Config"]:::build
        PackageJson["Package Config"]:::build
        BuildProcess["Build/Compile Process"]:::build
    end

    %% Supporting Artifacts
    Artifacts["DataStructure (Artifacts)"]:::artifact

    %% Connections
    UI --> Ribbon
    Ribbon --> LowCodeButtonBase

    LowCodeButtonBase --> FormBase
    LowCodeButtonBase --> GridBase

    FormBase -->|"uses"| ButtonFormHelper
    GridBase -->|"uses"| ButtonGridHelper

    ButtonFormHelper --> BaseHelper
    ButtonGridHelper --> BaseHelper

    BaseHelper --> Models

    FormBase -->|"metadata"| Dataverse
    GridBase -->|"metadata"| Dataverse

    %% Build process arrows
    WebpackCommon --> BuildProcess
    WebpackDev --> BuildProcess
    WebpackProd --> BuildProcess
    TSConfig --> BuildProcess
    PackageJson --> BuildProcess
    BuildProcess -->|"build/compile"| LowCodeButtonBase

    %% Class Definitions for Colors
    classDef external fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
    classDef app fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef helper fill:#ffe599,stroke:#b45f06,stroke-width:2px;
    classDef build fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef integration fill:#cfe2f3,stroke:#1155cc,stroke-width:2px;
    classDef artifact fill:#ead1dc,stroke:#b854a4,stroke-width:2px;

    %% Click Events
    click LowCodeButtonBase "https://github.com/lagoesp/lowcodebutton/blob/main/dist/LowCodeButtonBase.js"
    click FormBase "https://github.com/lagoesp/lowcodebutton/blob/main/src/Base_Cases/LowCodeButtonFormBase.ts"
    click GridBase "https://github.com/lagoesp/lowcodebutton/blob/main/src/Base_Cases/LowCodeButtonGridBase.ts"
    click ButtonFormHelper "https://github.com/lagoesp/lowcodebutton/blob/main/src/Helpers/ButtonFormHelper.ts"
    click ButtonGridHelper "https://github.com/lagoesp/lowcodebutton/blob/main/src/Helpers/ButtonGridHelper.ts"
    click BaseHelper "https://github.com/lagoesp/lowcodebutton/blob/main/src/Helpers/BaseHelper.ts"
    click ButtonException "https://github.com/lagoesp/lowcodebutton/blob/main/src/Exceptions/ButtonException.ts"
    click Models "https://github.com/lagoesp/lowcodebutton/blob/main/src/Models/BaseButtonResponseModels.ts"
    click Dataverse "https://github.com/lagoesp/lowcodebutton/tree/main/src/dataverse-gen"
    click WebpackCommon "https://github.com/lagoesp/lowcodebutton/blob/main/webpack.common.js"
    click WebpackDev "https://github.com/lagoesp/lowcodebutton/blob/main/webpack.dev.js"
    click WebpackProd "https://github.com/lagoesp/lowcodebutton/blob/main/webpack.prod.js"
    click TSConfig "https://github.com/lagoesp/lowcodebutton/blob/main/tsconfig.json"
    click PackageJson "https://github.com/lagoesp/lowcodebutton/blob/main/package.json"
    click Artifacts "https://github.com/lagoesp/lowcodebutton/tree/main/DataStructure"
```
