# eth-infinitism/bundler architecture

> Architecture diagram of the GitHub repository eth-infinitism/bundler, 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/eth-infinitism/bundler
- Repository: https://github.com/eth-infinitism/bundler

## Overview

##### Main Components
- Bundler Service: The core service is implemented in the "packages/bundler" directory. It includes configuration files, server setup (BundlerServer.ts), method handlers for different RPC calls (e.g., MethodHandlerERC4337.ts, MethodHandlerRIP7560.ts), and several modules (BundleManager, DepositManager, ExecutionManager, etc.). This component is the heart of the application.
- SDK Package: Found under "packages/sdk", this package provides APIs (like ERC4337EthersProvider, ERC4337EthersSigner, etc.) to interact with the bundler and to create/send UserOperations.
- Utilities: The "packages/utils" delivers internal methods, helper utilities, and shared contracts that support bundler operations.
- Validation Manager: The "packages/validation-manager" package includes components for checking the correctness of user operations and managing the state (with references to parsing, rule enforcement, and even custom tracing via Geth).
- Smart Contracts: There are contracts under various packages (for instance, "packages/bundler/contracts"). These contracts are essential for wallet deployment and the underlying account abstraction.
- Test Infrastructure and Scripts: The repository includes an extensive suite of tests for different modules and scripts for deployment and operation (found in “packages/bundler/test”, “packages/sdk/test”, and the “scripts” folder).

##### Interactions and Relationships
- Deployment Context: Represent Docker containers and orchestration. For instance, illustrate separate Docker containers for:
- Bundler service
- Geth node for production/development support (as provided via docker run command)
- Test environments (dockers/test)
- Contract Interactions: Indicate a connection between the Bundler and deployed smart contracts (used for wallet creation and deployments), which are deployed using Hardhat scripts (shown in “packages/bundler/deploy” and the hardhat config files).

##### Architectural Patterns and Design Principles
- External Integration: Emphasize how the bundler integrates with third-party networks and services via both Docker-based deployment and an HTTP RPC interface.
- Continuous Integration/Deployment: Include a component for CI/CD that is hinted by the GitHub workflows (".github/workflows/build.yml").

##### Relevant Technologies and Frameworks
- Hardhat: Since “hardhat.config.ts” files appear in multiple packages, note the usage of Hardhat for deployments and testing.
- Docker Containers: Highlight Docker’s role for bundler, test environments, and dependency (Geth).
- TypeScript: Emphasize that the codebase is written in TypeScript (e.g., tsconfig files throughout the repository).

##### Summing Up
- The main internal components of the bundler and its modular sub-components
- The relationship of the bundler to Ethereum network components (via Geth)
- The supporting SDK and utility packages that interact with the bundler
- The CI/CD and Dockerized deployment strategy, highlighting both production and test configurations

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        sdk["SDK / Client Application"]:::sdk
    end

    %% Bundler Service Layer
    subgraph "Bundler Service Layer"
        bundler["Bundler Service"]:::bundler
        server["BundlerServer"]:::bundler
        mhERC4337["MethodHandlerERC4337"]:::bundler
        mhRIP7560["MethodHandlerRIP7560"]:::bundler
        modules["Modules (BundleManager,DepositManager,ExecutionManager)"]:::bundler
    end

    %% Support Packages
    subgraph "Support Packages"
        utilities["Utilities"]:::utilities
        validation["Validation Manager"]:::validation
        subgraph "Smart Contracts"
            bundlerContracts["Smart Contracts (Bundler)"]:::contracts
            utilsContracts["Smart Contracts (Shared)"]:::contracts
        end
    end

    %% External Systems
    subgraph "External Systems"
        geth["Geth Node (Ethereum Client)"]:::external
    end

    %% Deployment & Testing
    subgraph "Deployment & Testing"
        dockerBundler["Docker: Bundler Deployment"]:::docker
        dockerTest["Docker: Test Environment"]:::docker
        bundlerTest["Bundler Tests"]:::tests
        sdkTest["SDK Tests"]:::tests
        scriptsNode["Operational Scripts"]:::tests
        cicd["CI/CD Pipeline"]:::cicd
    end

    %% Relationships
    sdk -->|"HTTP_RPC"| bundler
    bundler -->|"contains"| server
    server -->|"handles"| mhERC4337
    server -->|"handles"| mhRIP7560
    bundler -->|"orchestrates"| modules
    bundler -->|"leverages"| utilities
    bundler -->|"validates_with"| validation
    bundler -->|"deploys_contract"| bundlerContracts
    bundlerContracts ---|"shares"| utilsContracts
    bundler -->|"calls"| geth

    cicd -->|"triggers"| dockerBundler
    cicd -->|"triggers"| dockerTest

    dockerBundler -->|"hosts"| bundler
    dockerTest -->|"hosts"| geth

    bundlerTest -->|"tests"| bundler
    sdkTest -->|"tests"| sdk
    scriptsNode -->|"automates"| sdk

    %% Styles
    classDef bundler fill:#f7d794,stroke:#333,stroke-width:2px;
    classDef sdk fill:#7bed9f,stroke:#333,stroke-width:2px;
    classDef utilities fill:#ffb142,stroke:#333,stroke-width:2px;
    classDef validation fill:#ff6b6b,stroke:#333,stroke-width:2px;
    classDef contracts fill:#1dd1a1,stroke:#333,stroke-width:2px;
    classDef external fill:#f368e0,stroke:#333,stroke-width:2px;
    classDef docker fill:#54a0ff,stroke:#333,stroke-width:2px;
    classDef tests fill:#a29bfe,stroke:#333,stroke-width:2px;
    classDef cicd fill:#feca57,stroke:#333,stroke-width:2px;

    %% Click Events
    click bundler "https://github.com/eth-infinitism/bundler/tree/master/packages/bundler"
    click sdk "https://github.com/eth-infinitism/bundler/tree/master/packages/sdk"
    click utilities "https://github.com/eth-infinitism/bundler/tree/master/packages/utils"
    click validation "https://github.com/eth-infinitism/bundler/tree/master/packages/validation-manager"
    click bundlerContracts "https://github.com/eth-infinitism/bundler/tree/master/packages/bundler/contracts"
    click utilsContracts "https://github.com/eth-infinitism/bundler/tree/master/packages/utils/contracts"
    click dockerBundler "https://github.com/eth-infinitism/bundler/tree/master/dockers/bundler"
    click dockerTest "https://github.com/eth-infinitism/bundler/tree/master/dockers/test"
    click bundlerTest "https://github.com/eth-infinitism/bundler/tree/master/packages/bundler/test"
    click sdkTest "https://github.com/eth-infinitism/bundler/tree/master/packages/sdk/test"
    click scriptsNode "https://github.com/eth-infinitism/bundler/tree/master/scripts"
```
