---
title: "Architecture"
---
Karakoram is a self-hosted, multi-platform control plane that reconciles engine clusters across infrastructure providers and namespace targets. [Zerops](https://zerops.io/) is the reference provider; [Dokploy](https://dokploy.com/) and [Nomad](https://developer.hashicorp.com/nomad) are also available. See [Providers](/docs/providers/).

## Deployment and trust boundaries

The diagram and concrete paths below show the Zerops provider deployment; other providers provide their own runtime layout, storage and public ingress.

<figure class="karakoram-mermaid"><div data-mermaid-output hidden role="img" aria-label="Diagram"></div><details data-mermaid-source open><summary>Diagram source</summary><pre><code>flowchart LR
  Client[Browser / karactl] --&gt;|Public HTTPS| Routing[Zerops HTTP routing]
  Routing --&gt;|HTTP 8080| CP[Karakoram control plane]
  CP --&gt; State[(SQLite / karakoramdata)]
  CP --&gt;|Project-scoped credentials| Platform[Zerops REST API]
  CP --&gt;|Engine driver-authenticated administration| Engine[Engine runtime]
  CP --&gt;|Pinned TLS + member token / 9443| Agent[Node agent]
  Agent --&gt;|Protected configuration pull / TLS 9443| CP
  Agent --&gt;|Render files / supervise processes| Engine</code></pre></details></figure>

- **Control plane:** one runtime service, normally `karakoram`, with one container and a `karakoramdata` Local Storage volume mounted at `/mnt/karakoramdata`. UI/API traffic enters through public HTTPS; the private agent listener uses TLS 9443. [SQLite](https://sqlite.org/) stores desired state, observations, operations, events and encrypted secret values. The master key is a separately managed service secret.
- **Data-bearing members:** singleton [Ubuntu](https://ubuntu.com/) 24.04 runtimes with independently identified persistent volumes and stable identities (Local Storage on Zerops). Increasing a runtime's container count is not engine replication.
- **Stateless components:** engine driver-supported auxiliary runtimes do not have durable data volumes. Containers sharing a service identity are not independent data-bearing members.
- **Node agent:** `karakoram agent` supervises the selected engine and exposes a bounded private API, not a remote shell.

Private networking alone is not an authentication boundary. Agent traffic uses pinned trust roots and per-member bearer tokens. Public HTTPS, internal agent TLS and engine authentication/TLS protect different paths. See [Security](/docs/security/) for credentials, project-token authority and secret-storage limits. Backup transfer paths are documented in [Backups and storage](/docs/backups/).

## Namespaces and relay routing

A namespace selects an immutable provider kind and target with its infrastructure credentials. Providers are the [Zerops provider](/docs/zerops/) (targets are Zerops projects), the [Dokploy provider](/docs/dokploy/) (Dokploy environments on a [Docker Swarm](https://docs.docker.com/engine/swarm/)), and the [Nomad provider](/docs/nomad/) (Nomad namespaces on an operator-managed cluster). `default` is the control plane's own target and uses direct private networking. Additional namespaces use an outbound relay only when their provider's `BackendInfo.Relay` requires one; all three current providers require it.

The relay opens an outbound WebSocket connection through public HTTPS and carries an inner mutually authenticated TLS tunnel. Engine driver-approved administration traffic and protected agent traffic use namespace-qualified streams; agent configuration pulls retain end-to-end TLS. A namespace token or relay outage interrupts management of that namespace, not every project. The relay is not application networking.

See [Namespaces and relays](/docs/namespaces/), the [relay threat model](/docs/security/#relay-threat-model) and [ADR 0018](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/0018-multi-project-namespaces-relay.md).

## Infrastructure providers

The server composition root registers compiled-in factories in `infra.Registry`. Each factory constructs and validates a namespace's `Target`; engines use `infra.Backend`, not the platform client. Neutral `ServiceSpec` values distinguish runtimes from independently identified persistent volumes. `Deployment` pairs an executable artifact with a structured `RuntimeSpec`; each provider renders its own manifest and supplies its runtime `Layout`. Operations remain opaque handles polled through `OpStatus`, and errors use neutral classes.

Provider capabilities describe optional public routing, disk growth, quotas, placement, logs and other resource/runtime features. Engine capability gates reject unsupported requests. `GET /api/v1/backends` publishes registered kinds and capabilities; namespace responses identify their provider and enabled capabilities. All providers must pass the shared contract suite. See [ADR 0030](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/0030-backend-neutral-infrastructure-contract.md); the registry does not imply support for an unregistered platform.

## Desired state and durable operations

Clusters separate desired `spec` from observed `status`, with generation tracking. Mutations persist intent before reconciliation. Per-cluster workers serialize synchronization and imperative operations; unrelated clusters can progress independently. Engine drivers persist checkpoints and platform identifiers, then observe completion before advancing disruptive work.

Engine driver persistence replaces each owned state value, not just its nonempty fields. [PostgreSQL](https://www.postgresql.org/), [Elasticsearch](https://www.elastic.co/elasticsearch) and [Supabase](https://supabase.com/) replace their complete `Cluster.Internal` namespace objects. Flat [MongoDB](https://www.mongodb.com/) and [RabbitMQ](https://www.rabbitmq.com/) state uses `internal/statejson.ReplaceOwned`: explicit JSON tags define owned root keys, omitted empty fields remove prior values, and unrelated workflow keys survive. Nested values are replaced whole; adding an optional owned field must not require a second, hand-maintained deletion list.

Neither HTTP acceptance nor a successful infrastructure configuration process proves engine health. There is no distributed exactly-once transaction across SQLite, infrastructure providers and engine/storage APIs: durable identifiers and observation constrain replay, while ambiguous outcomes require investigation. [Clusters and operations](/docs/clusters/#operations-and-status) defines generations, operation phases, health, cancellation and wait behavior.

Independent availability renewal for steady clusters can use authenticated agent
heartbeats and a shared per-target platform snapshot; health leases remain
anchored to their oldest evidence. Lifecycle reconciliation and safety decisions
keep fresh reads, with 30-minute deep resynchronization for steady clusters.
[ADR 0070](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/0070-agent-heartbeats-and-platform-read-budget.md) defines the
freshness classes, mutation epochs and fallback to live observation.

## Node-local durability

Agents cache assigned configuration on the data volume with owner-only permissions. Existing data-bearing members can start from that cache during control-plane downtime; first startup without a cache cannot. Stateless runtimes lose cached configuration when replaced.

Rendered credentials, certificates and configuration are restricted to the runtime owner. Explicit maintenance and process-stop holds are persisted separately from pulled configuration, so a configuration refresh or agent restart does not silently release them. Restore/restart recovery remains engine driver-specific: use the engine operations and recovery guides rather than manually overriding holds.

When the member executable is PID 1, a minimal init parent re-executes the real
agent as its child. The parent forwards termination, interrupt and hangup signals,
reaps adopted daemon descendants, and exits with the real agent's status. This
keeps orphan reaping separate from the agent's `os/exec` command waits; daemonized
database processes cannot remain zombies that block their supervisor's lifecycle
checks. Ordinary non-PID-1 members do not re-execute.

The shared process supervisor reaps each direct child independently of stdout and
stderr EOF. After exit it allows up to 250 ms for final log draining, then closes
its pipe readers so descendants retaining inherited descriptors cannot block exit
status, restart scheduling or stop completion. Normal EOF finishes the drain
immediately. Exit observation does not signal descendants; explicit stop/restart
retains the configured stop signal to the child's process group.

## Recovery, monitoring and events

The control plane owns scheduling and count retention; its downtime pauses new scheduling and retention. Already-started engine-side work can continue without the control plane. Engine backups and control-plane state backups protect different assets: preserve both the SQLite state and its master key as described in [state backup and recovery](/docs/operations/#control-plane-state-backup-and-recovery).

Agents expose member metrics for control-plane collection, history and authenticated [Prometheus](https://prometheus.io/) export. Persisted events feed live UI/API updates; the live event stream is an acceleration, not the persistence layer. See [Monitoring and events](/docs/monitoring/) and [API pagination and events](/docs/api/#pagination-and-events).

## Failure domains

The control plane is single-replica. Persistent volumes are node-local on current providers. Zerops does not guarantee host separation; Dokploy and Nomad report authoritative node placement but cannot establish independent racks or physical hosts beneath the scheduler. Engine replication cannot compensate for every shared-host failure. See [Limitations](/docs/limitations/) before selecting availability and recovery objectives.

## Engine drivers

The code calls an engine driver `engine.Provider`; the API and CLI retain `spec.provider`, `/api/v1/providers` and `--provider` for engine selection. Engine drivers are compiled into Karakoram, not dynamically installable plugins. Each owns its version catalog, validation/defaults, topology, health observation, lifecycle checkpoints, access APIs and backup semantics. Shared interfaces handle infrastructure, namespaces, secrets, operations and monitoring; capability metadata gates supported UI/API actions. A cluster's engine driver is immutable.

Optional auxiliary services use ordered `ComponentDef`/`ComponentSet` declarations with per-component replicas and resources in `spec.components.extra`. Shared stateless reconciliation handles enable/disable stages through engine callbacks; credentials, application readiness, resizing and stateful safety remain engine-owned. Elasticsearch uses this for [Kibana](https://www.elastic.co/kibana), [Logstash](https://www.elastic.co/logstash) and [APM](https://www.elastic.co/observability/application-performance-monitoring); PostgreSQL for [ProxySQL](https://proxysql.com/); Supabase for its modular native services. See [ADR 0031](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/0031-engine-component-model.md).

| Engine | Engine driver | Runtime and operational details |
| --- | --- | --- |
| MongoDB | `psmdb` | [Overview](/docs/mongodb/) |
| RabbitMQ | `rabbitmq` | [Overview](/docs/rabbitmq/) |
| Elasticsearch | `elasticsearch` | [Overview](/docs/elasticsearch/) |
| PostgreSQL | `postgres` | [Percona, extension profiles, Patroni/etcd HA, Citus, ProxySQL and pgBackRest](/docs/postgres/) |
| Supabase | `supabase` | [PostgreSQL core plus modular native services](/docs/supabase/) |
| Keycloak | `keycloak` | [Native identity service with a managed PostgreSQL binding](/docs/keycloak/) |
| OpenBao | `openbao` | [Native secrets clusters, Raft recovery and leased database credentials](/docs/openbao/) |
| Temporal | `temporal` | [Stateless workflow roles on bound PostgreSQL](/docs/temporal/); requires the PostgreSQL binding service |
| MySQL | `mysql` | [Percona Server, Group Replication, ProxySQL and XtraBackup](/docs/mysql/) |
| Percona XtraDB Cluster | `pxc` | [Galera, quorum recovery and separate backup provenance](/docs/mysql/) |
| Neo4j Community | `neo4j` | [TLS-only singleton, native administrative users and offline dumps](/docs/neo4j/) |
| Weaviate | `weaviate` | [Native lifecycle, access management and recovery](/docs/weaviate/) |

Supabase wraps the PostgreSQL core rather than duplicating database lifecycle. Internal services use a protocol-transparent leader forwarder rather than ProxySQL; the client proxy retains explicit protocol limits. Native service availability comes from an embedded, checksum-pinned lock with operator mirror precedence, not floating downloads. See [ADRs 0034–0036](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/README.md) and [native artifacts](/docs/native-artifacts/).

See [ADR 0005](https://github.com/KarakoramDev/Karakoram/blob/v0.4.11/docs/adr/0005-engine-provider-seam.md) for the engine driver seam and [Contributing](/docs/contributing/) for code layout and development workflows.