# tari-project/tari-dan architecture

> Architecture diagram of the GitHub repository tari-project/tari-dan, 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-dan
- Repository: https://github.com/tari-project/tari-dan

## Overview

##### High-Level Components

a) Application Layer
- Validator Node
- Wallet Daemon
- CLI Tools
- Web UIs
- Indexer
- Signaling Server

b) Core Protocol Layer
- Consensus (HotStuff implementation)
- Transaction Processing
- State Management
- Template Engine
- Cryptography

c) Networking Layer
- P2P Communication
- RPC Framework
- LibP2P Implementation
- Message Handling

d) Storage Layer
- SQLite Implementations
- State Store
- Transaction Store
- Message Logging

##### Key Architectural Elements

a) Validator Node Architecture:
**[Web UI] <-> [JSON-RPC API] <-> [Validator Node Core]**

- [Consensus] <-> [State Machine] <-> [Template Engine]

- [P2P Network] <-> [Storage]

b) Wallet Architecture:
**[CLI/Web UI] <-> [Wallet Daemon] <-> [SDK]**

- [Key Management] <-> [Transaction Builder]

- [Storage Layer]

##### Implementation Details

- HotStuff consensus implementation
- WASM template execution
- LibP2P networking
- SQLite storage backends
- RPC framework

##### Cross-Cutting Concerns

Shared services like:
- Logging
- Metrics
- Configuration
- Security

##### External Dependencies

Interaction points with:
- Base Tari network
- IPFS/HTTP (for template storage)
- Tor network

This architecture reflects a complex distributed system with multiple interaction points and careful consideration of security, scalability, and reliability concerns.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef ui fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef network fill:#D6F5D6,stroke:#33CC33
    classDef storage fill:#E5CCE5,stroke:#993399
    classDef crypto fill:#FFD6CC,stroke:#FF6666
    
    subgraph Application["Application Layer"]
        VN["Validator Node"]:::ui
        WD["Wallet Daemon"]:::ui
        CLI["CLI Tools"]:::ui
        WebUI["Web UIs"]:::ui
        IDX["Indexer"]:::ui
        SS["Signaling Server"]:::ui
    end

    subgraph Protocol["Core Protocol Layer"]
        CONS["Consensus (HotStuff)"]:::core
        TP["Transaction Processing"]:::core
        SM["State Management"]:::core
        TE["Template Engine"]:::core
        CRYPT["Cryptography"]:::crypto
    end

    subgraph Network["Networking Layer"]
        P2P["P2P Communication"]:::network
        RPC["RPC Framework"]:::network
        LP2P["LibP2P Implementation"]:::network
        MH["Message Handling"]:::network
    end

    subgraph Storage["Storage Layer"]
        SQL["SQLite Implementations"]:::storage
        SS["State Store"]:::storage
        TS["Transaction Store"]:::storage
        ML["Message Logging"]:::storage
    end

    %% Connections
    VN --> CONS
    VN --> TP
    WD --> TP
    CLI --> VN
    WebUI --> VN
    WebUI --> WD
    IDX --> SS
    
    CONS --> SM
    CONS --> P2P
    TP --> SM
    TP --> TE
    SM --> SS
    
    P2P --> LP2P
    P2P --> MH
    RPC --> MH
    
    SM --> SQL
    TS --> SQL
    ML --> SQL

    %% Click events
    click VN "https://github.com/tari-project/tari-dan/tree/development/applications/tari_validator_node/"
    click WD "https://github.com/tari-project/tari-dan/tree/development/applications/tari_dan_wallet_daemon/"
    click CLI "https://github.com/tari-project/tari-dan/tree/development/applications/tari_validator_node_cli/"
    click WebUI "https://github.com/tari-project/tari-dan/tree/development/applications/tari_validator_node_web_ui/"
    click IDX "https://github.com/tari-project/tari-dan/tree/development/applications/tari_indexer/"
    click SS "https://github.com/tari-project/tari-dan/tree/development/applications/tari_signaling_server/"
    click CONS "https://github.com/tari-project/tari-dan/tree/development/dan_layer/consensus/"
    click TE "https://github.com/tari-project/tari-dan/tree/development/dan_layer/engine/"
    click SM "https://github.com/tari-project/tari-dan/tree/development/dan_layer/state_store_sqlite/"
    click P2P "https://github.com/tari-project/tari-dan/tree/development/networking/libp2p-peersync/"
    click LP2P "https://github.com/tari-project/tari-dan/tree/development/networking/libp2p-messaging/"
    click RPC "https://github.com/tari-project/tari-dan/tree/development/networking/rpc_framework/"
    click SQL "https://github.com/tari-project/tari-dan/tree/development/dan_layer/storage_sqlite/"
    click SS "https://github.com/tari-project/tari-dan/tree/development/dan_layer/state_store_sqlite/"
    click TP "https://github.com/tari-project/tari-dan/tree/development/dan_layer/transaction/"
    click CRYPT "https://github.com/tari-project/tari-dan/tree/development/dan_layer/wallet/crypto/"
    click ML "https://github.com/tari-project/tari-dan/tree/development/networking/sqlite_message_logger/"

    %% Legend
    classDef legend fill:#F5F5F5,stroke:#333
    class Application,Protocol,Network,Storage legend
```
