# alpenlabs/strata architecture

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

- Interactive diagram: https://gitdiagram.com/alpenlabs/strata
- Repository: https://github.com/alpenlabs/strata

## Overview

##### Main Components (Top Level)

- Bitcoin Layer (Base Layer)
- Strata Core Layer (Rollup)
- Application Layer (EVM Compatible)

##### Core Components

a) Client Components:
- Bridge Client (`bin/bridge-client/`)
- Prover Client (`bin/prover-client/`)
- Strata Client (`bin/strata-client/`)
- Strata CLI (`bin/strata-cli/`)

b) Execution Components:
- EVM Execution Engine (`crates/eectl/`, `crates/evmexec/`)
- Bridge Execution (`crates/bridge-exec/`)
- Consensus Logic (`crates/consensus-logic/`)

c) Storage & State:
- RocksDB Store (`crates/rocksdb-store/`)
- State Management (`crates/state/`)
- Database Layer (`crates/db/`)

d) Proof System:
- RISC0 Prover (`provers/risc0/`)
- SP1 Prover (`provers/sp1/`)
- ZK Verification (`crates/zkvm/`)

##### Data Flow Connections

- Bitcoin data flow through BTC I/O (`crates/btcio/`)
- Bridge operations flow through Bridge Relay (`crates/bridge-relay/`)
- Transaction processing through TX Parser (`crates/tx-parser/`)
- State transitions through State Management
- Proof generation and verification paths

##### Key Subsystems

a) Bridge System:
- Bridge TX Builder
- Bridge Sig Manager
- Bridge Relay
- Bridge Operations

b) Proof System:
- Different proof types (BTC blockspace, checkpoint, CL aggregation, etc.)
- Proof verification flow
- Proof generation pipeline

c) Execution Environment:
- EVM compatibility layer
- State transition function
- Block execution

##### External Interfaces

Connections to:
- Bitcoin network
- RPC interfaces (`crates/rpc/`)
- Client applications
- External services

##### The client interaction points

Remember to include version or phase indicators, as the README mentions this is a work-in-progress project with different phases (devnet, mainnet) having different characteristics.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef bitcoin fill:#4267B2,color:white
    classDef rollup fill:#34A853,color:white
    classDef evm fill:#8E44AD,color:white
    classDef bridge fill:#E67E22,color:white
    classDef storage fill:#95A5A6,color:white
    classDef proof fill:#9B59B6,color:white
    classDef client fill:#1ABC9C,color:white
    classDef execution fill:#E74C3C,color:white

    %% Bitcoin Layer
    subgraph BL["Bitcoin Layer"]
        BTC[Bitcoin Network]:::bitcoin
        BTCIO[Bitcoin I/O]:::bitcoin
    end

    %% Strata Core Layer
    subgraph SCL["Strata Core Layer"]
        %% Client Components
        BC[Bridge Client]:::client
        PC[Prover Client]:::client
        SC[Strata Client]:::client
        CLI[Strata CLI]:::client

        %% Bridge System
        subgraph BS["Bridge System"]
            BTB[Bridge TX Builder]:::bridge
            BSM[Bridge Sig Manager]:::bridge
            BR[Bridge Relay]:::bridge
            BE[Bridge Execution]:::bridge
        end

        %% Proof System
        subgraph PS["Proof System"]
            RISC[RISC0 Prover]:::proof
            SP1[SP1 Prover]:::proof
            ZKV[ZK Verification]:::proof
        end

        %% Execution Components
        subgraph EC["Execution Components"]
            EVM[EVM Execution Engine]:::execution
            CL[Consensus Logic]:::execution
            TP[Transaction Parser]:::execution
        end

        %% Storage Components
        subgraph ST["Storage Layer"]
            RDB[RocksDB Store]:::storage
            SM[State Management]:::storage
            DB[Database Layer]:::storage
        end

        RPC[RPC Interface]:::rollup
    end

    %% Application Layer
    subgraph AL["Application Layer"]
        EVMA[EVM Applications]:::evm
    end

    %% Connections
    BTC --> BTCIO
    BTCIO --> BR
    BR --> BE
    BE --> BTB
    BTB --> BSM
    BSM --> BR

    SC --> RPC
    BC --> RPC
    PC --> RPC
    CLI --> RPC

    RPC --> TP
    TP --> EVM
    EVM --> CL
    CL --> SM

    SM --> RDB
    SM --> DB
    
    EVM --> RISC
    EVM --> SP1
    RISC --> ZKV
    SP1 --> ZKV

    RPC --> EVMA

    %% Click Events
    click BC "https://github.com/alpenlabs/strata/tree/main//bin/bridge-client/"
    click PC "https://github.com/alpenlabs/strata/tree/main//bin/prover-client/"
    click SC "https://github.com/alpenlabs/strata/tree/main//bin/strata-client/"
    click CLI "https://github.com/alpenlabs/strata/tree/main//bin/strata-cli/"
    click EVM "https://github.com/alpenlabs/strata/tree/main//crates/eectl/"
    click BE "https://github.com/alpenlabs/strata/tree/main//crates/bridge-exec/"
    click CL "https://github.com/alpenlabs/strata/tree/main//crates/consensus-logic/"
    click RDB "https://github.com/alpenlabs/strata/tree/main//crates/rocksdb-store/"
    click SM "https://github.com/alpenlabs/strata/tree/main//crates/state/"
    click DB "https://github.com/alpenlabs/strata/tree/main//crates/db/"
    click RISC "https://github.com/alpenlabs/strata/tree/main//provers/risc0/"
    click SP1 "https://github.com/alpenlabs/strata/tree/main//provers/sp1/"
    click ZKV "https://github.com/alpenlabs/strata/tree/main//crates/zkvm/"
    click BTB "https://github.com/alpenlabs/strata/tree/main//crates/bridge-tx-builder/"
    click BSM "https://github.com/alpenlabs/strata/tree/main//crates/bridge-sig-manager/"
    click BR "https://github.com/alpenlabs/strata/tree/main//crates/bridge-relay/"
    click BTCIO "https://github.com/alpenlabs/strata/tree/main//crates/btcio/"
    click TP "https://github.com/alpenlabs/strata/tree/main//crates/tx-parser/"
    click RPC "https://github.com/alpenlabs/strata/tree/main//crates/rpc/"

    %% Legend
    subgraph Legend
        L1[Bitcoin Components]:::bitcoin
        L2[Rollup Components]:::rollup
        L3[EVM Components]:::evm
        L4[Bridge Components]:::bridge
        L5[Storage Components]:::storage
        L6[Proof Components]:::proof
        L7[Client Components]:::client
        L8[Execution Components]:::execution
    end
```
