# digital-asset/decentralized-canton-sync architecture

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

- Interactive diagram: https://gitdiagram.com/digital-asset/decentralized-canton-sync
- Repository: https://github.com/digital-asset/decentralized-canton-sync

## Overview

##### Project type and purpose
- This is a full-stack, microservice reference application suite (“Splice”) for operating and governing public Canton synchronizers with on-chain payment utilities (“Amulets”).
- Key features: name service (Ans), payment scan, split-well group payments, synchronizer governance (SV), on-chain validator APIs, wallet service.

##### Main components
a. Frontend SPAs (React/TypeScript)
– apps/ans/frontend, apps/scan/frontend, apps/splitwell/frontend, apps/sv/frontend, apps/validator (public UI parts), apps/wallet/frontend
– Share common UI code in apps/common/frontend and test utilities in apps/common/frontend-test-*
b. Backend services (Scala/Akka HTTP + Daml/Canton)
– apps/app (console & orchestrator), apps/ans, apps/scan, apps/splitwell, apps/sv, apps/validator, apps/wallet
– Each has src/main/scala with HTTP handlers, automation triggers, store/db migrations, OpenAPI/gRPC clients
– apps/common contains shared Scala libraries: config, store, automation, auth, metrics
c. Daml smart contract models
– daml/ directory holds DARs and Daml code for amulets, name service, token standards, test suites
d. Data storage
- Postgres (ledger‐api storage, service stores, migrations under apps/common/src/main/resources/db/migration)
e. Canton synchronizer cluster
- cluster/ and cluster/helm/ define Docker & Helm charts for CometBFT, Canton nodes (domain, participants, mediators) and service deployments (ans, scan, wallet, splitwell, sv, validator)
f. External services
- Auth0 (OAuth for wallet and governance),
- Metrics/monitoring: Prometheus & Grafana (dashboards in cluster/pulumi/grafana-dashboards),
- Toxiproxy (in tests),
- Nginx ingress (public HTTP).

##### Relationships & interactions
- Browser → Frontend SPA (HTTPS) → Backend HTTP/gRPC API → Canton Ledger API (gRPC) → Postgres
- Backend Automation triggers (Scala) invoke Canton client code to drive on-chain governance, ingestion, snapshotting
- Cluster Helm deploys microservices alongside Canton synchronizer nodes and Postgres; Nginx/Ingress routes external traffic
- Shared common libraries link into each service at build time

