# empyrealapp/eth-packages architecture

> Architecture diagram of the GitHub repository empyrealapp/eth-packages, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/empyrealapp/eth-packages
- Repository: https://github.com/empyrealapp/eth-packages

## Overview

##### High-Level Components (Main Layer)
- eth_rpc (Core RPC functionality)
- eth_protocols (Protocol implementations)
- eth_typeshed (Type definitions)
- eth_streams (Stream processing)
- sapphire (Auxiliary functionality)

##### Core Services Layer
- Transport Layer
- RPC Client
- WebSocket Client
- Contract Interaction Layer
- Contract Factory
- Function Caller
- Event Handler
- Blockchain Interface Layer
- Block Manager
- Transaction Manager
- Account Manager
- Network Layer
- Multiple Network Support (Ethereum, Arbitrum, etc.)

##### Protocol Implementation Layer
- UniswapV2 Implementation
- UniswapV3 Implementation
- ERC20 Implementation
- Multicall Implementation
- Custom Protocol Support

##### Stream Processing Layer
Stream processing components:
- Event Streams
- Block Streams
- Pipeline Processing
- Data Transformers

##### Type System Layer
Type system components:
- Contract Types
- Blockchain Types
- Protocol Types
- Custom Type Definitions

Use the following visual elements:

##### Specific callouts for
- Async support
- Type safety features
- Multi-network compatibility
- Event subscription capabilities

Key Relationships to Highlight:

##### Flow of type information through the system

Additional Elements:

##### Async/sync boundaries

- The modular nature of the system
- Type safety throughout the stack
- The ability to extend with new protocols
- The streaming and event handling capabilities
- Multi-network support

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Packages
    subgraph MainLayer["Main Layer"]
        EthRPC["eth_rpc"]:::core
        EthProtocols["eth_protocols"]:::protocols
        EthTypeshed["eth_typeshed"]:::types
        EthStreams["eth_streams"]:::streams
        Sapphire["sapphire"]:::auxiliary
    end

    %% Core Services Layer
    subgraph CoreServices["Core Services Layer"]
        subgraph Transport["Transport Layer"]
            RPCClient["RPC Client"]:::core
            WSClient["WebSocket Client"]:::core
        end

        subgraph ContractLayer["Contract Interaction Layer"]
            ContractFactory["Contract Factory"]:::core
            FunctionCaller["Function Caller"]:::core
            EventHandler["Event Handler"]:::core
        end

        subgraph BlockchainLayer["Blockchain Interface Layer"]
            BlockManager["Block Manager"]:::core
            TxManager["Transaction Manager"]:::core
            AccountManager["Account Manager"]:::core
        end

        subgraph NetworkLayer["Network Layer"]
            Networks["Multiple Networks"]:::core
        end
    end

    %% Protocol Implementation Layer
    subgraph ProtocolLayer["Protocol Layer"]
        UniV2["UniswapV2"]:::protocols
        UniV3["UniswapV3"]:::protocols
        ERC20["ERC20"]:::protocols
        Multicall["Multicall"]:::protocols
        CustomProtocol["Custom Protocols"]:::protocols
    end

    %% Stream Processing Layer
    subgraph StreamLayer["Stream Processing Layer"]
        EventStreams["Event Streams"]:::streams
        BlockStreams["Block Streams"]:::streams
        Pipeline["Pipeline Processing"]:::streams
        DataTransform["Data Transformers"]:::streams
    end

    %% Type System Layer
    subgraph TypeLayer["Type System Layer"]
        ContractTypes["Contract Types"]:::types
        BlockchainTypes["Blockchain Types"]:::types
        ProtocolTypes["Protocol Types"]:::types
        CustomTypes["Custom Types"]:::types
    end

    %% Relationships
    EthRPC --> Transport
    EthRPC --> ContractLayer
    EthRPC --> BlockchainLayer
    EthRPC --> NetworkLayer
    
    EthProtocols --> UniV2
    EthProtocols --> UniV3
    EthProtocols --> ERC20
    EthProtocols --> Multicall
    
    EthTypeshed --> ContractTypes
    EthTypeshed --> BlockchainTypes
    EthTypeshed --> ProtocolTypes
    
    EthStreams --> EventStreams
    EthStreams --> BlockStreams
    EthStreams --> Pipeline
    EthStreams --> DataTransform

    %% Cross-layer relationships
    ContractLayer -.-> TypeLayer
    ProtocolLayer -.-> TypeLayer
    StreamLayer -.-> CoreServices
    NetworkLayer -.-> BlockchainLayer

    %% Style Definitions
    classDef core fill:#2374ab
    classDef protocols fill:#57a773
    classDef types fill:#7b2cbf
    classDef streams fill:#ff8c42
    classDef auxiliary fill:#95a5a6

    %% Click Events
    click EthRPC "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_rpc/src/eth_rpc/"
    click EthProtocols "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_protocols/src/eth_protocols/"
    click EthTypeshed "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_typeshed/src/eth_typeshed/"
    click EthStreams "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_streams/src/eth_streams/"
    click Transport "https://github.com/empyrealapp/eth-packages/blob/main/packages/eth_rpc/src/eth_rpc/_transport.py"
    click ContractLayer "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_rpc/src/eth_rpc/contract/"
    click BlockchainLayer "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_rpc/src/eth_rpc/models/"
    click NetworkLayer "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_rpc/src/eth_rpc/networks/"
    click UniV2 "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_protocols/src/eth_protocols/uniswap_v2/"
    click UniV3 "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_protocols/src/eth_protocols/uniswap_v3/"
    click ERC20 "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_protocols/src/eth_protocols/tokens/erc20/"
    click EventHandler "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_rpc/src/eth_rpc/subscriber/"
    click Pipeline "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_streams/src/eth_streams/pipeline/"
    click TypeLayer "https://github.com/empyrealapp/eth-packages/tree/main/packages/eth_typeshed/src/eth_typeshed/types/"
```
