# textileio/ipc architecture

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

- Interactive diagram: https://gitdiagram.com/textileio/ipc
- Repository: https://github.com/textileio/ipc

## Overview

##### Main Components

a) Core Layer Components:
- IPC CLI (`ipc/cli`) - User interface component
- IPC Provider (`ipc/provider`) - Core interaction library
- Fendermint - Subnet implementation using Tendermint
- Smart Contracts (`contracts/`) - IPC protocol actors
- IPLD Resolver (`ipld/resolver`) - Content addressing system

b) Runtime Components:
- Subnet Management System
- Cross-chain Communication Layer
- Wallet Management System
- Consensus Layer (Tendermint Core)

##### Architectural Patterns to Highlight

a) Hierarchical Structure:
- Root Network (e.g., Filecoin Calibration)
- Subnet Hierarchy
- Cross-subnet Communication Channels

b) Actor Model:
- Gateway Actor
- Subnet Actor
- Registry Actor

**[IPC CLI] ←→ [Configuration Management]**

**[IPC Provider] ←→ [Wallet Management] ←→ [IPLD Resolver]**

**[Fendermint Node] ←→ [Consensus Engine] ←→ [State Machine]**

**[Gateway Contracts] ←→ [Subnet Contracts] ←→ [Registry Contracts]**

##### Key Interactions

- Cross-chain message flow
- Checkpoint synchronization
- Validator set management
- Subnet creation and management
- IPLD content resolution

##### Additional Elements

Specific annotations for:
- Security boundaries
- Cross-chain message paths
- Consensus participation flows
- State synchronization mechanisms
- External network interfaces

##### Technical Details

- WebAssembly runtime integration
- EVM compatibility layer
- Tendermint consensus integration
- IPLD-based content addressing
- Cross-chain messaging protocols

##### Implementation Notes

- Modular architecture allowing different consensus algorithms
- Recursive scalability through subnet hierarchy
- Integration with existing blockchain networks
- Security and validation boundaries
- State management and synchronization

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef cli fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef contract fill:#f1c40f,stroke:#f39c12,color:black
    classDef network fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interaction Layer
    subgraph User_Layer
        CLI["IPC CLI"]:::cli
        Config["Configuration Management"]:::cli
    end

    %% Core Services Layer
    subgraph Core_Services
        Provider["IPC Provider"]:::core
        Wallet["Wallet Management"]:::core
        IPLD["IPLD Resolver"]:::storage
        CrossChain["Cross-chain Communication"]:::core
        SubnetMgmt["Subnet Management"]:::core
    end

    %% Runtime Layer
    subgraph Runtime
        Fendermint["Fendermint Node"]:::core
        Consensus["Consensus Engine"]:::network
        StateMgmt["State Management"]:::storage
        EVMInt["EVM Integration"]:::core
        Checkpoint["Checkpoint System"]:::core
    end

    %% Smart Contracts Layer
    subgraph Contracts
        Gateway["Gateway Actor"]:::contract
        Subnet["Subnet Actor"]:::contract
        Registry["Registry Actor"]:::contract
    end

    %% External Systems
    FilecoinNet["Filecoin Network"]:::external

    %% Relationships
    CLI --> Config
    CLI --> Provider
    Provider --> Wallet
    Provider --> IPLD
    Provider --> CrossChain
    Provider --> SubnetMgmt
    
    CrossChain --> Fendermint
    SubnetMgmt --> Fendermint
    
    Fendermint --> Consensus
    Fendermint --> StateMgmt
    Fendermint --> EVMInt
    Fendermint --> Checkpoint
    
    Checkpoint --> Gateway
    Gateway --> Subnet
    Subnet --> Registry
    
    Registry --> FilecoinNet

    %% Click Events
    click CLI "https://github.com/textileio/ipc/tree/develop/ipc/cli/"
    click Provider "https://github.com/textileio/ipc/tree/develop/ipc/provider/"
    click Fendermint "https://github.com/textileio/ipc/tree/develop/fendermint/"
    click IPLD "https://github.com/textileio/ipc/tree/develop/ipld/resolver/"
    click Gateway "https://github.com/textileio/ipc/tree/develop/contracts/src/gateway/"
    click Subnet "https://github.com/textileio/ipc/tree/develop/contracts/src/subnet/"
    click Registry "https://github.com/textileio/ipc/tree/develop/contracts/src/subnetregistry/"
    click Wallet "https://github.com/textileio/ipc/tree/develop/ipc/wallet/"
    click CrossChain "https://github.com/textileio/ipc/blob/develop/ipc/api/src/cross.rs"
    click SubnetMgmt "https://github.com/textileio/ipc/blob/develop/ipc/api/src/subnet.rs"
    click Consensus "https://github.com/textileio/ipc/tree/develop/fendermint/abci/"
    click EVMInt "https://github.com/textileio/ipc/tree/develop/fendermint/eth/"
    click StateMgmt "https://github.com/textileio/ipc/tree/develop/fendermint/vm/"
    click Checkpoint "https://github.com/textileio/ipc/blob/develop/ipc/api/src/checkpoint.rs"

    %% Legend
    subgraph Legend
        L1["User Interface"]:::cli
        L2["Core Components"]:::core
        L3["Smart Contracts"]:::contract
        L4["Network & Consensus"]:::network
        L5["Storage"]:::storage
        L6["External Systems"]:::external
    end
```