##### Architectural patterns & principles
- Microservices: each domain (Ans, Scan, Splitwell, SV, Validator, Wallet) is its own service with UI + API + automation
- Daml/Canton: on-chain data model + consensus layer separate from service APIs
- CQRS‐style separation: services read from ledger API storage and write to ledger via Canton gRPC
- Shared libraries for cross‐cutting concerns: auth, config, metrics, store, automation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Browser
    Browser["Browser"]:::external

    %% Frontend SPAs
    subgraph "Frontend SPAs"
        direction TB
        AnsFE["Ans SPA"]:::frontend
        ScanFE["Scan SPA"]:::frontend
        SplitwellFE["Split-well SPA"]:::frontend
        SVFE["SV SPA"]:::frontend
        ValidatorFE["Validator UI"]:::frontend
        WalletFE["Wallet SPA"]:::frontend
    end

    %% Backend Microservices
    subgraph "Backend Microservices"
        direction TB
        Orchestrator["Orchestrator/Console Service"]:::backend
        AnsAPI["Ans API Service"]:::backend
        ScanAPI["Scan API Service"]:::backend
        SplitwellAPI["Split-well API Service"]:::backend
        SvAPI["SV API Service"]:::backend
        ValidatorAPI["Validator API Service"]:::backend
        WalletAPI["Wallet API Service"]:::backend
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        ScalaCommon["Scala Common Libs"]:::shared
        FECommon["Frontend Common Code"]:::shared
        FETestUtils["Frontend Test Utils"]:::shared
    end

    %% Daml Ledger & Canton Cluster
    subgraph "Canton/Daml Ledger Cluster"
        direction TB
        Daml["Daml Smart Contracts"]:::ledger
        HelmCharts["Helm Charts"]:::ledger
        DockerCompose["Docker Compose"]:::ledger
    end

    %% Database
    Postgres["Postgres DB"]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        Auth0["Auth0 (OAuth2)"]:::external
        PromGraf["Prometheus & Grafana"]:::external
        Toxiproxy["Toxiproxy in Tests"]:::external
        Nginx["Nginx Ingress"]:::external
    end

    %% Flows
    Browser -->|"HTTPS"| AnsFE
    Browser -->|"HTTPS"| ScanFE
    Browser -->|"HTTPS"| SplitwellFE
    Browser -->|"HTTPS"| SVFE
    Browser -->|"HTTPS"| ValidatorFE
    Browser -->|"HTTPS"| WalletFE

    AnsFE -->|"HTTP/gRPC"| AnsAPI
    ScanFE -->|"HTTP/gRPC"| ScanAPI
    SplitwellFE -->|"HTTP/gRPC"| SplitwellAPI
    SVFE -->|"HTTP/gRPC"| SvAPI
    ValidatorFE -->|"HTTP/gRPC"| ValidatorAPI
    WalletFE -->|"HTTP/gRPC"| WalletAPI

    %% Shared libs links
    ScalaCommon --- Orchestrator
    ScalaCommon --- AnsAPI
    ScalaCommon --- ScanAPI
    ScalaCommon --- SplitwellAPI
    ScalaCommon --- SvAPI
    ScalaCommon --- ValidatorAPI
    ScalaCommon --- WalletAPI

    FECommon --- AnsFE
    FECommon --- ScanFE
    FECommon --- SplitwellFE
    FECommon --- SVFE
    FECommon --- ValidatorFE
    FECommon --- WalletFE

    FETestUtils --- FECommon

    %% Backend to Ledger
    Orchestrator -->|"gRPC"| Daml
    AnsAPI -->|"gRPC"| Daml
    ScanAPI -->|"gRPC"| Daml
    SplitwellAPI -->|"gRPC"| Daml
    SvAPI -->|"gRPC"| Daml
    ValidatorAPI -->|"gRPC"| Daml
    WalletAPI -->|"gRPC"| Daml

    %% Ledger to DB
    Daml -->|"JDBC/SQL"| Postgres

    %% Cluster boundaries
    subgraph "Kubernetes/Helm"
        direction TB
        BackendServices[/"Backend & Ledger"/]
        BackendServices --> Orchestrator
        BackendServices --> AnsAPI
        BackendServices --> ScanAPI
        BackendServices --> SplitwellAPI
        BackendServices --> SvAPI
        BackendServices --> ValidatorAPI
        BackendServices --> WalletAPI
        BackendServices --> Daml
        BackendServices --> HelmCharts
    end

    %% External integrations
    Auth0 -.->|"/ OAuth2"| WalletAPI
    Auth0 -.->|"/ OAuth2"| SvAPI
    PromGraf -.->|metrics| ScalaCommon
    Toxiproxy -.->|testing| Orchestrator
    Nginx -.->|Ingress| AnsFE
    Nginx -.->|Ingress| ScanFE
    Nginx -.->|Ingress| SplitwellFE
    Nginx -.->|Ingress| SVFE
    Nginx -.->|Ingress| ValidatorFE
    Nginx -.->|Ingress| WalletFE

    %% Click Events
    click AnsFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/ans/frontend"
    click ScanFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/scan/frontend"
    click SplitwellFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/splitwell/frontend"
    click SVFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/sv/frontend"
    click ValidatorFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/validator"
    click WalletFE "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/wallet/frontend"
    click Orchestrator "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/app/src/main/scala/org/lfdecentralizedtrust/splice/SpliceApp.scala"
    click AnsAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/ans/src/main/scala/org/lfdecentralizedtrust/splice/ans/AnsApp.scala"
    click ScanAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/ScanApp.scala"
    click SplitwellAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/splitwell/src/main/scala/org/lfdecentralizedtrust/splice/splitwell/SplitwellApp.scala"
    click SvAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/SvApp.scala"
    click ValidatorAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/validator/src/main/scala/org/lfdecentralizedtrust/splice/validator/ValidatorApp.scala"
    click WalletAPI "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/wallet/src/main/scala/org/lfdecentralizedtrust/splice/wallet/ExternalPartyWalletService.scala"
    click ScalaCommon "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/src/main/scala/org/lfdecentralizedtrust/splice"
    click FECommon "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/frontend/src"
    click FETestUtils "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/frontend-test-handlers"
    click FETestUtils "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/frontend-test-utils"
    click FETestUtils "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/frontend-test-vite-utils"
    click Daml "https://github.com/digital-asset/decentralized-canton-sync/tree/main/daml/"
    click HelmCharts "https://github.com/digital-asset/decentralized-canton-sync/tree/main/cluster/helm"
    click DockerCompose "https://github.com/digital-asset/decentralized-canton-sync/tree/main/cluster/compose"
    click Postgres "https://github.com/digital-asset/decentralized-canton-sync/tree/main/apps/common/src/main/resources/db/migration"
    click Auth0 "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/common/src/main/scala/org/lfdecentralizedtrust/splice/auth/OAuthApi.scala"
    click Auth0 "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/common/src/main/scala/org/lfdecentralizedtrust/splice/auth/AdminAuthExtractor.scala"
    click Toxiproxy "https://github.com/digital-asset/decentralized-canton-sync/blob/main/apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/plugins/UseToxiproxy.scala"
    click Nginx "https://github.com/digital-asset/decentralized-canton-sync/blob/main/cluster/helm/splice-istio-gateway/templates/gateway.yaml"
    click Nginx "https://github.com/digital-asset/decentralized-canton-sync/blob/main/cluster/helm/splice-istio-gateway/templates/virtualService.yaml"
    click PromGraf "https://github.com/digital-asset/decentralized-canton-sync/tree/main/cluster/pulumi/infra/grafana-dashboards"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#0366d6,color:#000
    classDef backend fill:#90ee90,stroke:#228B22,color:#000
    classDef shared fill:#ccffcc,stroke:#66bb6a,color:#000
    classDef ledger fill:#ffa500,stroke:#ff8c00,color:#000
    classDef db fill:#f9f871,stroke:#e0c341,color:#000
    classDef external fill:#d3d3d3,stroke:#696969,color:#000
```
