Skip to content

Architecture Orientation

This page orients you in the workspace: first the actor model that drives a running node, then the crate map grouped by layer. For the protocol-level model (the signed-op DAG and the deterministic fold) see the Protocol Reference.

A running node is organized as a small set of Actix actors that talk to each other through typed messages, plus a couple of long-lived async tasks. The actors never reach into each other’s state directly — they exchange messages and go through thin client façades (NodeClient, ContextClient, NetworkClient) that wrap message recipients.

Actor / taskCrateRole
NodeManagercrates/nodeCentral orchestrator. Receives network events, routes incoming state deltas to contexts, handles blob caching (multi-phase LRU), heartbeats, and key delivery. Handles NodeMessage.
ContextManagercrates/contextManages contexts (application instances), groups (governance units), and per-namespace governance DAGs. 30+ message handlers covering execution, governance, membership, and upgrades. Handles ContextMessage.
NetworkManagercrates/networkOwns and drives the libp2p Swarm. Publishes/subscribes gossipsub topics, runs the Kademlia DHT, mDNS, relay, and request/response streams. Handles NetworkMessage.
SyncManagercrates/nodeNot an actor — a long-lived async task spawned at startup. Runs periodic and on-demand sync cycles, selecting a sync protocol from handshake-negotiated divergence metrics.
GarbageCollectorcrates/nodeBackground actor that cleans up storage tombstones.
Server layer — REST · JSON-RPC · WebSocket · SSE crates/server — no business logic, delegates through client façades ContextClient NodeClient ContextManager actor contexts · groups · governance DAGs 30+ handlers — execution · membership crates/context · Handler<ContextMessage> NodeManager actor central orchestrator — routes deltas blob cache (LRU) · heartbeats · keys crates/node · Handler<NodeMessage> NetworkManager actor owns the libp2p Swarm gossipsub · Kademlia · streams crates/network · Handler<NetworkMessage> deltas publish event SyncManager async task periodic + on-demand sync cycles picks protocol from divergence metrics crates/node · tokio task · uses NetworkClient GarbageCollector actor background storage cleanup removes tombstones on a timer crates/node broadcast channel spawns Runtime crates/runtime · WASM Causal DAG crates/dag Storage crates/store + crates/storage execute persist Actors exchange typed messages through thin client façades (LazyRecipient); the network layer moves opaque bytes only.

How they talk, end to end:

  • External clients hit the Server layer (crates/server) over REST / JSON-RPC / WebSocket / SSE. The server holds no business logic — it delegates to ContextClient and NodeClient.
  • NodeManager routes work: an execution request goes to ContextManager, which runs a WASM method on the runtime (crates/runtime) and produces a state delta.
  • Deltas are recorded in the causal DAG (crates/dag), persisted through the storage layer (crates/store + crates/storage), and broadcast to peers via NetworkManager.
  • Inbound network events flow the other way: NetworkManagerNodeManager → the right context, where deltas are applied and convergence is reconciled by SyncManager.

The workspace layers from external surfaces at the top down to shared primitives at the bottom. Binaries depend on the server and node crates, which fan out through the core libraries, all converging on primitives.

The crate stack — external surfaces down to shared primitives each layer depends on the layers below it; every crate ultimately converges on `primitives` depends ↓ Binaries& tools merod meroctl calimero-abi mero-sign merodb Client &Server server mero-auth client Node &Context node context context-config config Sync · NetworkRuntime · Store network runtime store store-rocksdb store-blobs store-encryption storage GovernanceOp · DAG dag op projection authz op-adapter governance-types governance-store SDK &Primitives sdk sys wasm-abi primitives prelude crypto tee-attestation Binaries fan out through the server and node crates into the core libraries — all converging on `primitives`.
CrateResponsibility
crates/server (+ server/primitives)Single Axum HTTP server mounting all public surfaces: Admin REST API, JSON-RPC 2.0, WebSocket, SSE, Prometheus metrics, and the embedded admin dashboard SPA.
crates/auth (mero-auth)Forward-auth service: JWT issuing/verification, pluggable providers (NEAR, Ethereum, custom), challenge/nonce wallet auth. Runs embedded in the server or behind a reverse proxy.
crates/clientTrait-based client library for talking to Calimero APIs (auth, storage abstractions) — used by tooling and integrations.
CrateResponsibility
crates/node (+ node/primitives)NodeManager actor, the SyncManager task, and the GarbageCollector. Orchestrates the whole node and owns delta handling and blob caching.
crates/context (+ context/primitives)ContextManager actor: contexts, groups, namespace governance DAGs, lifecycle recovery, and metrics.
crates/context/configContext configuration types and the on-chain/config-contract client surface.
crates/configNode configuration (config.toml) types and loading.
CrateResponsibility
crates/network (+ network/primitives)NetworkManager actor wrapping the composed libp2p behaviour stack (gossipsub, Kademlia, mDNS, relay, rendezvous, hole-punching, streams). Moves opaque bytes only.
crates/runtimeWasmer + Cranelift WASM execution engine. Builds a VMLogic per call, runs the exported method, and returns an Outcome (return value, logs, events, storage delta). 50+ host functions.
crates/storeColumn-family key-value abstraction over RocksDB via the Database trait; typed keys with compile-time size/column guarantees.
crates/store/impl/rocksdbThe RocksDB-backed implementation of the Database trait.
crates/store/blobsBlob store (calimero-blobstore) for large binary artifacts.
crates/store/encryptionOptional transparent AES-GCM encryption of values at rest.
crates/storage (+ storage-macros)CRDT storage collections and the derive macros that wire app state into the storage subtree.
CrateResponsibility
crates/dagPure causal DAG for delta tracking with automatic dependency resolution — no network or storage deps. Orders state changes correctly even when messages arrive out of order.
crates/governance-typesSigned group-operation types for local (no-chain) group governance.
crates/governance-storeApply pipeline, broadcast/ack flow, metrics, and notifications for the local group-governance domain (extracted from calimero-context).
crates/opThe unified Op envelope for the causal log — one operation type for data writes, writer-set rotation, membership, and policy changes.
crates/projectionScopeState — the single deterministic projection (materializer) of a scope’s op-log into values plus a root hash.
crates/authzThe single authorization fold over the op-log: authorize is one match over the op payload against an ACL view resolved at the op’s causal cut.
crates/op-adapterTransitional bridge mapping per-plane operation types onto the unified causal log.
CrateResponsibility
crates/sdk (+ sdk/macros)Proc-macro SDK for building apps: #[app::state], #[app::logic], #[app::event]. Compiles to WASM and exposes methods as JSON-RPC-callable endpoints.
crates/sysLow-level system/host ABI bindings used by the SDK and runtime boundary.
crates/wasm-abiWASM ABI definitions shared between host and guest.
crates/primitivesCore shared types (e.g. ContextId, identities) used across the workspace.
crates/preludeCommon re-exports for ergonomic imports across crates.
crates/cryptoCryptographic primitives (keys, signing, hashing).
crates/tee-attestationPlatform-agnostic TEE attestation generation/verification (e.g. TDX quotes).
CrateResponsibility
crates/merodThe node daemon binary.
crates/meroctlThe operator/developer CLI.
tools/calimero-abi (mero-abi)Inspect/verify application WASM ABIs.
tools/mero-signSign application bundles.
tools/merodbInspect and debug the node’s RocksDB database.