# microsoft/ccf architecture

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

## Overview

##### Main Components

a. Core Layer Components:
- Consensus Engine (src/consensus/aft/)
- Key-Value Store (src/kv/)
- Cryptographic Services (src/crypto/)
- Network Layer (src/node/)

b. Application Layer:
- JavaScript/TypeScript Runtime (src/js/)
- HTTP/RPC Interface (src/http/)
- Endpoint Registry (src/endpoints/)

c. Platform Security:
- TEE (Trusted Execution Environment) Integration
- Attestation Services (src/node/quote.cpp)
- Security Protocols (src/tls/)

**[Client Applications]**
- ↕ HTTPS/RPC
**[Front-end Layer]**
- HTTP/RPC Handlers
- Authentication/Authorization
- ↕
**[Application Layer]**
- JS/TS Runtime
- Endpoint Registry
- Business Logic
- ↕
**[Core Services Layer]**
- Consensus Engine
- Key-Value Store
- Cryptographic Services
- ↕
**[Platform Security Layer]**
- TEE Integration
- Attestation
- TLS

##### Key Relationships to Highlight

a. External Interactions:
- Client-to-Node communication via HTTPS/RPC
- Node-to-Node communication for consensus
- External service interactions (e.g., attestation)

b. Internal Flows:
- Request processing pipeline
- Consensus message flow
- State replication
- Security validation path

##### Implementation Details

- Version/state indicators where relevant

##### Additional Elements

- Monitoring/metrics flow
- Backup/recovery paths
- Configuration boundaries
- Extension points

- Multi-party compute capabilities
- Consensus mechanism
- Security guarantees
- State replication
- TEE integration

Remember to:
##### Failure handling paths

This will provide a clear understanding of CCF's architecture while highlighting its security and distributed nature.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef external fill:#2374f7,color:white
    classDef application fill:#4CAF50,color:white
    classDef core fill:#FFC107,color:black
    classDef security fill:#f44336,color:white
    classDef infrastructure fill:#78909C,color:white

    %% Client Layer
    Client["Client Applications"]:::external

    %% Frontend Layer
    subgraph FrontEnd["Front-end Layer"]
        HTTP["HTTP/RPC Interface"]
        Auth["Authentication/Authorization"]
    end

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        JSRuntime["JavaScript/TypeScript Runtime"]
        EndpointReg["Endpoint Registry"]
        BusinessLogic["Business Logic"]
        Gov["Governance System"]
    end

    %% Core Services Layer
    subgraph CoreServices["Core Services Layer"]
        Consensus["Consensus Engine"]
        KVStore["Key-Value Store"]
        Crypto["Cryptographic Services"]
        Network["Network Layer"]
        N2N["Node-to-Node Communication"]
    end

    %% Platform Security Layer
    subgraph Security["Platform Security Layer"]
        TEE["TEE Integration"]
        Attestation["Attestation Services"]
        TLS["TLS Security"]
    end

    %% Relationships
    Client <--> HTTP
    HTTP --> Auth
    Auth --> JSRuntime
    Auth --> EndpointReg
    JSRuntime --> BusinessLogic
    EndpointReg --> BusinessLogic
    BusinessLogic --> Consensus
    BusinessLogic --> KVStore
    Consensus <--> N2N
    N2N <--> Network
    Network --> TLS
    TEE --> Attestation
    Crypto --> TLS
    KVStore --> Crypto

    %% Click Events
    click Consensus "https://github.com/microsoft/CCF/tree/main/src/consensus/aft/"
    click KVStore "https://github.com/microsoft/CCF/tree/main/src/kv/"
    click Crypto "https://github.com/microsoft/CCF/tree/main/src/crypto/"
    click Network "https://github.com/microsoft/CCF/tree/main/src/node/"
    click JSRuntime "https://github.com/microsoft/CCF/tree/main/src/js/"
    click HTTP "https://github.com/microsoft/CCF/tree/main/src/http/"
    click EndpointReg "https://github.com/microsoft/CCF/tree/main/src/endpoints/"
    click TEE "https://github.com/microsoft/CCF/tree/main/src/enclave/"
    click TLS "https://github.com/microsoft/CCF/tree/main/src/tls/"
    click Attestation "https://github.com/microsoft/CCF/blob/main/src/node/quote.cpp"
    click N2N "https://github.com/microsoft/CCF/blob/main/src/node/node_to_node.h"
    click Gov "https://github.com/microsoft/CCF/tree/main/src/node/gov/"

    %% Legend
    subgraph Legend
        E[External]:::external
        A[Application]:::application
        C[Core]:::core
        S[Security]:::security
        I[Infrastructure]:::infrastructure
    end
```
