# block-core/angor architecture

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

- Interactive diagram: https://gitdiagram.com/block-core/angor
- Repository: https://github.com/block-core/angor

## Overview

##### Project type and purpose
- Angor is a **decentralized, full-stack P2P funding platform**. There is **no central backend**: all business logic lives in client applications (desktop, mobile, browser, Tauri wrapper) and shared libraries. Bitcoin nodes (and indexers) plus Nostr relays provide persistence and communication.

##### Top-level file‐structure analysis
- ​Clients/UI:
- src/Angor.Avalonia – cross-platform desktop/mobile (Avalonia) with CompositionRoot, Contexts (Funding, Wallet), UI features, ViewModels, Views
- src/Client – Blazor PWA (WebAssembly) hosted via wwwroot, razor pages, services, storage abstractions
- src-tauri – Rust/Tauri-based desktop wrapper exposing native capabilities to a web UI
- ​Core libraries:
- src/Shared – .NET Standard “business engine”: derivation, protocol scripts, transaction builders, application logic, services (IndexerService, NetworkService, RelayService, SignService), models
- ​Tests:
- src/Angor.Test – unit tests for protocol, derivation, services
- src/Testing – Cypress end-to-end tests for the PWA
- ​Infrastructure bootstrap:
- docker/ – ready-to-spin Docker Compose setups for Bitcoin explorers (Electrs), Nostr relays, proxy (nginx), and angor-app container

