# asuarezc/asc.utils.commander architecture

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

- Interactive diagram: https://gitdiagram.com/asuarezc/asc.utils.commander
- Repository: https://github.com/asuarezc/asc.utils.commander

## Overview

##### Domain Components
- Command Abstraction: Central to the architecture is the ICommand interface and its implementations (e.g., Command in the Implementation folder). This is the atomic “unit of work” with properties like a unique identifier, parameters, and the actual job (delegate) to execute.
- Command Builder: The ICommandBuilder and its fluent API implementation (e.g., CommandBuilder, CommandBuilderValidator) which help create commands by chaining method calls (setting job, success and failure delegates, and parameters).
- Command Processor: This orchestrates the execution of commands. There are two distinct implementations:
- Sequential Command Processor (SequentialCommandProcessor and its builder)
- Concurrent Command Processor (ConcurrentCommandProcessor and its builder)
- Delegates & Parameter Handling: Elements such as CommandDelegate, CommandParameter, and the ExceptionManager which take care of associated preparation and error handling.
- Commander Singleton: The high-level interface (ICommander) that the client code uses to obtain builders and processors.
- Utility and Validation Components: Supporting classes, validators and configuration objects (e.g., CommandProcessorConfiguration).

##### Relationships and Data Flow
- A client uses the Commander’s fluent builder methods (for either sequential or concurrent processors) to register pre-job, on-success, on-failure, and post-job delegates.
- The builder then produces a configured ICommandProcessor.
- When a command is created (via the Command Builder), all necessary attributes (identifier, job, success/failure handlers, and parameters) are set.
- The processors (whether sequential or concurrent) receive these command objects and execute the job along with the before/after hooks.
- Error handling is unified through the on-failure delegates which address both specific and generic exceptions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Interaction Layer
    subgraph "Client Interaction Layer"
        A["Commander"]:::commander
        B["Command Builder"]:::builder
    end

    %% Command Construction Layer
    subgraph "Command Construction Layer"
        C["ICommand (Interface)"]:::command
        D["Command (Concrete)"]:::command
        G["CommandBuilderValidator"]:::validator
        E["Delegates & Parameter Handling"]:::delegates
    end

    %% Processing Layer
    subgraph "Processing Layer"
        I["SequentialCommandProcessorBuilder"]:::builder
        H["SequentialCommandProcessor"]:::processor
        K["ConcurrentCommandProcessorBuilder"]:::builder
        J["ConcurrentCommandProcessor"]:::processor
        L["CommandProcessorConfiguration"]:::config
        M["CommandProcessorBuilderValidator"]:::validator
    end

    %% Relationships - Client Interaction to Construction
    A -->|"provides-builder"| B
    %% Command Builder validates then builds Command
    B -->|"validates"| G
    B -->|"builds-Command"| D

    %% Commander provides processor builders
    A -->|"provides-SequentialBuilder"| I
    A -->|"provides-ConcurrentBuilder"| K

    %% Processing Layer: Builder builds processor
    I -->|"builds-processor"| H
    K -->|"builds-processor"| J

    %% Processors execute the built command
    H -->|"processes-Command"| D
    J -->|"processes-Command"| D

    %% Processors execute delegates/hooks
    H -->|"executes-delegates"| E
    J -->|"executes-delegates"| E

    %% Processor builders validation and configuration
    I -->|"validates"| M
    K -->|"validates"| M
    M -->|"configures-processor"| L

    %% Processors use configuration
    H -->|"uses-config"| L
    J -->|"uses-config"| L

    %% Click Events for Commander
    click A "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/ICommander.cs"
    click A "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Commander.cs"

    %% Click Events for Command Abstraction
    click C "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/ICommand.cs"
    click D "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/Command.cs"

    %% Click Events for Command Builder
    click B "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/ICommandBuilder.cs"
    click B "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandBuilder.cs"
    click G "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandBuilderValidator.cs"

    %% Click Events for Sequential Command Processor
    click H "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/SequentialCommandProcessor.cs"
    click I "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/SequentialCommandProcessorBuilder.cs"

    %% Click Events for Concurrent Command Processor
    click J "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/ConcurrentCommandProcessor.cs"
    click K "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/ConcurrentCommandProcessorBuilder.cs"

    %% Click Events for Delegates & Parameter Handling
    click E "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandDelegate.cs"
    click E "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandParameter.cs"
    click E "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/ExceptionManager.cs"

    %% Click Events for Utility and Validation Components
    click L "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandProcessorConfiguration.cs"
    click M "https://github.com/asuarezc/asc.utils.commander/blob/main/Asc.Utils.Commander/Implementation/CommandProcessorBuilderValidator.cs"

    %% Class Styles
    classDef commander fill:#aqua,stroke:#000,stroke-width:2px;
    classDef builder fill:#b3ffb3,stroke:#000,stroke-width:2px;
    classDef command fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef processor fill:#ff9999,stroke:#000,stroke-width:2px;
    classDef delegates fill:#ffd700,stroke:#000,stroke-width:2px;
    classDef config fill:#d1c4e9,stroke:#000,stroke-width:2px;
    classDef validator fill:#ffb3ff,stroke:#000,stroke-width:2px;
```
