# mofalabs/sui architecture

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

- Interactive diagram: https://gitdiagram.com/mofalabs/sui
- Repository: https://github.com/mofalabs/sui

## Overview

##### Project Type and Purpose
This is a Dart SDK library project that provides interfaces to interact with the Sui blockchain network. It's primarily a client-side library with multiple components for blockchain interactions.

##### Main Components

A. Core SDK Components (Primary Layer):
- Transaction Builder System
- Cryptography Module
- RPC Providers
- Account Management
- WebSocket Client

B. Supporting Components (Secondary Layer):
- BCS (Binary Canonical Serialization)
- HTTP Clients
- Model Definitions
- Type Systems
- ZK Login Support

**[Application Layer]**
- ^

**[Sui Dart SDK]**

- [Core Components]--------------------

- Account   Transaction  Signers    Providers
- Manager    Builder                (RPC/WS)

- [Cryptography]---------------------

- Ed25519   Secp256    MultiSig

- [Serialization & Types]------------

- BCS      Models      Types

- [Communication]--------------------

- HTTP      WebSocket   Faucet

- [Utils & Helpers]------------------

- Bech32     Hex        Error

**[Sui Blockchain Network]**

##### Key Relationships to Highlight

- How Transaction Builder interacts with Cryptography modules for signing
- Relationship between RPC Providers and HTTP/WebSocket clients
- Demonstrate how Account Management integrates with the Cryptography layer
- BCS serialization flow for transaction processing

##### Implementation Details

a. Core Features:
- Account creation and management
- Transaction building and signing
- Network communication (RPC/WebSocket)
- Cryptographic operations

b. Supporting Features:
- Event subscription system
- Faucet interaction
- Object and coin management
- Checkpoint queries

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application Layer"
        APP[Client Applications]
    end

    subgraph "Sui Dart SDK"
        CORE[Core Client]:::core
        
        subgraph "Core Components"
            ACCOUNT[Account Manager]:::core
            TXBUILDER[Transaction Builder]:::core
            SIGNER[Signers]:::core
            PROVIDER[Providers]:::core
        end

        subgraph "Cryptography"
            CRYPTO[Cryptography Module]:::crypto
            MULTISIG[Multi-signature]:::crypto
            ZKLOGIN[ZK Login]:::crypto
        end

        subgraph "Serialization & Types"
            BCS[BCS Serialization]:::data
            MODELS[Models]:::data
            TYPES[Types]:::data
        end

        subgraph "Communication"
            HTTP[HTTP Client]:::comm
            WS[WebSocket Client]:::comm
        end

        subgraph "Utils & Helpers"
            UTILS[Utilities]:::util
        end
    end

    subgraph "Sui Network"
        BLOCKCHAIN[Sui Blockchain]
    end

    %% Relationships
    APP --> CORE
    CORE --> ACCOUNT
    CORE --> PROVIDER
    CORE --> TXBUILDER
    
    TXBUILDER --> CRYPTO
    TXBUILDER --> BCS
    TXBUILDER --> SIGNER
    
    ACCOUNT --> CRYPTO
    ACCOUNT --> MULTISIG
    
    PROVIDER --> HTTP
    PROVIDER --> WS
    
    HTTP --> BLOCKCHAIN
    WS --> BLOCKCHAIN
    
    MODELS --> TYPES
    SIGNER --> CRYPTO
    SIGNER --> ZKLOGIN
    
    %% Click events
    click TXBUILDER "https://github.com/mofalabs/sui/tree/main/lib/builder/"
    click CRYPTO "https://github.com/mofalabs/sui/tree/main/lib/cryptography/"
    click PROVIDER "https://github.com/mofalabs/sui/tree/main/lib/providers/"
    click ACCOUNT "https://github.com/mofalabs/sui/blob/main/lib/sui_account.dart"
    click WS "https://github.com/mofalabs/sui/blob/main/lib/rpc/websocket_client.dart"
    click BCS "https://github.com/mofalabs/sui/tree/main/lib/bcs/"
    click HTTP "https://github.com/mofalabs/sui/tree/main/lib/http/"
    click MODELS "https://github.com/mofalabs/sui/tree/main/lib/models/"
    click TYPES "https://github.com/mofalabs/sui/tree/main/lib/types/"
    click ZKLOGIN "https://github.com/mofalabs/sui/tree/main/lib/zklogin/"
    click SIGNER "https://github.com/mofalabs/sui/tree/main/lib/signers/"
    click UTILS "https://github.com/mofalabs/sui/tree/main/lib/utils/"
    click MULTISIG "https://github.com/mofalabs/sui/tree/main/lib/multisig/"
    click CORE "https://github.com/mofalabs/sui/blob/main/lib/sui_client.dart"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef crypto fill:#4CAF50,stroke:#2E7D32,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef comm fill:#FF5722,stroke:#E64A19,color:white
    classDef util fill:#9C27B0,stroke:#7B1FA2,color:white
```
