# dagworks-inc/burr architecture

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

- Interactive diagram: https://gitdiagram.com/dagworks-inc/burr
- Repository: https://github.com/dagworks-inc/burr

## Overview

##### Main Components
- Core State Machine Engine – This is implemented primarily in the burr/core directory. It contains modules for actions (burr/core/action.py), application building (burr/core/application.py), graph/data flow (burr/core/graph.py), persistence (burr/core/persistence.py), serialization/deserialization (burr/core/serde.py), and state management (burr/core/state.py). This is the heart of the framework.
- CLI / Entry Point – The burr/cli package (e.g., burr/cli/__main__.py and demo_data.py) acts as the command-line launcher and demonstration executor to kick off state machine runs.
- Integrations and Extensibility – The burr/integrations package adds support for several external services and modules (e.g., Hamilton, Haystack, opentelemetry, notebook interface) as well as persisters (in burr/integrations/persisters) and serializers (in burr/integrations/serde) that can interface with external systems.
- Telemetry and Tracking – There is a dedicated telemetry layer seen in burr/telemetry.py, and an extensive tracking subsystem in burr/tracking alongside the server code (including S3 deployment) and demo data. This component captures and logs execution traces and state changes.
- Lifecycle & Visibility – Packages like burr/lifecycle and burr/visibility encapsulate lifecycle event management and the visibility (tracing/debugging) aspects so that state transitions can be monitored and analyzed easily.
- UI Component – The telemetry UI is separate from the core library and resides under the telemetry/ui directory, built with TypeScript/React. It provides an interactive real-time interface to view execution flow, logs, and metrics.
- Examples and Documentation – The examples directory and docs illustrate many use-cases, ranging from simple counter apps to complex chatbots and integrations with other libraries (e.g., Hamilton, Ray, streamlit).

##### Relationships and Interactions
- The CLI (or an API call) initiates an application built by the ApplicationBuilder from the core module.
- The core engine invokes ‘actions’ (Python functions decorated with @action) arranged in the state machine graph, transitioning the application’s state.
- As actions execute, state updates along with persistence (using the persisters provided in the integrations) and telemetry tracking (via the tracking modules) are recorded.
- The tracking data is then fed into the Telemetry UI for real-time monitoring and debugging.
- Integrations act as adapters: they translate calls from the core (for serialization, logging, or external API calls) into operations in external systems.
- Lifecycle and visibility components are invoked during state transitions to provide hooks and additional debugging support.

##### Important Architectural Patterns and Principles
- Modular State Machine Architecture – Each state machine is constructed from decoupled actions, transitions, and data flow managed by the core modules.
- Extensibility by Integration – The design emphasizes plug-and-play integrations for persistence, telemetry, and external service connections.
- Separation of Concerns – The architecture cleanly distinguishes between core logic (state management and transitions), external integrations/persistence, and the monitoring/UI layer.
- Multi-layered Approach – The design covers command-line interfaces, backend processing via the core engine, and a front-end UI for visualization, connecting through telemetry/tracking layers.

##### Relevant Technologies and Frameworks
- Python is the primary language with a focus on state machine and workflow orchestration.
- The Telemetry UI is built using a modern web stack (React/TypeScript), as indicated by the telemetry/ui directory.
- Integrations include support for popular tools (Hamilton, Ray, opentelemetry, etc.), hinting at interoperability with asynchronous workflows and external APIs.
- Build and test tools (GitHub Actions workflows, pre-commit configuration, etc.) are part of the supporting infrastructure.

