# jamesatomc/kanari-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/jamesatomc/kanari-sdk
- Repository: https://github.com/jamesatomc/kanari-sdk

## Overview

##### Main Components Identification

The system should be represented as a layered architecture with these key components:

a. Application Layer
- Web Explorer (web/kari-explorer)
- CLI Tools (crates/command)
- RPC API (crates/rpc)

b. Framework Layer
- Kanari Framework (framework/kanari-framework)
- Move Standard Library (framework/move-stdlib)
- System Framework (framework/kanari-system)

c. Core Layer
- K2 Core (crates/core/k2)
- Transaction Management
- State Management
- Move VM Runtime
- Move Compiler
- Consensus Mechanisms (consensus/pos and consensus/pow)

d. Network Layer
- P2P Network (crates/core/p2p)
- RPC Network (crates/core/network)

e. Storage Layer
- Wallet Management (crates/core/wallet)
- File Storage (monaos/mona-storage)
- State Database

**[Application Layer]**
- ↓
**[Framework Layer]**
- ↓
**[Core Layer]**
- ↙     ↘
**[Network]  [Storage]**

##### Critical Flows to Highlight

a. Transaction Flow:
**CLI/RPC → Transaction Management → Consensus → State Management → Storage**

b. Smart Contract Execution:
**Framework → Move VM → State Management**

##### Component Details

For each component, include:
- Component name
- Primary responsibility
- Key interfaces/APIs
- Dependencies on other components

##### Additional Elements

Supporting elements:
- Version information
- Key external dependencies
- System requirements

##### Implementation Notes

- The modular nature of the system (separate crates)
- The dual consensus mechanism support (PoW/PoS)
- The Move language integration
- The separation between core blockchain logic and application interfaces

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef application fill:#e3f2fd,stroke:#1565c0
    classDef framework fill:#e8f5e9,stroke:#2e7d32
    classDef core fill:#fff8e1,stroke:#f9a825
    classDef network fill:#fce4ec,stroke:#c2185b
    classDef storage fill:#f3e5f5,stroke:#7b1fa2
    classDef default stroke-width:2px

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        WebExplorer["Web Explorer"]
        CLI["CLI Tools"]
        RPC["RPC API"]
    end

    %% Framework Layer
    subgraph FrameworkLayer["Framework Layer"]
        KanariFramework["Kanari Framework"]
        MoveStdLib["Move Standard Library"]
        SystemFramework["System Framework"]
    end

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        K2Core["K2 Core"]
        TxMgmt["Transaction Management"]
        StateMgmt["State Management"]
        MoveVM["Move VM Runtime"]
        MoveCompiler["Move Compiler"]
        
        subgraph Consensus["Consensus"]
            PoS["Proof of Stake"]
            PoW["Proof of Work"]
        end
    end

    %% Network Layer
    subgraph NetworkLayer["Network Layer"]
        P2P["P2P Network"]
        RPCNetwork["RPC Network"]
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        Wallet["Wallet Management"]
        FileStorage["File Storage"]
        StateDB["State Database"]
    end

    %% Relationships
    WebExplorer --> RPC
    CLI --> RPC
    RPC --> K2Core
    
    KanariFramework --> MoveVM
    MoveStdLib --> MoveVM
    SystemFramework --> MoveVM
    
    K2Core --> TxMgmt
    TxMgmt --> Consensus
    Consensus --> StateMgmt
    StateMgmt --> StateDB
    
    MoveVM --> StateMgmt
    MoveCompiler --> MoveVM
    
    K2Core --> P2P
    K2Core --> RPCNetwork
    
    StateMgmt --> FileStorage
    TxMgmt --> Wallet

    %% Click Events
    click WebExplorer "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/web/kari-explorer/"
    click CLI "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/command/"
    click RPC "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/rpc/rpc-api/"
    click KanariFramework "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/framework/kanari-framework/"
    click MoveStdLib "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/framework/move-stdlib/"
    click SystemFramework "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/framework/kanari-system/"
    click K2Core "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/core/k2/"
    click TxMgmt "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/core/k2/src/transaction/"
    click PoS "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/consensus/pos/"
    click PoW "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/consensus/pow/"
    click P2P "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/core/p2p/"
    click RPCNetwork "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/core/network/"
    click Wallet "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/crates/core/wallet/"
    click FileStorage "https://github.com/jamesatomc/kanari-sdk/tree/kanari-sdk/monaos/mona-storage/"

    %% Style Applications
    class WebExplorer,CLI,RPC application
    class KanariFramework,MoveStdLib,SystemFramework framework
    class K2Core,TxMgmt,StateMgmt,MoveVM,MoveCompiler,PoS,PoW core
    class P2P,RPCNetwork network
    class Wallet,FileStorage,StateDB storage
```
