# tinestaric/bcexamples architecture

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

- Interactive diagram: https://gitdiagram.com/tinestaric/bcexamples
- Repository: https://github.com/tinestaric/bcexamples

## Overview

##### Project type and purpose
- This repository (“BCExamples”) is a collection of Microsoft Dynamics 365 Business Central (BC) AL-based extension samples. Each top-level folder (e.g. CallApiWithUserPool, ScheduleJobsAsS2S, SecureEndpoints, etc.) is a standalone AL extension demonstrating a particular BC feature or integration (OAuth2, job scheduling, custom API pages, event subscribers, formula parsing, etc.).
- The README simply labels the repo “BCExamples,” confirming it’s a set of illustrative modules rather than a single monolithic application.

##### File structure
- Top-level directories:
- CallApiWithUserPool, InsertLockTimeouts, PreprocessingSymbolCleanup (PowerShell script), ScheduleJobsAsS2S, SecureEndpoints, StringFormulaCalculator, TriggerLogger.
- Each AL project has an app.json, .al code files under /src or root, and in some cases PermissionSets.
- Patterns & architectural hints:
- “src/API” folders ⇒ custom API pages/codeunits.
- “JobQueue” folder ⇒ use of BC’s job queue.
- OAuth2 and TokenGetter subfolders ⇒ pluggable authentication providers.
- TriggerLogger uses subscriber codeunits to log database changes (event-driven pattern).
- Build/deploy artifacts:
- PowerShell scripts (PreprocessingSymbolCleanup.ps1, BCPTRunner.ps1) ⇒ automation of symbol cleanup or BC container deployment.
- .csproj and .cs files in CallApiWithUserPool ⇒ a small C# console app invoking BC web services using a user pool.

##### Detail without over-splitting
- Inside each, list primary object types (e.g. Codeunits, Pages, Tables, Interfaces) only if space allows
- Patterns: event subscriptions, interface-based providers, job queue scheduling
- Keep the focus on how code travels from developer machine to BC runtime, and how BC interacts internally (DB, subscribers, job queue) and externally (OAuth2, REST).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer and Toolchain
    Developer["Developer Toolchain\n(VS Code + AL Extension)"]:::frontend
    ALCompiler["AL Compiler"]:::frontend

    %% Repository and Modules
    Repo["BCExamples Repository"]:::repo

    subgraph "BCExamples Repository"
        CallApiWithUserPool["CallApiWithUserPool"]:::module
        subgraph "CallApiWithUserPool Files"
            ProgramCS["Program.cs"]:::file
            ApiServiceCS["ApiService.cs"]:::file
        end

        InsertLockTimeouts["InsertLockTimeouts"]:::module
        subgraph "InsertLockTimeouts Files"
            ILAppJson["app.json"]:::file
            BCPTRunner["BCPTRunner.ps1"]:::scripts
            EntryEnum["EntryType.Enum.al"]:::file
        end

        Preprocessing["PreprocessingSymbolCleanup.ps1"]:::scripts

        ScheduleJobsAsS2S["ScheduleJobsAsS2S"]:::module

        SecureEndpoints["SecureEndpoints"]:::module

        StringFormulaCalculator["StringFormulaCalculator"]:::module

        TriggerLoggerCore["TriggerLogger Core"]:::module
        TriggerLoggerExt["TriggerLogger Extension"]:::module
    end

    %% Build Artifacts and Deployment
    PowerShellScripts["PowerShell Deployment\nScripts"]:::scripts
    AppPackages[".app Packages"]:::artifact

    %% Runtime Infrastructure
    BCContainer["Business Central\nContainer/Runtime"]:::infra
    SQLDB["SQL Server Database"]:::infra

    %% External Services
    OAuth2Providers["OAuth2 Providers\n(Azure AD, Facebook)"]:::external
    ExternalAPIs["External REST APIs"]:::external

    %% Connections
    Developer --> ALCompiler
    Repo --> ALCompiler
    Repo --> PowerShellScripts
    ALCompiler --> AppPackages
    PowerShellScripts --> BCContainer
    AppPackages --> BCContainer
    BCContainer --> SQLDB
    BCContainer -->|OAuth2 Auth Calls| OAuth2Providers
    BCContainer -->|API Calls| ExternalAPIs

    %% Module Integration with BCContainer
    CallApiWithUserPool --> BCContainer
    InsertLockTimeouts --> BCContainer
    Preprocessing --> ALCompiler
    ScheduleJobsAsS2S --> BCContainer
    SecureEndpoints --> BCContainer
    StringFormulaCalculator --> BCContainer
    TriggerLoggerCore --> BCContainer
    TriggerLoggerExt --> BCContainer

    %% Click Events
    click CallApiWithUserPool "https://github.com/tinestaric/bcexamples/tree/Master/CallApiWithUserPool/"
    click ProgramCS "https://github.com/tinestaric/bcexamples/blob/Master/CallApiWithUserPool/Program.cs"
    click ApiServiceCS "https://github.com/tinestaric/bcexamples/blob/Master/CallApiWithUserPool/ApiService.cs"
    click InsertLockTimeouts "https://github.com/tinestaric/bcexamples/tree/Master/InsertLockTimeouts/"
    click ILAppJson "https://github.com/tinestaric/bcexamples/blob/Master/InsertLockTimeouts/app.json"
    click BCPTRunner "https://github.com/tinestaric/bcexamples/blob/Master/InsertLockTimeouts/BCPTRunner.ps1"
    click Preprocessing "https://github.com/tinestaric/bcexamples/blob/Master/PreprocessingSymbolCleanup/PreprocessingSymbolCleanup.ps1"
    click ScheduleJobsAsS2S "https://github.com/tinestaric/bcexamples/tree/Master/ScheduleJobsAsS2S/"
    click SecureEndpoints "https://github.com/tinestaric/bcexamples/tree/Master/SecureEndpoints/"
    click StringFormulaCalculator "https://github.com/tinestaric/bcexamples/tree/Master/StringFormulaCalculator/"
    click TriggerLoggerCore "https://github.com/tinestaric/bcexamples/tree/Master/TriggerLogger/Core/"
    click TriggerLoggerExt "https://github.com/tinestaric/bcexamples/tree/Master/TriggerLogger/Extension/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef repo fill:#E0FFFF,stroke:#000,stroke-width:1px
    classDef module fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef file fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef scripts fill:#FFFFE0,stroke:#000,stroke-width:1px
    classDef artifact fill:#FFB6C1,stroke:#000,stroke-width:1px
    classDef infra fill:#A9A9A9,stroke:#000,stroke-width:1px
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px
```
