# sublayerapp/sublayer architecture

> Architecture diagram of the GitHub repository sublayerapp/sublayer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sublayerapp/sublayer
- Repository: https://github.com/sublayerapp/sublayer

## Overview

##### Main Components

a. Core Framework Components:
- Generators (Primary building blocks)
- Actions (Operation executors)
- Agents (Autonomous entities)
- Triggers (Event listeners)
- Providers (AI Model interfaces)

b. Supporting Components:
- CLI Interface
- Output Adapters
- Logging System
- Configuration System

**┌─────────────────────────────────────────────────────────────┐**
- Client Applications                      │
- ┘
- ▲

**┌─────────────────────────────────────────────────────────────┐**
- Sublayer Framework                       │
- ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ │
- Agents   │──│  Triggers   │  │     Generators      │ │
- ┘  └─────────────┘  └─────────────────────┘ │

- ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ │
- Actions   │  │   Output    │  │     Components      │ │
- Adapters   │  │                     │ │
- ┘  └─────────────┘  └─────────────────────┘ │

- ┌─────────────────────────────────────────────────────┐   │
- AI Providers                        │   │
- ┌──────────┐  ┌──────────┐  ┌──────────────────┐  │   │
- OpenAI  │  │  Gemini  │  │      Claude      │  │   │
- ┘  └──────────┘  └──────────────────┘  │   │
- ┘   │
- ┘

**┌─────────────────────────────────────────────────────────────┐**
- External AI Services                     │
- ┘

##### Component Relationships to Highlight

a. Core Flow:
- Agents use Triggers to monitor for events
- Agents coordinate Generators and Actions
- Generators communicate with AI Providers
- Actions execute based on Generator outputs

b. Support Systems:
- Output Adapters format responses
- Logging system tracks operations
- CLI provides user interface
- Configuration system manages settings

##### Important Details

- Model agnostic nature of the framework
- Supported AI providers (OpenAI, Gemini, Claude)
- Extension points for custom implementations
- Configuration options
- File structure organization

##### Implementation Notes

- The modular architecture allowing for easy extension
- The separation between AI interaction and business logic
- The flexibility in provider selection
- The standardized interfaces for components

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        App[Client App]
    end

    subgraph Framework["Sublayer Framework"]
        subgraph Core["Core Components"]
            Agents["Agents"]
            Triggers["Triggers"]
            Generators["Generators"]
            Actions["Actions"]
            Components["Components"]
            Output["Output Adapters"]
        end

        subgraph Providers["AI Providers"]
            OpenAI["OpenAI"]
            Gemini["Gemini"]
            Claude["Claude"]
        end

        subgraph Support["Support Systems"]
            CLI["CLI Interface"]
            Logging["Logging System"]
            Config["Configuration"]
        end
    end

    subgraph External["External AI Services"]
        AIServices["AI Services"]
    end

    %% Relationships
    App --> Framework
    Agents --> Triggers
    Agents --> Generators
    Agents --> Actions
    Generators --> Providers
    Actions --> Components
    Components --> Output
    Providers --> AIServices
    CLI --> Framework
    Logging --> Framework

    %% Click events for component mapping
    click Generators "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/generators/base.rb"
    click Actions "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/actions/base.rb"
    click Agents "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/agents/base.rb"
    click Triggers "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/triggers/base.rb"
    click OpenAI "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/providers/open_ai.rb"
    click Gemini "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/providers/gemini.rb"
    click Claude "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/providers/claude.rb"
    click CLI "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/cli.rb"
    click Output "https://github.com/sublayerapp/sublayer/blob/main/lib/sublayer/components/output_adapters.rb"
    click Logging "https://github.com/sublayerapp/sublayer/tree/main/lib/sublayer/logging"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef core fill:#dae8fc,stroke:#6c8ebf
    classDef provider fill:#d5e8d4,stroke:#82b366
    classDef support fill:#ffe6cc,stroke:#d79b00
    classDef external fill:#f5f5f5,stroke:#666666
    
    class Agents,Triggers,Generators,Actions,Components,Output core
    class OpenAI,Gemini,Claude provider
    class CLI,Logging,Config support
    class AIServices external

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ProviderComp["AI Provider"]:::provider
        SupportComp["Support System"]:::support
        ExtComp["External Service"]:::external
    end
```
