# jamessimone/apex-rollup architecture

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

- Interactive diagram: https://gitdiagram.com/jamessimone/apex-rollup
- Repository: https://github.com/jamessimone/apex-rollup

## Overview

##### Project type and purpose
- This is an open-source Salesforce package (“Apex Rollup”) delivered as an SFDX project.
- Purpose: Provide a metadata-driven engine for custom rollup summaries across any SObject, invoked by Apex triggers, Flows, LWC buttons, or scheduled jobs, with extensible plugins and asynchronous processing.

##### File structure
- Top level:
- .github, workflows & config → CI/CD and lint rules
- scripts → build, conversion, test helpers
- extra-tests → supplemental Apex tests and sample metadata
- plugins → optional RollupLogger, RollupCallback, ExtraCodeCoverage
- rollup-namespaced → namespaced SFDX packaging variations
- rollup/
– app → LWC components, flexipage, permission sets (UI layer)
– core → Apex “engine” classes under classes/, custom metadata under customMetadata/, CMDT-defined objects under objects/, supporting DWL mappings
- Key patterns:
- “core” contains engine logic (Rollup.cls and sub-classes)
- “app” houses UI entry points (quick-action LWC, permission sets)
- triggers call Rollup.runFromTrigger() in core
- flows use @Invocable methods in core
- custom metadata types (Rollup__mdt, RollupOrderBy__mdt, RollupControl__mdt, RollupPluginParameter__mdt) define behavior

##### README for additional insights
- Execution contexts: Apex triggers, Change Data Capture triggers, Flows, Scheduled jobs, LWC quick action
- Architectural features: metadata-driven configuration, plugin interface, asynchronous processing (Queueable/Batchable), full-recalc UI

