# mytang0/brook architecture

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

- Interactive diagram: https://gitdiagram.com/mytang0/brook
- Repository: https://github.com/mytang0/brook

## Overview

##### Main Components
- Core Orchestration Engine – Represented by modules such as brook-core and brook-engine. This is where the main execution, flow/task management, caching, locking, and monitoring exist (e.g., FlowExecutor, TaskRegistry, Callback, ExecutorFactory, RateLimiter, etc.).
- Common Utilities – Found in brook-common. These include shared annotations, configuration classes, context management, exception definitions, metadata definitions, and various utility classes (for JSON, reflection, token handling, etc.).
- SPI and Extensions – The brook-spi and brook-spi-extensions modules provide a pluggable mechanism for computing, locking, metadata handling, tasks, and more. This layer uses SPI design patterns to allow for multiple implementations to be integrated via providers.
- Integration/Bootstrapping – The brook-spring-boot suite (starter, autoconfigure, locks, metadata, mybatis, etc.) offers easy integration with Spring Boot ecosystems, handling auto-configuration and registration of implementations. Also, the brook-demo module demonstrates how these components work within a sample Spring Boot application.
- External Flows and Configuration – The flows in brook-demo’s resources (in META-INF/flows) demonstrate how orchestration workflows are defined externally and then parsed/managed by the engine.

##### Relationships and Interactions
- The brook-core module sits at the heart, handling orchestration tasks. It communicates with:
- The SPI layer (brook-spi and brook-spi-extensions) for extension points, such as configuration, task execution, locking, and metadata handling.
- The brook-engine module, which provides the integration or runtime “front door” for starting flows.
- The brook-spring-boot modules then wrap these core capabilities, providing auto-configuration, dependency injection, and integration points for Spring Boot applications.
- The brook-demo module acts as a client that demonstrates the orchestration engine’s usage (e.g., REST controllers, sample callbacks, and listeners).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear separation between core functionalities (execution engine, task management) and support utilities (configuration, metadata, common annotations).
- Inversion of Control / Dependency Injection: With Spring Boot integrations, much of the wiring is handled via auto-configuration and annotation scanning. Indicate how the spring-boot autoconfigure modules use bean registration (e.g., FlowAutoConfiguration, FlowSPIBeanRegister) to link with core components.

##### Technologies and Frameworks
- Java (core language).
- Maven (project build/tool, as demonstrated by the multiple pom.xml files).
- Spring Boot (for the integration modules and demo).
- The SPI concepts along with any reflective/extension mechanisms used in the code.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Common Utilities
    subgraph "Common Utilities"
        COMMON["Brook Common"]:::common
    end

    %% Core Orchestration Engine Layer
    subgraph "Core Orchestration Engine"
        CORE["Brook Core"]:::core
        ENGINE["Brook Engine"]:::core
    end

    %% SPI and Extensions Layer
    subgraph "SPI and Extensions"
        SPI["Brook SPI"]:::spi
        SP_EXT["Brook SPI Extensions"]:::spi
    end

    %% Integration / Spring Boot Layer
    subgraph "Integration / Spring Boot"
        SPRING["Brook Spring Boot Integration"]:::spring
    end

    %% Demo and External Flows Layer
    subgraph "Demo & External Flows"
        DEMO["Demo Application (Brook Demo)"]:::demo
        FLOWS["External Flows"]:::demo
    end

    %% Relationships
    COMMON -->|"requires"| CORE
    COMMON -->|"provides_utilities"| SPI
    CORE -->|"integrates_with"| SPI
    CORE -->|"links_to"| ENGINE
    SPI -->|"extended_by"| SP_EXT
    ENGINE -->|"exposes_API_to"| SPRING
    SPRING -->|"configured_via_SPI"| SPI
    SPRING -->|"used_by"| DEMO
    DEMO -->|"loads"| FLOWS

    %% Click Events
    click CORE "https://github.com/mytang0/brook/tree/main/brook-core/src/main/java/xyz/mytang0/brook/core"
    click ENGINE "https://github.com/mytang0/brook/blob/main/brook-engine/pom.xml"
    click COMMON "https://github.com/mytang0/brook/tree/main/brook-common/src/main/java/xyz/mytang0/brook/common"
    click SPI "https://github.com/mytang0/brook/tree/main/brook-spi/src/main/java/xyz/mytang0/brook/spi"
    click SP_EXT "https://github.com/mytang0/brook/tree/main/brook-spi-extensions"
    click SPRING "https://github.com/mytang0/brook/tree/main/brook-spring-boot"
    click DEMO "https://github.com/mytang0/brook/tree/main/brook-demo/brook-demo-spring"
    click FLOWS "https://github.com/mytang0/brook/tree/main/brook-demo/brook-demo-spring/src/main/resources/META-INF/flows"

    %% Styles
    classDef common fill:#f0f0f0,stroke:#333,stroke-width:1px;
    classDef core fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef spi fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef spring fill:#fff3cd,stroke:#333,stroke-width:1px;
    classDef demo fill:#f8d7da,stroke:#333,stroke-width:1px;
```
