# vultisig/vultiserver architecture

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

- Interactive diagram: https://gitdiagram.com/vultisig/vultiserver
- Repository: https://github.com/vultisig/vultiserver

## Overview

##### Main Components

a. External Interface Layer:
- HTTP API Server (api/server.go)
- Client Applications (Mobile/Web)
- Email Service Integration (Mandrill)

b. Core Services:
- TSS Worker Service
- Vault Management Service
- Key Management Service
- Relay Service

c. Storage Layer:
- Redis Storage
- Block Storage

d. Supporting Components:
- Chain Helpers (for different blockchain implementations)
- Wallet Core Integration
- Context Management

##### Component Relationships and Data Flow

**[Client Applications] ←→ [API Server]**
- ↓
**[Service Layer (TSS, Reshare, Worker)]**
- ↓
**[Chain Helpers & Wallet Core]**
- ↓
**[Storage Layer (Redis & Block Storage)]**

##### Specific Implementation Details

a. API Layer (Blue):
- HTTP endpoints (/vault/create, /vault/sign, /vault/reshare)
- Authentication/Authorization flow
- Request validation

b. Service Layer (Green):
- TSS Service (service/tss.go)
- Worker Service (service/worker.go)
- Reshare Service (service/reshare.go)
- Mandrill Email Service (service/mandrill.go)

c. Chain Support Layer (Yellow):
- EVM Helper
- UTXO Helper
- Cosmos Helper
- THORChain Helper

d. Storage Layer (Purple):
- Redis Storage Implementation
- Block Storage Implementation

##### Integration Points

- Wallet Core Integration (walletcore/)
- External Chain Interactions (chainhelper/)
- Email Service Integration
- Redis Connection

##### Security Components

Security-related elements:
- Encryption/Decryption flows
- Vault Share Management
- Password Protection
- Session Management

##### Specific Notations

Use these symbols:
- 🔒 for security-related components
- 🔄 for asynchronous operations
- 💾 for storage operations
- 🌐 for network interfaces

##### Implementation Details to Highlight

- 2/2 and 2/3 vault configurations
- TSS protocol flow
- Generation and signing paths
- Resharing process flow

Remember to:
- Version information
- Document all interfaces
- Error handling paths
- Monitoring points

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "External Interface Layer"
        Client["Client Applications (Mobile/Web)"]
        APIServer["HTTP API Server"]:::api
        EmailService["Email Service (Mandrill)"]:::email
    end

    subgraph "Core Services Layer"
        TSSService["TSS Service"]:::service
        WorkerService["Worker Service"]:::service
        ReshareService["Reshare Service"]:::service
        RelayService["Relay Service"]:::relay
    end

    subgraph "Chain Support Layer"
        ChainHelpers["Chain Helpers"]:::chainhelper
        EVMHelper["EVM Helper"]:::chainhelper
        UTXOHelper["UTXO Helper"]:::chainhelper
        CosmosHelper["Cosmos Helper"]:::chainhelper
        ThorchainHelper["THORChain Helper"]:::chainhelper
    end

    subgraph "Storage Layer"
        RedisStorage[(Redis Storage)]:::storage
        BlockStorage[(Block Storage)]:::storage
    end

    subgraph "Integration Layer"
        WalletCore["Wallet Core"]:::integration
        ContextMgmt["Context Management"]:::integration
    end

    %% Relationships
    Client <--> APIServer
    APIServer --> TSSService
    APIServer --> WorkerService
    APIServer --> ReshareService
    EmailService --> Client

    TSSService --> ChainHelpers
    TSSService --> WalletCore
    WorkerService --> RedisStorage
    WorkerService --> BlockStorage
    
    ChainHelpers --> EVMHelper
    ChainHelpers --> UTXOHelper
    ChainHelpers --> CosmosHelper
    ChainHelpers --> ThorchainHelper

    RelayService --> ContextMgmt
    
    %% Click Events
    click APIServer "https://github.com/vultisig/VultiServer/blob/main/api/server.go"
    click TSSService "https://github.com/vultisig/VultiServer/blob/main/service/tss.go"
    click WorkerService "https://github.com/vultisig/VultiServer/blob/main/service/worker.go"
    click ReshareService "https://github.com/vultisig/VultiServer/blob/main/service/reshare.go"
    click EmailService "https://github.com/vultisig/VultiServer/blob/main/service/mandrill.go"
    click ChainHelpers "https://github.com/vultisig/VultiServer/tree/main/chainhelper/"
    click EVMHelper "https://github.com/vultisig/VultiServer/blob/main/chainhelper/evm_helper.go"
    click UTXOHelper "https://github.com/vultisig/VultiServer/blob/main/chainhelper/utxo_helper.go"
    click CosmosHelper "https://github.com/vultisig/VultiServer/blob/main/chainhelper/cosmos.go"
    click ThorchainHelper "https://github.com/vultisig/VultiServer/blob/main/chainhelper/thorchain.go"
    click RedisStorage "https://github.com/vultisig/VultiServer/blob/main/storage/redis_storage.go"
    click BlockStorage "https://github.com/vultisig/VultiServer/blob/main/storage/block_storage.go"
    click RelayService "https://github.com/vultisig/VultiServer/tree/main/relay/"
    click WalletCore "https://github.com/vultisig/VultiServer/tree/main/walletcore/core/"
    click ContextMgmt "https://github.com/vultisig/VultiServer/blob/main/contexthelper/context.go"

    %% Styling
    classDef api fill:#2374ab
    classDef service fill:#2a9d8f
    classDef chainhelper fill:#e9c46a
    classDef storage fill:#8338ec
    classDef integration fill:#fb8500
    classDef email fill:#06d6a0
    classDef relay fill:#ef476f

    %% Legend
    subgraph Legend
        L1["API Component"]:::api
        L2["Service Component"]:::service
        L3["Chain Helper"]:::chainhelper
        L4["Storage Component"]:::storage
        L5["Integration Component"]:::integration
        L6["Email Service"]:::email
        L7["Relay Service"]:::relay
    end
```
