# pimlicolabs/alto architecture

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

- Interactive diagram: https://gitdiagram.com/pimlicolabs/alto
- Repository: https://github.com/pimlicolabs/alto

## Overview

##### Main Components

a) Core Bundler Components:
- Mempool System (/src/mempool)
- Executor System (/src/executor)
- RPC Handler (/src/rpc)
- CLI Interface (/src/cli)

b) Supporting Systems:
- Validation Layer (/src/rpc/validation)
- Gas Estimation System (/src/rpc/estimation)
- Contract Interfaces (/src/types/contracts)
- Event Handlers (/src/handlers)

##### Component Relationships

**External Layer:**
- ERC-4337 Client Requests
- Ethereum Node Connection
- Smart Contracts (EntryPoint)

**API Layer:**
- RPC Server
- Custom Endpoints
- Request Validation

**Core Processing Layer:**
- Mempool Management
- Operation Execution
- Gas Estimation
- Transaction Validation

**Infrastructure Layer:**
- Monitoring & Metrics
- Configuration Management
- Utility Wallet Management

##### Specific Implementation Details

Key elements:

a) RPC Endpoints:
- eth_sendUserOperation
- eth_estimateUserOperationGas
- eth_getUserOperationByHash
- eth_getUserOperationReceipt
- Custom Pimlico endpoints

b) Processing Pipeline:
- Flow from request reception to transaction inclusion
- Validation steps
- Gas estimation process
- Mempool management

##### Critical Subsystems

Important subsystems:

a) Validation System:
- Safe Validator
- Unsafe Validator
- Tracer Components

b) Execution System:
- Executor Manager
- Sender Manager
- Utility Wallet Monitor

##### Integration Points

Connections with:
- Ethereum Network
- EntryPoint Contracts
- Client Applications
- Monitoring Systems

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Layer"]
        Client["ERC-4337 Client"]
        EthNode["Ethereum Node"]
        SmartContracts["EntryPoint Contracts"]:::contracts
    end

    subgraph API["API Layer"]
        RPC["RPC Handler"]:::rpc
        Validation["Validation Layer"]:::validation
        GasEstimation["Gas Estimation System"]:::gas
    end

    subgraph Core["Core Processing Layer"]
        Mempool["Mempool System"]:::mempool
        Executor["Executor System"]:::executor
        RepManager["Reputation System"]:::reputation
    end

    subgraph Infrastructure["Infrastructure Layer"]
        CLI["CLI Interface"]:::cli
        UWallet["Utility Wallet Management"]:::uwallet
        SenderMgr["Sender Management"]:::sender
    end

    subgraph Handlers["Event Handlers"]
        CompHandler["Compression Handler"]:::handler
        GasPriceMgr["Gas Price Manager"]:::handler
        ArbGasPriceMgr["Arbitrum Gas Price"]:::handler
        MantleGasPriceMgr["Mantle Gas Price"]:::handler
    end

    Client --> RPC
    EthNode --> RPC
    SmartContracts --> RPC

    RPC --> Validation
    RPC --> GasEstimation
    
    Validation --> Mempool
    GasEstimation --> Mempool
    
    Mempool --> RepManager
    Mempool --> Executor
    
    Executor --> UWallet
    Executor --> SenderMgr
    
    Executor --> CompHandler
    Executor --> GasPriceMgr
    GasPriceMgr --> ArbGasPriceMgr
    GasPriceMgr --> MantleGasPriceMgr

    CLI --> RPC
    CLI --> Mempool
    CLI --> Executor

    classDef contracts fill:#FFE873
    classDef rpc fill:#87CEEB
    classDef validation fill:#98FB98
    classDef gas fill:#DDA0DD
    classDef mempool fill:#87CEEB
    classDef executor fill:#87CEEB
    classDef reputation fill:#FFB6C1
    classDef cli fill:#D3D3D3
    classDef uwallet fill:#D3D3D3
    classDef sender fill:#D3D3D3
    classDef handler fill:#FFA07A

    click Mempool "https://github.com/pimlicolabs/alto/blob/main/src/mempool/mempool.ts"
    click RepManager "https://github.com/pimlicolabs/alto/blob/main/src/mempool/reputationManager.ts"
    click Executor "https://github.com/pimlicolabs/alto/blob/main/src/executor/executor.ts"
    click RPC "https://github.com/pimlicolabs/alto/blob/main/src/rpc/rpcHandler.ts"
    click CLI "https://github.com/pimlicolabs/alto/blob/main/src/cli/alto.ts"
    click Validation "https://github.com/pimlicolabs/alto/tree/main/src/rpc/validation/"
    click GasEstimation "https://github.com/pimlicolabs/alto/tree/main/src/rpc/estimation/"
    click SmartContracts "https://github.com/pimlicolabs/alto/tree/main/src/types/contracts/"
    click CompHandler "https://github.com/pimlicolabs/alto/blob/main/src/handlers/compressionHandler.ts"
    click GasPriceMgr "https://github.com/pimlicolabs/alto/blob/main/src/handlers/gasPriceManager.ts"
    click UWallet "https://github.com/pimlicolabs/alto/blob/main/src/executor/utilityWalletMonitor.ts"
    click SenderMgr "https://github.com/pimlicolabs/alto/blob/main/src/executor/senderManager.ts"
    click ArbGasPriceMgr "https://github.com/pimlicolabs/alto/blob/main/src/handlers/arbitrumGasPriceManager.ts"
    click MantleGasPriceMgr "https://github.com/pimlicolabs/alto/blob/main/src/handlers/mantleGasPriceManager.ts"
```
