# microsoft/scitt-ccf-ledger architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/scitt-ccf-ledger
- Repository: https://github.com/microsoft/scitt-ccf-ledger

## Overview

##### Main Components

a. Core Components:
- CCF Platform Layer (Base Infrastructure)
- SCITT Application Layer
- Client Interface Layer
- Authentication & Authorization System
- Storage Layer (Ledger)

b. Supporting Components:
- Policy Engine
- DID Resolver
- Historical Query System
- CBOR/COSE Processing
- Verification System

##### Infrastructure Layer
- SGX/SEV-SNP Enclave support
- CCF Network Components
- Virtual Mode support (for development)

##### Core Service Layer
- Constitution Services (from app/constitution/)
- Service Endpoints (from app/src/service_endpoints.h)
- Operations Endpoints (from app/src/operations_endpoints.h)

##### Processing Layer
- CBOR/COSE Handlers
- Signature Verification
- Policy Engine
- DID Resolution System

##### Client Interface Layer
- REST API Endpoints
- Python CLI Tool (pyscitt)
- Authentication Handlers

##### Interaction Flows

- Client request flow through the system
- Authentication and authorization paths
- Claim submission and verification processes
- Receipt generation and validation
- Historical query processing

##### Specific Implementation Details

Specialized components visible in the file structure:
- Configuration Management
- Tracing System
- LRU Cache for Historical Queries
- Key Management System

##### Important Subsystems to Highlight

- Constitution System (app/constitution/)
- DID Resolution (app/src/did/)
- Historical Queries (app/src/historical/)
- Authentication System (app/src/configurable_auth.h)

##### External Integrations

Connections to:
- IETF SCITT Standards
- External DID Services
- Client Applications
- Key Vault Integration (visible in pyscitt/key_vault_sign_client.py)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Interface Layer"
        CLI["CLI Tool"]:::client
        ClientCore["Client Core"]:::client
        ReceiptHandler["Receipt Handler"]:::client
        VerificationClient["Verification Client"]:::client
    end

    subgraph "Service Layer"
        ServiceEndpoints["Service Endpoints"]:::service
        OperationsEndpoints["Operations Endpoints"]:::service
        AuthSystem["Authentication System"]:::service
    end

    subgraph "Processing Layer"
        CBOR["CBOR Processing"]:::processing
        COSE["COSE Processing"]:::processing
        PolicyEngine["Policy Engine"]:::processing
        Verifier["Verification System"]:::processing
    end

    subgraph "Core Components"
        DIDSystem["DID System"]:::core
        DIDDoc["Document Handler"]:::core
        DIDResolver["DID Resolver"]:::core
        
        HistoricalSystem["Historical Query System"]:::core
        QueryAdapter["Query Adapter"]:::core
        LRUCache["LRU Cache"]:::core
    end

    subgraph "Constitution Layer"
        Actions["Actions"]:::constitution
        Validation["Validation"]:::constitution
        Resolution["Resolution"]:::constitution
    end

    subgraph "Key Management"
        KeyVault["Key Vault Integration"]:::security
        LocalKey["Local Key Signing"]:::security
    end

    subgraph "Infrastructure Layer"
        CCF["CCF Platform"]:::infra
        SGX["SGX/SEV-SNP Enclave"]:::infra
        VirtualMode["Virtual Mode"]:::infra
    end

    %% Relationships
    CLI --> ClientCore
    ClientCore --> ServiceEndpoints
    ClientCore --> ReceiptHandler
    ReceiptHandler --> VerificationClient
    
    ServiceEndpoints --> AuthSystem
    ServiceEndpoints --> OperationsEndpoints
    
    OperationsEndpoints --> CBOR
    OperationsEndpoints --> COSE
    OperationsEndpoints --> PolicyEngine
    OperationsEndpoints --> Verifier
    
    Verifier --> DIDSystem
    DIDSystem --> DIDDoc
    DIDSystem --> DIDResolver
    
    ServiceEndpoints --> HistoricalSystem
    HistoricalSystem --> QueryAdapter
    HistoricalSystem --> LRUCache
    
    ServiceEndpoints --> Actions
    Actions --> Validation
    Actions --> Resolution
    
    ClientCore --> KeyVault
    ClientCore --> LocalKey
    
    CCF --> SGX
    CCF --> VirtualMode

    %% Click Events
    click CLI "https://github.com/microsoft/scitt-ccf-ledger/tree/main/pyscitt/pyscitt/cli/"
    click ClientCore "https://github.com/microsoft/scitt-ccf-ledger/blob/main/pyscitt/pyscitt/client.py"
    click ReceiptHandler "https://github.com/microsoft/scitt-ccf-ledger/blob/main/pyscitt/pyscitt/receipt.py"
    click VerificationClient "https://github.com/microsoft/scitt-ccf-ledger/blob/main/pyscitt/pyscitt/verify.py"
    click ServiceEndpoints "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/service_endpoints.h"
    click OperationsEndpoints "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/operations_endpoints.h"
    click AuthSystem "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/configurable_auth.h"
    click CBOR "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/cbor.h"
    click COSE "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/cose.h"
    click PolicyEngine "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/policy_engine.h"
    click Verifier "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/verifier.h"
    click DIDDoc "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/did/document.h"
    click DIDResolver "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/did/resolver.h"
    click QueryAdapter "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/historical/historical_queries_adapter.h"
    click LRUCache "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/src/historical/lru.h"
    click Actions "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/constitution/actions.js"
    click Validation "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/constitution/validate.js"
    click Resolution "https://github.com/microsoft/scitt-ccf-ledger/blob/main/app/constitution/resolve.js"
    click KeyVault "https://github.com/microsoft/scitt-ccf-ledger/blob/main/pyscitt/pyscitt/key_vault_sign_client.py"
    click LocalKey "https://github.com/microsoft/scitt-ccf-ledger/blob/main/pyscitt/pyscitt/local_key_sign_client.py"

    %% Styles
    classDef client fill:#a8d1ff,stroke:#333,stroke-width:1px;
    classDef service fill:#ffb366,stroke:#333,stroke-width:1px;
    classDef processing fill:#ff9999,stroke:#333,stroke-width:1px;
    classDef core fill:#99ff99,stroke:#333,stroke-width:1px;
    classDef constitution fill:#ffff99,stroke:#333,stroke-width:1px;
    classDef security fill:#ff99cc,stroke:#333,stroke-width:1px;
    classDef infra fill:#cc99ff,stroke:#333,stroke-width:1px;
```
