Skip to content

Architecture Containers

Mohammad Rasoul Kazemi edited this page Nov 30, 2026 · 4 revisions

Architecture Containers

Chapter 5 (level 1) of the arc42 structure (Architecture), and level 2 of the C4 model: the deployable and runnable parts of one KingresDB server and of the cluster. In C4 a "container" is a process or a data store, not a Docker container.

Diagram: one server and its neighbours

flowchart TB
    browser["Web console<br/>Vue 3 single-page application, embedded in kingresd"]
    client["SQL client"]
    verifier["kingres-verify<br/>standalone verifier, auditor machine"]
    targets["Anchoring targets<br/>WORM, TSA, OpenTimestamps"]
    prom["Prometheus"]
    peer["kingresd of the other servers"]

    subgraph server["One server"]
        kingresd["kingresd<br/>REST API, panel, manager, agent, standby agent, leases and failover, client entry point, transfer relay"]
        watchdog["kingres-watchdog<br/>lease watchdog"]
        subgraph pg["PostgreSQL instance with extensions"]
            shard["kingres_shard"]
            ledger["kingres_ledger"]
            analytics["kingres_sketch, kingres_timepart, kingres_columnar"]
            sysdb[("System database kingres_system<br/>schema kingres_cp, on the map group")]
        end
        files[("Files under /var/lib/kingres<br/>keys, pki, audit log, state, staged transfers")]
    end

    browser -->|"HTTP, REST under /api/v1"| kingresd
    client -->|"PostgreSQL protocol"| pg
    client -.->|"through the client entry point when enabled"| kingresd
    prom -->|"GET /metrics"| kingresd
    kingresd -->|"local socket, SQL"| pg
    kingresd --> files
    kingresd -.-> watchdog
    kingresd <-->|"internal API, mutual TLS"| peer
    shard <-->|"PostgreSQL protocol between nodes"| peer
    kingresd -->|"anchoring"| targets
    verifier -->|"reads the publication, exported files"| kingresd
Loading

Containers

Container Technology Responsibility Port or channel Source
PostgreSQL instance with the extensions PostgreSQL 18.7 or 19.0 plus the five extensions, started and stopped by kingresd as an independent process; one instance per server in the packaged layout (instances/1/pgdata) Stores the data. kingres_shard shards and routes; kingres_ledger keeps the hash chain; the analytics extensions add functions, storage and partitioning. shared_preload_libraries is set by kingresd to kingres_shard,kingres_ledger,kingres_columnar,pg_stat_statements (the last two are left out when their library is absent) pg-port, default 5432, pg-listen default 127.0.0.1; a Unix socket under /run/kingres/1 packaging README, control-plane README
kingresd One static Go binary with the console embedded Serves the REST API and the console; manages the local instance (initdb, configuration, start, stop); runs the task engine; creates and maintains the standbys of the groups, grants and renews the group leases, runs failover and switchover and the client entry point; on the manager leader, the recurring jobs, rebalance, the table and database transfers, ledger collector, publication and anchoring; forwards operations to the leader (a transfer body is relayed as a stream) REST and console on listen, default 127.0.0.1:8091; internal API on internal-listen (by convention 8092); optional client entry points client-listen and client-standby-listen; optional publication listener ledger-publication-listen; Prometheus text at /metrics; readiness at /api/v1/readyz control-plane README, internal-api.md
kingres-watchdog Go, standard library only Next to the instance: stops a primary whose kingresd died or hung when its lease would lapse. A server that runs the lease protocol does not start without it (allow-no-watchdog is for tests and development) A file refreshed by kingresd; no network control-plane README
System database A database kingres_system, schema kingres_cp, on the map group; embedded migrations Cluster state: servers, databases, tasks, alerts, certificates, configuration, rebalance and failover records, ledger publication and anchoring. See Data Model System Database The PostgreSQL port ADR 0019, migrations
Local files of kingresd Files and directories node-state.json, setup-token, audit.jsonl, pki/ (the cluster CA key and certificates), service-credentials, the staging directory and master key of the table and database transfers (sealed files), and the ledger signing keys and anchor credentials, which are deliberately kept outside PostgreSQL /var/lib/kingres packaging README, ledger-phase7.md
Web console Vue 3, TypeScript, built with Vite; served from go:embed Pages for the dashboard, servers, shards, databases and tables, security (including the certificate authority escrow), query workbench, rebalance, replication and failover, ledger, configuration, settings, alerts, tasks, logs and this server. See Web Console Same port as the REST API web README, ADR 0017
Verifier kingres-verify Go, standard library only Checks digests, proofs, signed checkpoints, tile logs, consistency proofs and anchors from files and HTTP reads the auditor controls. See The Verifier Runs on the auditor machine; reads the publication listener over HTTP verifier README
External anchoring targets An S3-compatible object store with Object Lock (worm), an RFC 3161 authority (tsa), OpenTimestamps calendars (ots) Hold evidence of an aggregate checkpoint outside the cluster. See Ledger Anchoring Outgoing HTTPS to the configured host and port only, no redirect, no proxy Ledger Anchoring
REST contract kingres/api/openapi.yaml The one description of the public API; the operation table of kingresd is generated from it n/a api README

Channels between servers

Channel Used for Security
Internal API, TLS 1.3, separate listener Joining and leaving, certificates, forwarding to the leader, cluster-wide reads, instance and standby calls, failover reads Mutual TLS under the cluster CA, ECDSA P-256; the client certificate is checked at every request against the revocation list; the protocol version header must match
PostgreSQL protocol between instances Distributed queries, two-phase commit, bucket moves, replication Roles and pg_hba.conf managed by kingresd, certificate rules for the servers of the cluster
Public REST Browser and scripts (kingres-cli is part of release 0.2.0 (2026-11-30), see Command Line Client) Sessions, CSRF, role hierarchy; see Security Model

Details of the internal API are in internal-api.md. The parts inside each container are on Architecture Components; where these run is on Architecture Deployment.

Sources

Clone this wiki locally