# mattburton/beckett architecture

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

- Interactive diagram: https://gitdiagram.com/mattburton/beckett
- Repository: https://github.com/mattburton/beckett

## Overview

##### Core Components Layer
- Message Store
- PostgreSQL implementation and the extensibility point for custom implementations (IMessageStorage)
- Message serialization and type mapping components
- Event Sourcing Infrastructure
- Stream management
- Message handling
- Optimistic concurrency control

##### Subscription System Layer
- Subscription Handler
- Checkpoint Management
- Checkpoint processor
- Checkpoint consumer groups
- Retry Mechanism
- Exponential backoff
- Error handling
- Scaling Components
- Multiple node support
- Stream partitioning

##### Projection System Layer
- Projection Handler
- State Views
- Message Configuration
- Projection Actions

##### Scheduling System Layer
- Message Scheduler
- Transactional Scheduler
- Cancellation Support
- Delivery Management

##### Monitoring & Management Layer
- Dashboard UI
- Message browser
- Retry management
- Subscription monitoring
- OpenTelemetry Integration
- Tracing
- Metrics
- Instrumentation

Use the following visual elements:

##### Components
- Use rectangles for major system components
- Use rounded rectangles for services
- Use hexagons for interfaces/contracts

##### Event Sourcing Pattern
- Flow from command to event storage
- Stream organization and message ordering

##### Message Processing Pattern
- Subscription flow
- Parallel processing capabilities
- Retry mechanisms

##### Projection Pattern
- How events flow into projections
- State building process

##### Scheduling Pattern
- Message scheduling flow
- Cancellation capabilities

Additional Considerations:

##### Notes for key architectural decisions
- Horizontal scaling capabilities
- Stream-based processing
- Error handling and retry strategies

##### Integration points
- OpenTelemetry integration
- Custom message store implementation
- Application integration points

