# tari-project/tari architecture

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

- Interactive diagram: https://gitdiagram.com/tari-project/tari
- Repository: https://github.com/tari-project/tari

## Overview

##### High-Level Architecture Components

a) Core Protocol Layer:
- Base Node (Blockchain)
- Mempool
- Consensus Engine
- Transaction Processing
- Proof of Work (SHA3 and RandomX/Monero merge mining)

b) Network Layer:
- P2P Communication
- DHT (Distributed Hash Table)
- Tor Integration
- gRPC Services

c) Wallet Layer:
- Console Wallet
- Key Management
- Transaction Services
- Output Management

d) Mining Components:
- SHA3 Miner
- Merge Mining Proxy
- Integration with XMRig

##### Component Relationships

Key interactions:

**Base Node <-> P2P Network <-> Other Nodes**
- ↑          ↑

**Wallet Services  Mempool**
- ↑          ↑

**Console Wallet   Miners**

##### Specific Implementation Details

Technical elements:

- gRPC interfaces between components
- Tor transport layer
- Database backends (LMDB, SQLite)
- Cryptographic components (RandomX, SHA3)
- MMR (Merkle Mountain Range) structures

##### Key Subsystems to Highlight

Detail these critical subsystems:

a) Mining Infrastructure:
**SHA3 Miner -> Base Node**
**Merge Mining Proxy -> Monero Network**
- > Tari Network

b) Wallet Architecture:
**Console Wallet -> Key Manager**
- > Output Manager
- > Transaction Service

c) Network Communication:
**Tor Transport -> P2P Layer -> DHT**
- > gRPC Services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef network fill:#98fb98,stroke:#333,stroke-width:2px
    classDef wallet fill:#fff68f,stroke:#333,stroke-width:2px
    classDef mining fill:#ffa07a,stroke:#333,stroke-width:2px
    classDef security fill:#ff6b6b,stroke:#333,stroke-width:2px
    classDef storage fill:#deb887,stroke:#333,stroke-width:2px

    %% Core Protocol Layer
    subgraph CoreLayer["Core Protocol Layer"]
        BaseNode["Base Node"]:::core
        Mempool["Mempool"]:::core
        ConsensusEngine["Consensus Engine"]:::core
        TxProcessing["Transaction Processing"]:::core
        PoW["Proof of Work"]:::core
        ChainStorage["Chain Storage"]:::storage
        BlockValidation["Block Validation"]:::core
        MMR["Merkle Mountain Range"]:::core
    end

    %% Network Layer
    subgraph NetworkLayer["Network Layer"]
        P2P["P2P Communication"]:::network
        DHT["DHT"]:::network
        Tor["Tor Integration"]:::security
        GRPC["gRPC Services"]:::network
    end

    %% Wallet Layer
    subgraph WalletLayer["Wallet Layer"]
        ConsoleWallet["Console Wallet"]:::wallet
        KeyMgmt["Key Management"]:::wallet
        TxServices["Transaction Services"]:::wallet
        OutputMgmt["Output Management"]:::wallet
    end

    %% Mining Components
    subgraph MiningLayer["Mining Layer"]
        SHA3Miner["SHA3 Miner"]:::mining
        MergeMiningProxy["Merge Mining Proxy"]:::mining
        XMRIntegration["XMRig Integration"]:::mining
    end

    %% Relationships
    BaseNode <--> P2P
    P2P <--> DHT
    P2P <--> Tor
    BaseNode <--> Mempool
    Mempool <--> TxProcessing
    BaseNode <--> ConsensusEngine
    BaseNode <--> ChainStorage
    BaseNode <--> BlockValidation
    BaseNode <--> MMR
    
    ConsoleWallet <--> KeyMgmt
    ConsoleWallet <--> TxServices
    ConsoleWallet <--> OutputMgmt
    TxServices <--> BaseNode
    
    SHA3Miner --> BaseNode
    MergeMiningProxy --> BaseNode
    MergeMiningProxy --> XMRIntegration
    
    GRPC --> BaseNode
    GRPC --> ConsoleWallet

    %% Click events
    click BaseNode "https://github.com/tari-project/tari/tree/development/base_layer/core/src/base_node/"
    click Mempool "https://github.com/tari-project/tari/tree/development/base_layer/core/src/mempool/"
    click ConsensusEngine "https://github.com/tari-project/tari/tree/development/base_layer/core/src/consensus/"
    click TxProcessing "https://github.com/tari-project/tari/tree/development/base_layer/core/src/transactions/"
    click PoW "https://github.com/tari-project/tari/tree/development/base_layer/core/src/proof_of_work/"
    click P2P "https://github.com/tari-project/tari/tree/development/comms/core/"
    click DHT "https://github.com/tari-project/tari/tree/development/comms/dht/"
    click Tor "https://github.com/tari-project/tari/tree/development/comms/core/src/tor/"
    click GRPC "https://github.com/tari-project/tari/tree/development/applications/minotari_app_grpc/"
    click ConsoleWallet "https://github.com/tari-project/tari/tree/development/applications/minotari_console_wallet/"
    click KeyMgmt "https://github.com/tari-project/tari/tree/development/base_layer/key_manager/"
    click TxServices "https://github.com/tari-project/tari/tree/development/base_layer/wallet/src/transaction_service/"
    click OutputMgmt "https://github.com/tari-project/tari/tree/development/base_layer/wallet/src/output_manager_service/"
    click SHA3Miner "https://github.com/tari-project/tari/tree/development/applications/minotari_miner/"
    click MergeMiningProxy "https://github.com/tari-project/tari/tree/development/applications/minotari_merge_mining_proxy/"
    click XMRIntegration "https://github.com/tari-project/tari/tree/development/base_layer/core/src/proof_of_work/monero_rx/"
    click ChainStorage "https://github.com/tari-project/tari/tree/development/base_layer/core/src/chain_storage/"
    click BlockValidation "https://github.com/tari-project/tari/tree/development/base_layer/core/src/validation/"
    click MMR "https://github.com/tari-project/tari/tree/development/base_layer/mmr/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Network Components"]:::network
        L3["Wallet Components"]:::wallet
        L4["Mining Components"]:::mining
        L5["Security Components"]:::security
        L6["Storage Components"]:::storage
    end
```
