# 0xpolygon/kurtosis-cdk architecture

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

- Interactive diagram: https://gitdiagram.com/0xpolygon/kurtosis-cdk
- Repository: https://github.com/0xpolygon/kurtosis-cdk

## Overview

- L1 Chain: Represent the local L1 blockchain based on the ethereum-package. Indicate that it is fully customizable with multi-client support.
- L2 Chain: Show the Polygon CDK-based L2 network. Include key components such as:
- Sequencer (often implemented by “cdk-erigon” or legacy “zkevm-node”)
- Sequence sender and aggregator (e.g., via “cdk-node” or the newer zkevm-sequence-sender and aggregator if applicable)
- Additional modules (RPC nodes, provers, DAC, etc.)
- zkEVM Bridge: Represent the bridging infrastructure that connects the L1 and L2 chains.
- Additional services: Include any extra services such as the transaction spammer, monitoring tools, permissionless nodes; these are provided under “src/additional_services” and referenced in the docs.
- Kurtosis Enclave & Orchestration: Since this is deployed as a Kurtosis package, represent the overarching container/orchestration layer (Docker or Kubernetes) that encapsulates all these components. Also include the “kurtosis run” and “kurtosis clean” commands as part of the control flow.

##### Deployment & Configuration Layers
- CI/CD/Testing: Include an element for GitHub Actions and testing scripts (found in the “.github” directory) to highlight automation. This further emphasizes how continuous testing of configurations is integrated into the development cycle.

##### Relationships and Interactions
- From the L2 chain block, detail the interactions between the sequencer, sequence sender, and aggregator. Show communications between these components (e.g., state, transactions, and batch finality).
- ZkEVM bridge between the L1 and L2 elements.
- That additional services (monitoring, TX spammer, dashboards, etc.) interface with the running chains.

##### Architectural Patterns/Modules
- Modularity: Emphasize the separation between different services across directories (lib for core logic, src for additional services, and templates/configuration for deployment settings).
- Containerization: Show that each service (L1 chain, L2 chain components, additional services) runs inside its own isolated container managed by Kurtosis.
- Test & CI Automation: Represent the GitHub workflows and test configurations as integral parts of the overall system.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Orchestration and Control
    K["Kurtosis Orchestration"]:::orchestration
    U["User CLI Commands"]:::cli
    CI["CI/CD & Testing"]:::cicd
    C["Configuration & Templates"]:::config

    %% Blockchain Networks
    subgraph "Blockchain Networks"
        subgraph "L1 Layer"
            L1["L1 Ethereum Chain"]:::blockchain
        end
        subgraph "L2 Layer"
            L2_Sequencer["Sequencer"]:::blockchain
            L2_SequenceSender["Sequence Sender"]:::blockchain
            L2_Aggregator["Agglayer Interoperability"]:::blockchain
            L2_Prover["Prover"]:::blockchain
            L2_DAC["DAC"]:::blockchain
            L2_Aux["L2 Aux Module (cdk_node)"]:::blockchain
        end
        Bridge["zkEVM Bridge"]:::blockchain
    end

    %% Additional Services
    AS["Additional Services"]:::service

    %% Relationships
    %% Orchestration controlling deployment
    K -->|"deploys"| L1
    K -->|"deploys"| L2_Sequencer
    K -->|"deploys"| L2_SequenceSender
    K -->|"deploys"| L2_Aggregator
    K -->|"deploys"| L2_Prover
    K -->|"deploys"| L2_DAC
    K -->|"deploys"| L2_Aux
    K -->|"deploys"| Bridge
    K -->|"deploys"| AS

    %% CI/CD triggers orchestration
    CI -->|"triggers"| K

    %% User CLI interacts with orchestration
    U -->|"controls"| K

    %% Configuration feeds into blockchain deployment
    C -->|"configures"| L1
    C -->|"configures"| L2_Sequencer
    C -->|"configures"| L2_SequenceSender
    C -->|"configures"| L2_Aggregator
    C -->|"configures"| L2_Prover
    C -->|"configures"| L2_DAC
    C -->|"configures"| L2_Aux
    C -->|"configures"| Bridge

    %% L1 provides base for L2 via the bridge
    L1 -->|"provides base to"| Bridge
    Bridge -->|"connects to"| L2_Sequencer
    Bridge -->|"connects to"| L2_Aggregator

    %% Internal L2 communications
    L2_Sequencer -->|"sends state"| L2_SequenceSender
    L2_SequenceSender -->|"forwards data to"| L2_Aggregator
    L2_Aggregator -->|"coordinates with"| L2_Prover
    L2_Aggregator -->|"coordinates with"| L2_DAC
    L2_Aggregator -->|"integrates with"| L2_Aux

    %% Additional Services interact with blockchain networks
    AS -->|"monitors"| L1
    AS -->|"interacts with"| Bridge
    AS -->|"interacts with"| L2_Aggregator

    %% Click Events
    click L1 "https://github.com/0xpolygon/kurtosis-cdk/blob/main/ethereum.star"
    click L2_Sequencer "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/cdk_erigon.star"
    click L2_Sequencer "https://github.com/0xpolygon/kurtosis-cdk/tree/main/templates/cdk-erigon"
    click L2_SequenceSender "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/zkevm_sequence_sender.star"
    click L2_Aggregator "https://github.com/0xpolygon/kurtosis-cdk/blob/main/agglayer.star"
    click L2_Aggregator "https://github.com/0xpolygon/kurtosis-cdk/blob/main/templates/bridge-infra/agglayer-config.toml"
    click L2_Prover "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/zkevm_prover.star"
    click L2_DAC "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/zkevm_dac.star"
    click L2_Aux "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/cdk_node.star"
    click Bridge "https://github.com/0xpolygon/kurtosis-cdk/blob/main/cdk_bridge_infra.star"
    click Bridge "https://github.com/0xpolygon/kurtosis-cdk/blob/main/lib/zkevm_bridge.star"
    click Bridge "https://github.com/0xpolygon/kurtosis-cdk/tree/main/templates/bridge-infra"
    click AS "https://github.com/0xpolygon/kurtosis-cdk/tree/main/src/additional_services"
    click K "https://github.com/0xpolygon/kurtosis-cdk/blob/main/kurtosis.yml"
    click K "https://github.com/0xpolygon/kurtosis-cdk/tree/main/.github/actions/setup-kurtosis-cdk"
    click C "https://github.com/0xpolygon/kurtosis-cdk/blob/main/input_parser.star"
    click C "https://github.com/0xpolygon/kurtosis-cdk/tree/main/templates/"
    click CI "https://github.com/0xpolygon/kurtosis-cdk/blob/main/.github"

    %% Styles
    classDef blockchain fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef orchestration fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef config fill:#D8BFD8,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFDEAD,stroke:#000,stroke-width:2px;
    classDef cli fill:#F08080,stroke:#000,stroke-width:2px;
```