##### Detail requirements
- Key invocation points and data-flow loops.
- Engine’s dependency on Custom Metadata for runtime behavior.
- How plugins hook into the engine.
- Do not oversimplify—include separate circles for major engine classes (e.g., RollupAsyncProcessor, RollupScheduler) if desired for clarity.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Infrastructure & CI/CD"
        DevCI("Developer & CI/CD"):::infra
        Repo("Source Code Repository (SFDX)"):::infra
        Struct("SFDX Project Structure"):::infra
    end
    DevCI --> Repo
    Repo --> Struct
    click DevCI "https://github.com/jamessimone/apex-rollup/blob/main/.github/workflows/deploy.yml"
    click Repo "https://github.com/jamessimone/apex-rollup/blob/main/sfdx-project.json"
    click Struct "https://github.com/jamessimone/apex-rollup/tree/main/rollup/"

    subgraph "Salesforce Org"
        subgraph "UI & Orchestration"
            LWC1("recalculateParentRollupFlexipage"):::ui
            LWC2("recalculateParentRollupQuickAction"):::ui
            LWC3("rollupForceRecalculation"):::ui
            LWC4("rollupOrderBy"):::ui
            LWC5("rollupUtils"):::ui
            PS1("See_Rollup_App Permissions"):::ui
            PS2("See_Rollup_Button Permissions"):::ui
            TAB1("Recalculate_Rollup Tab"):::ui
            TAB2("RollupState__c Tab"):::ui
            Trigger("Apex Triggers"):::ui
            Flow("Flow Invocable Actions"):::ui
            Scheduler("Scheduled Jobs"):::ui
        end

        subgraph "Core Processing"
            Engine("Rollup Engine"):::core
            AsyncProc("RollupAsyncProcessor"):::core
            DefFull("RollupDeferredFullRecalcProcessor"):::core
            FlowRec("RollupFlowRecalculator"):::core
            FlowBulk("RollupFlowBulkProcessor"):::core
            SchedProc("RollupScheduler"):::core
            LoggerCls("RollupLogger"):::core
            PluginIF("RollupPlugin Interface"):::core
        end

        subgraph "Configuration Store"
            CMDT1("RollupControl.Org_Defaults"):::config
            CMDT2("RollupPlugin.RollupLogger"):::config
            CMDT3("RollupPluginParameter.LoggingDebugLevel"):::config
            ObjDefs("CMDT Object Definitions"):::config
        end

        subgraph "Plugins"
            Plug1("CustomObjectRollupLogger"):::core
            Plug2("NebulaLogger"):::core
            Plug3("RollupCallback"):::core
            Plug4("ExtraCodeCoverage"):::core
        end

        DataStore("Salesforce Data Store"):::data

        LWC1 --> Engine
        LWC2 --> Engine
        LWC3 --> Engine
        LWC4 --> Engine
        LWC5 --> Engine
        Trigger --> Engine
        Flow --> Engine
        Scheduler --> Engine

        Engine --> AsyncProc
        Engine --> DefFull
        Engine --> FlowRec
        Engine --> FlowBulk
        Engine --> SchedProc

        AsyncProc --> DataStore
        DefFull --> DataStore

        Engine --> CMDT1
        Engine --> CMDT2
        Engine --> CMDT3
        Engine --> ObjDefs

        Engine --> PluginIF
        PluginIF --> Plug1
        PluginIF --> Plug2
        PluginIF --> Plug3
        PluginIF --> Plug4

        Engine --> DataStore
    end

    click LWC1 "https://github.com/jamessimone/apex-rollup/tree/main/rollup/app/lwc/recalculateParentRollupFlexipage/"
    click LWC2 "https://github.com/jamessimone/apex-rollup/tree/main/rollup/app/lwc/recalculateParentRollupQuickAction/"
    click LWC3 "https://github.com/jamessimone/apex-rollup/tree/main/rollup/app/lwc/rollupForceRecalculation/"
    click LWC4 "https://github.com/jamessimone/apex-rollup/tree/main/rollup/app/lwc/rollupOrderBy/"
    click LWC5 "https://github.com/jamessimone/apex-rollup/tree/main/rollup/app/lwc/rollupUtils/"
    click PS1 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/app/permissionsets/See_Rollup_App.permissionset-meta.xml"
    click PS2 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/app/permissionsets/See_Rollup_Button.permissionset-meta.xml"
    click TAB1 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/app/tabs/Recalculate_Rollup.tab-meta.xml"
    click TAB2 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/app/tabs/RollupState__c.tab-meta.xml"
    click Engine "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/Rollup.cls"
    click AsyncProc "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupAsyncProcessor.cls"
    click DefFull "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupDeferredFullRecalcProcessor.cls"
    click FlowRec "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupFlowRecalculator.cls"
    click FlowBulk "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupFlowBulkProcessor.cls"
    click SchedProc "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupScheduler.cls"
    click LoggerCls "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupLogger.cls"
    click PluginIF "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupPlugin.cls"
    click CMDT1 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/customMetadata/RollupControl.Org_Defaults.md-meta.xml"
    click CMDT2 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/customMetadata/RollupPlugin.RollupLogger.md-meta.xml"
    click CMDT3 "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/customMetadata/RollupPluginParameter.LoggingDebugLevel.md-meta.xml"
    click ObjDefs "https://github.com/jamessimone/apex-rollup/tree/main/rollup/core/objects/Rollup__mdt/"
    click Plug1 "https://github.com/jamessimone/apex-rollup/tree/main/plugins/CustomObjectRollupLogger/"
    click Plug2 "https://github.com/jamessimone/apex-rollup/tree/main/plugins/NebulaLogger/"
    click Plug3 "https://github.com/jamessimone/apex-rollup/tree/main/plugins/RollupCallback/"
    click Plug4 "https://github.com/jamessimone/apex-rollup/tree/main/plugins/ExtraCodeCoverage/"
    click Scheduler "https://github.com/jamessimone/apex-rollup/blob/main/rollup/core/classes/RollupSchedulable.cls"

    classDef infra fill:#DDA0DD,stroke:#333,stroke-width:1px;
    classDef ui fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef core fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef config fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef data fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