##### Key README insights
- Angor uses Bitcoin Taproot for time-locked contracts and Nostr for metadata and messaging.
- There is no monolithic server; clients interact directly with Bitcoin nodes (via JSON-RPC) and Nostr relays (via WebSocket events).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients / UI Layer
    subgraph "Clients / UI"
        direction TB
        AvaloniaApp["Avalonia Desktop/Mobile App"]:::ui
        BlazorPWA["Blazor PWA Client"]:::ui
        TauriWrapper["Tauri Desktop Wrapper"]:::ui
    end

    %% Application & Domain Layer
    subgraph "Application & Domain Layers"
        direction TB
        CompositionRoot["CompositionRoot (IoC)"]:::app
        subgraph "Application Services"
            direction TB
            InvestmentAppService["IInvestmentAppService"]:::app
            WalletAppService["IWalletAppService"]:::app
        end
        subgraph "Domain Entities & Repos"
            direction TB
            WalletEntity["Wallet Entity"]:::app
            ProjectEntity["Project Entity"]:::app
            ProjectRepo["IProjectRepository"]:::app
            InvestmentRepo["IInvestmentRepository"]:::app
        end
    end

    %% Infrastructure Adapters
    subgraph "Infrastructure Adapters & Stores"
        direction TB
        NetworkServiceNode["NetworkService (Bitcoin JSON-RPC)"]:::infra
        IndexerServiceNode["IndexerService (Electrs/Mempool)"]:::infra
        RelayServiceNode["RelayService (Nostr WebSocket)"]:::infra
        SerializerNode["Serializer (JSON/PSBT)"]:::infra
        FileStoreNode["FileStore"]:::infra
        WalletStoreNode["WalletStore"]:::infra
        EncryptionServiceNode["EncryptionService"]:::infra
    end

    %% Shared Protocol & Utilities
    subgraph "Shared Protocol & Utilities"
        direction TB
        ProjectScriptsBuilderNode["ProjectScriptsBuilder"]:::util
        InvestmentTxBuilderNode["InvestmentTransactionBuilder"]:::util
        DerivationOperationsNode["DerivationOperations"]:::util
        HdOperationsNode["HdOperations"]:::util
    end

    %% External Services
    subgraph "External Services"
        direction TB
        BitcoinNode["Bitcoin Node (RPC)"]:::ext
        IndexerAPI["Indexer (Electrs/Mempool REST)"]:::ext
        NostrRelays["Nostr Relays (WebSocket)"]:::ext
    end

    %% Docker Network
    subgraph "Docker Local Deployment"
        direction TB
        ExplorersDC["Docker: Explorers (Electrs + Bitcoin Node)"]:::ext
        RelaysDC["Docker: Nostr Relays"]:::ext
        ProxyConfig["Docker: Proxy (nginx)"]:::ext
        AngorAppDC["Docker: Angor App Container"]:::ext
    end

    %% Connections
    AvaloniaApp -->|uses| CompositionRoot
    BlazorPWA -->|uses| CompositionRoot
    TauriWrapper -->|uses| CompositionRoot

    CompositionRoot -->|injects| InvestmentAppService
    CompositionRoot -->|injects| WalletAppService

    InvestmentAppService -->|commands/queries| WalletEntity
    InvestmentAppService -->|commands/queries| ProjectEntity
    InvestmentAppService -->|uses| ProjectRepo
    InvestmentAppService -->|uses| InvestmentRepo

    WalletAppService -->|commands/queries| WalletEntity

    InvestmentAppService <-->|builds tx/scripts| ProjectScriptsBuilderNode
    InvestmentAppService <-->|builds tx| InvestmentTxBuilderNode
    WalletAppService <-->|derivation| DerivationOperationsNode
    WalletAppService <-->|hd ops| HdOperationsNode

    WalletEntity -->|persists via| FileStoreNode
    WalletEntity -->|persists via| WalletStoreNode

    ProjectRepo -->|adapter| EncryptionServiceNode

    WalletAppService -->|calls| NetworkServiceNode
    InvestmentAppService -->|calls| NetworkServiceNode
    InvestmentAppService -->|queries| IndexerServiceNode
    InvestmentAppService -->|publishes| RelayServiceNode

    NetworkServiceNode -->|HTTP/JSON-RPC| BitcoinNode
    IndexerServiceNode -->|HTTP/REST| IndexerAPI
    RelayServiceNode -->|WebSocket| NostrRelays
    FileStoreNode -->|local I/O| AvaloniaApp
    WalletStoreNode -->|local I/O| AvaloniaApp

    %% Docker connections
    AvaloniaApp ---|optional local| ExplorersDC
    AvaloniaApp ---|optional local| RelaysDC
    AvaloniaApp ---|optional local| ProxyConfig
    AvaloniaApp ---|optional local| AngorAppDC

    BlazorPWA ---|hosted via proxy| ProxyConfig
    TauriWrapper ---|bundled| AngorAppDC

    ExplorersDC --> BitcoinNode
    RelaysDC --> NostrRelays

    %% Click Events
    click AvaloniaApp "https://github.com/block-core/angor/tree/main/src/Angor/Avalonia/AngorApp"
    click BlazorPWA "https://github.com/block-core/angor/tree/main/src/Angor/Client"
    click TauriWrapper "https://github.com/block-core/angor/tree/main/src-tauri"
    click CompositionRoot "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/AngorApp/Composition/CompositionRoot.cs"
    click InvestmentAppService "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Funding/Investor/IInvestmentAppService.cs"
    click WalletAppService "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Wallet/Application/IWalletAppService.cs"
    click WalletEntity "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Wallet/Domain/Wallet.cs"
    click ProjectEntity "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Funding/Projects/Domain/Project.cs"
    click ProjectRepo "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Funding/Projects/Domain/IProjectRepository.cs"
    click InvestmentRepo "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Funding/Projects/Domain/IInvestmentRepository.cs"
    click NetworkServiceNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Services/NetworkService.cs"
    click IndexerServiceNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Services/IndexerService.cs"
    click RelayServiceNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Services/RelayService.cs"
    click SerializerNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Services/Serializer.cs"
    click FileStoreNode "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Wallet/Infrastructure/Impl/FileStore.cs"
    click WalletStoreNode "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Wallet/Infrastructure/Impl/WalletStore.cs"
    click EncryptionServiceNode "https://github.com/block-core/angor/blob/main/src/Angor/Avalonia/Angor.Contexts.Funding/Projects/Infrastructure/Impl/EncryptionService.cs"
    click ProjectScriptsBuilderNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Protocol/Scripts/ProjectScriptsBuilder.cs"
    click InvestmentTxBuilderNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/Protocol/TransactionBuilders/InvestmentTransactionBuilder.cs"
    click DerivationOperationsNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/DerivationOperations.cs"
    click HdOperationsNode "https://github.com/block-core/angor/blob/main/src/Angor/Shared/HdOperations.cs"
    click ExplorersDC "https://github.com/block-core/angor/blob/main/docker/explorers/angornet/docker-compose.yml"
    click RelaysDC "https://github.com/block-core/angor/blob/main/docker/relays/docker-compose.yml"
    click ProxyConfig "https://github.com/block-core/angor/blob/main/docker/proxy/nginx.conf"
    click AngorAppDC "https://github.com/block-core/angor/blob/main/docker/angor-app/docker-compose.yml"

    %% Styles
    classDef ui fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef app fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef infra fill:#e0ccff,stroke:#333,stroke-width:1px
    classDef util fill:#ffebcc,stroke:#333,stroke-width:1px
    classDef ext fill:#dddddd,stroke:#333,stroke-width:1px
```