- Clear, labeled nodes/components for:
- Core Engine (State Machine, Actions, Transitions)
- CLI / Entrypoint
- Integration Adapters (with sub-nodes for persisters, serializers, third-party integrations)
- Telemetry & Tracking Engine
- UI Dashboard Module (Telemetry UI)
- Lifecycle & Visibility (Hooks and debugging)
- Flow from CLI or application invocation → Core Engine → Action execution → State updates.
- Data persistence flows from the core engine to various integration persisters.
- Telemetry data flowing from tracking modules to the UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Execution Layer
    subgraph "Execution Layer"
        CLI["CLI / Entry Point"]:::cli
    end

    %% Core Engine Layer
    subgraph "Core State Machine Engine"
        APP_BUILDER["Application Builder"]:::core
        ACTIONS["Actions Module"]:::core
        GRAPH["Graph Data Flow"]:::core
        PERSISTENCE["Persistence Module"]:::core
        SERDE["Serialization Module"]:::core
        STATE["State Management Module"]:::core
    end

    %% Integrations Layer
    subgraph "Integrations Layer"
        INTEGRATIONS["Integration Adapters"]:::integration
        PERSISTER["Persisters Adapter"]:::integration
        INT_SERIALIZERS["Serializers Adapter"]:::integration
    end

    %% Monitoring & Telemetry Layer
    subgraph "Monitoring & Telemetry Layer"
        TELEMETRY["Telemetry Module"]:::telemetry
        TRACKING["Tracking Subsystem"]:::telemetry
        LIFECYCLE["Lifecycle Hooks"]:::lifecycle
        VISIBILITY["Debug & Visibility"]:::lifecycle
        UI["Telemetry UI Dashboard"]:::ui
    end

    %% Auxiliary Layer
    subgraph "Documentation & Examples"
        EXAMPLES["Examples"]:::aux
        DOCS["Documentation"]:::aux
    end

    %% Connections between Execution and Core
    CLI -->|"invokes"| APP_BUILDER
    APP_BUILDER -->|"builds"| ACTIONS
    ACTIONS -->|"executes"| GRAPH
    ACTIONS -->|"triggers"| STATE

    %% Connections from Core to Integrations
    PERSISTENCE -->|"persists"| PERSISTER
    SERDE -->|"handles"| INT_SERIALIZERS

    %% Connections from Core to Monitoring
    STATE -->|"records"| TELEMETRY
    STATE -->|"updates"| TRACKING
    ACTIONS -->|"hooks"| LIFECYCLE
    STATE -->|"notifies"| VISIBILITY

    TELEMETRY -->|"streams"| UI
    TRACKING -->|"sends"| UI

    %% Feedback loop from UI
    UI -->|"feedback"| APP_BUILDER

    %% Click Events
    click CLI "https://github.com/dagworks-inc/burr/blob/main/burr/cli/__main__.py"
    click APP_BUILDER "https://github.com/dagworks-inc/burr/blob/main/burr/core/application.py"
    click ACTIONS "https://github.com/dagworks-inc/burr/blob/main/burr/core/action.py"
    click GRAPH "https://github.com/dagworks-inc/burr/blob/main/burr/core/graph.py"
    click PERSISTENCE "https://github.com/dagworks-inc/burr/blob/main/burr/core/persistence.py"
    click SERDE "https://github.com/dagworks-inc/burr/blob/main/burr/core/serde.py"
    click STATE "https://github.com/dagworks-inc/burr/blob/main/burr/core/state.py"
    click INTEGRATIONS "https://github.com/dagworks-inc/burr/tree/main/burr/integrations"
    click PERSISTER "https://github.com/dagworks-inc/burr/tree/main/burr/integrations/persisters"
    click INT_SERIALIZERS "https://github.com/dagworks-inc/burr/tree/main/burr/integrations/serde"
    click TELEMETRY "https://github.com/dagworks-inc/burr/blob/main/burr/telemetry.py"
    click TRACKING "https://github.com/dagworks-inc/burr/tree/main/burr/tracking"
    click LIFECYCLE "https://github.com/dagworks-inc/burr/tree/main/burr/lifecycle"
    click VISIBILITY "https://github.com/dagworks-inc/burr/blob/main/burr/visibility/tracing.py"
    click UI "https://github.com/dagworks-inc/burr/tree/main/telemetry/ui"
    click EXAMPLES "https://github.com/dagworks-inc/burr/tree/main/examples"
    click DOCS "https://github.com/dagworks-inc/burr/tree/main/docs"

    %% Styles
    classDef cli fill:#F5CBA7,stroke:#000,stroke-width:1px;
    classDef core fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef integration fill:#F9E79F,stroke:#000,stroke-width:1px;
    classDef telemetry fill:#A3E4D7,stroke:#000,stroke-width:1px;
    classDef lifecycle fill:#D5F5E3,stroke:#000,stroke-width:1px;
    classDef ui fill:#D2B4DE,stroke:#000,stroke-width:1px;
    classDef aux fill:#FADBD8,stroke:#000,stroke-width:1px;
```
