# open-qkd-network/qkd-net architecture

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

- Interactive diagram: https://gitdiagram.com/open-qkd-network/qkd-net
- Repository: https://github.com/open-qkd-network/qkd-net

## Overview

The “qkd-net” project is a reference implementation of a quantum key distribution network system that adopts a layered, microservice‐oriented approach. In this system, three main layers are defined:
- The Key Management System (KMS) layer – consists of several microservices (configuration service, registration service, authorization service, KMS service, KMS API gateway, and KMS QNL service) that collectively provide an application interface for symmetric key retrieval.
- The Quantum Network Layer (QNL) – a single microservice (Key Routing Service) that sits between the KMS layer and the QKD Link Layer, responsible for managing routing, key relaying, and (in longer term) handling network topology dynamics.
- The QKD Link Layer (QLL) – representing the physical or simulated layer where the quantum key generation happens (including simulators for when real QKD devices are unavailable).

##### Main Components
a. KMS Layer – List individual microservices as separate components (Configuration Service, Registration Service, Authorization Service, KMS Service, KMS API Gateway, KMS QNL Service).
b. QNL Layer – Represent the “Key Routing Service” component that handles routing and key block relaying.
c. QLL (Quantum Link Layer) – Represent the QKD devices (or the provided simulator) which generate the raw quantum keys.
– Additionally, include sample “applications” (such as tls-kms-demo, qTox, etc.) to illustrate how external clients integrate with the system.

##### Relationships and Interactions
- The QLL layer provides key blocks (via simulated or real QKD links) to the QNL service.
- The QNL layer (Key Routing Service) both receives and routes key blocks between sites and pushes key blocks to the KMS QNL service.
- The KMS layer’s services (especially the KMS Service and API gateway) expose endpoints for client applications to make “newkey” and “getkey” REST calls.

##### Architectural Patterns and Design Principles
– Emphasize that a microservices architecture has been adopted, which provides flexibility for deployment and scaling.
– The project follows SOLID principles to achieve good separation of concerns.
– There is clear separation between the layers (each with its own responsibility and communication interface), which makes the system modular.

##### Specify Key Technologies and Artifacts
– Mention Java (with Maven as the build tool) as the primary technology for KMS and related services.
– Identify configuration files (like kms.conf, config.yaml, and routes.json) that are crucial in coordinating the operation between layers.
– Mention supporting scripts (e.g., shell scripts under the kms/scripts directory) that build and run services.

##### Elements

– Notations for deployment-specific configuration (e.g., configuration files, scripts) that indicate how services are expected to be integrated and run.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "KMS Layer"
        kms_config["Configuration Service"]:::kms
        kms_reg["Registration Service"]:::kms
        kms_auth["Authorization Service"]:::kms
        kms_service["KMS Service"]:::kms
        kms_api["KMS API Gateway"]:::kms
        kms_qnl["KMS QNL Service"]:::kms
    end

    subgraph "QNL Layer"
        qnl_keyrouting["Key Routing Service"]:::qnl
    end

    subgraph "QLL Layer"
        qll_sim["QKD Simulator"]:::qll
    end

    subgraph "External Clients"
        ext_tls["tls-kms-demo"]:::external
        ext_qtox["qTox"]:::external
    end

    %% Data Flow Arrows
    qll_sim -->|"keyblocks"| qnl_keyrouting
    qnl_keyrouting -->|"routes-keyblocks"| kms_qnl

    %% Internal KMS Communication
    kms_config -->|"init"| kms_reg
    kms_reg -->|"register"| kms_auth
    kms_auth -->|"authorize"| kms_service
    kms_service -->|"service-call"| kms_api
    kms_qnl -->|"key-feed"| kms_service

    %% External Client Interactions
    ext_tls -->|"REST-calls"| kms_api
    ext_qtox -->|"REST-calls"| kms_api

    %% Click Events
    click kms_config "https://github.com/open-qkd-network/qkd-net/tree/master/kms/config-service"
    click kms_reg "https://github.com/open-qkd-network/qkd-net/tree/master/kms/registration-service"
    click kms_auth "https://github.com/open-qkd-network/qkd-net/tree/master/kms/auth-service"
    click kms_service "https://github.com/open-qkd-network/qkd-net/tree/master/kms/kms-service"
    click kms_api "https://github.com/open-qkd-network/qkd-net/tree/master/kms/kms-api-gateway"
    click kms_qnl "https://github.com/open-qkd-network/qkd-net/tree/master/kms/kms-qnl-service"
    click qnl_keyrouting "https://github.com/open-qkd-network/qkd-net/tree/master/qnl/key-routing-service"
    click qll_sim "https://github.com/open-qkd-network/qkd-net/tree/master/qll_sim"
    click ext_tls "https://github.com/open-qkd-network/qkd-net/tree/master/applications/tls-kms-demo"
    click ext_qtox "https://github.com/open-qkd-network/qkd-net/tree/master/applications/qTox"

    %% Styles
    classDef kms fill:#FAD7A0,stroke:#C0392B,stroke-width:2px;
    classDef qnl fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef qll fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