##### Sample flow paths
- Message processing path
- Projection update path
- Scheduled message path

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef subscription fill:#b3ffb3,stroke:#4dff4d
    classDef projection fill:#ffd9b3,stroke:#ffb366
    classDef scheduling fill:#e6b3ff,stroke:#cc66ff
    classDef monitoring fill:#d9d9d9,stroke:#999999
    classDef storage fill:#fff,stroke:#666,stroke-dasharray: 5 5
    classDef interface fill:#f9f9f9,stroke:#666,stroke-width:2px

    %% Core Components Layer
    subgraph CoreLayer["Core Components Layer"]
        MessageStore["Message Store"]:::core
        IMessageStorage{{"IMessageStorage"}}:::interface
        PostgresImpl["PostgreSQL Implementation"]:::core
        MessageSerialization["Message Serialization"]:::core
        TypeMapping["Type Mapping"]:::core
        StreamMgmt["Stream Management"]:::core
        MessageHandling["Message Handling"]:::core
        ConcurrencyControl["Optimistic Concurrency"]:::core
    end

    %% Subscription System Layer
    subgraph SubscriptionLayer["Subscription System"]
        SubHandler["Subscription Handler"]:::subscription
        CheckpointMgmt["Checkpoint Management"]:::subscription
        CheckpointProc["Checkpoint Processor"]:::subscription
        RetryMech["Retry Mechanism"]:::subscription
        ExpBackoff["Exponential Backoff"]:::subscription
        RetryClient["Retry Client"]:::subscription
    end

    %% Projection System Layer
    subgraph ProjectionLayer["Projection System"]
        ProjHandler["Projection Handler"]:::projection
        IProjection{{"IProjection"}}:::interface
        StateViews["State Views"]:::projection
        ProjActions["Projection Actions"]:::projection
    end

    %% Scheduling System Layer
    subgraph SchedulingLayer["Scheduling System"]
        MsgScheduler["Message Scheduler"]:::scheduling
        TransScheduler["Transactional Scheduler"]:::scheduling
        SchedService["Scheduled Message Service"]:::scheduling
    end

    %% Monitoring Layer
    subgraph MonitoringLayer["Monitoring & Management"]
        Dashboard["Dashboard UI"]:::monitoring
        OpenTelemetry["OpenTelemetry"]:::monitoring
        Instrumentation["Instrumentation"]:::monitoring
    end

    %% Relationships
    MessageStore --> IMessageStorage
    IMessageStorage --> PostgresImpl
    MessageStore --> MessageSerialization
    MessageStore --> TypeMapping
    MessageStore --> StreamMgmt
    StreamMgmt --> MessageHandling
    MessageHandling --> ConcurrencyControl

    SubHandler --> CheckpointMgmt
    CheckpointMgmt --> CheckpointProc
    SubHandler --> RetryMech
    RetryMech --> ExpBackoff
    RetryMech --> RetryClient

    ProjHandler --> IProjection
    IProjection --> StateViews
    ProjHandler --> ProjActions

    MsgScheduler --> TransScheduler
    TransScheduler --> SchedService

    Dashboard --> OpenTelemetry
    OpenTelemetry --> Instrumentation

    %% Click Events
    click MessageStore "https://github.com/mattburton/beckett/blob/main/src/Beckett/IMessageStore.cs"
    click PostgresImpl "https://github.com/mattburton/beckett/blob/main/src/Beckett/MessageStorage/Postgres/PostgresMessageStorage.cs"
    click MessageSerialization "https://github.com/mattburton/beckett/blob/main/src/Beckett/Messages/MessageSerializer.cs"
    click TypeMapping "https://github.com/mattburton/beckett/blob/main/src/Beckett/Messages/MessageTypeMap.cs"
    click StreamMgmt "https://github.com/mattburton/beckett/blob/main/src/Beckett/IMessageStream.cs"
    click ConcurrencyControl "https://github.com/mattburton/beckett/blob/main/src/Beckett/OptimisticConcurrencyException.cs"
    click SubHandler "https://github.com/mattburton/beckett/blob/main/src/Beckett/Subscriptions/SubscriptionHandler.cs"
    click CheckpointProc "https://github.com/mattburton/beckett/blob/main/src/Beckett/Subscriptions/CheckpointProcessor.cs"
    click ExpBackoff "https://github.com/mattburton/beckett/blob/main/src/Beckett/Subscriptions/Retries/ExponentialBackoff.cs"
    click RetryClient "https://github.com/mattburton/beckett/blob/main/src/Beckett/Subscriptions/Retries/RetryClient.cs"
    click ProjHandler "https://github.com/mattburton/beckett/blob/main/src/Beckett/Projections/ProjectionHandler.cs"
    click IProjection "https://github.com/mattburton/beckett/blob/main/src/Beckett/Projections/IProjection.cs"
    click ProjActions "https://github.com/mattburton/beckett/blob/main/src/Beckett/Projections/ProjectionAction.cs"
    click MsgScheduler "https://github.com/mattburton/beckett/blob/main/src/Beckett/Scheduling/MessageScheduler.cs"
    click TransScheduler "https://github.com/mattburton/beckett/blob/main/src/Beckett/Scheduling/ITransactionalMessageScheduler.cs"
    click SchedService "https://github.com/mattburton/beckett/blob/main/src/Beckett/Scheduling/Services/ScheduledMessageService.cs"
    click Dashboard "https://github.com/mattburton/beckett/blob/main/src/Beckett.Dashboard/Dashboard.cs"
    click Instrumentation "https://github.com/mattburton/beckett/blob/main/src/Beckett/OpenTelemetry/Instrumentation.cs"
    click OpenTelemetry "https://github.com/mattburton/beckett/blob/main/src/Beckett/OpenTelemetry/TracerProviderBuilderExtensions.cs"

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        SubComp["Subscription Components"]:::subscription
        ProjComp["Projection Components"]:::projection
        SchedComp["Scheduling Components"]:::scheduling
        MonComp["Monitoring Components"]:::monitoring
        InterfaceComp{{"Interfaces"}}:::interface
    end
```
