Skip to content

Architecture

How assets are published, indexed, audited, read and distributed, and the relay network underneath.

Critical registries

Registry architecture

Select the diagram to open it at full size.

Author / SDK (Edge Execution)

Component Role
SDK Core Executes the end-to-end upload workflow, maintains resumable state, retries failed steps with backoff, and guarantees crash-safe recovery.
Chunker Splits large assets into deterministic fixed-size chunks, aligns ranges for HTTP streaming, and ensures memory-safe streaming behavior.
Hasher Computes SHA256 for every chunk, constructs a Merkle tree incrementally, and outputs a deterministic Merkle root for the asset.
Manifest Builder Assembles the complete asset list, maintains a monotonic version counter, and embeds the Merkle root as the canonical completeness commitment.
Policy Encoder Embeds propagation intent, distribution scope, time-to-live, and deletion semantics directly into the asset metadata.
Signer Derives event identifiers and cryptographically signs all manifests and asset events using the author’s private key.
Nostr Publisher Broadcasts signed events to multiple relays, tracks acknowledgements, and retries publication until sufficient relay acceptance is reached.
Origin Uploader Performs multipart uploads to origin storage, resumes from byte offsets on failure, and verifies integrity before final commit.

Control Plane (L1 / Nostr)

Component Role
Event space Defines asset events, author manifests, propagation intents, revocations, Layer-2 checkpoints, and watchdog audit reports.

Nostr Relay Network

Component Role
Relay A Persists signed events and exposes them to subscribers.
Relay B Replicates events from upstream relays and serves downstream consumers.
Relay C Ensures redundancy and independent availability of published events.

Aggregation Layer (Permissionless L2 Indexers)

Component Role
Relay Consumer Subscribes to relays, manages replay windows, deduplicates events, and guarantees ordered ingestion.
Signature Validator Verifies author signatures, checks event identifiers, and rejects malformed or forged events.
State Builder Transforms verified events into indexed state, resolves conflicts deterministically, and applies deletion tombstones.
Aggregator Database Persists canonical asset events, author manifests, tag-based indexes, and scheduler discovery records.
Aggregator Write-Ahead Log Records state transitions to guarantee crash recovery and deterministic rebuilds.
Hot Cache Retains frequently accessed assets and scheduler metadata with time-based eviction for low-latency reads.
Query API Serves client queries, signs responses, attaches proofs, and guarantees non-equivocation through verifiable transcripts.

L2 Quorum Checkpoint (Optional For Critical Registries)

Component Role
L2 State Synchronizer Exchanges state deltas between participating indexers to converge on a shared view.
Checkpoint Builder Derives a canonical Merkle root representing the agreed-upon registry state.
Quorum Signer Collects threshold signatures from dynamically selected indexers to attest to the checkpoint root.
Checkpoint Database Stores signed roots, historical epochs, and verifier metadata.
Checkpoint Event Publishes the signed root and quorum signatures as a public attestation.

Client / Runtime

Component Role
Resolver Selects Layer-2 indexers dynamically and determines quorum size using randomized selection.
Verifier Validates author signatures, checks Merkle inclusion proofs, and verifies Layer-2 response signatures.
Result Union Merges responses from multiple sources and deterministically removes duplicates.
Reputation Filter Intersects watchdog reports and applies decay-weighted trust scoring.
Fallback Reader Directly queries Layer-1 relays when Layer-2 trust thresholds are not met.

Watchdog / Auditor Layer

Component Role
L2 Probe Engine Issues randomized and broad queries against Layer-2 indexers to evaluate completeness, latency, and consistency.
L1 Scanner Continuously ingests events from multiple relays and detects gaps or inconsistencies in relay coverage.
Evidence Store Persists signed response transcripts and cryptographic proofs for forensic verification.
Ground Truth Database Reconstructs canonical author timelines, asset histories, and manifest roots directly from Layer-1.
Comparator Analyzes Layer-2 responses against Layer-1 truth to detect omissions, censorship, or equivocation.
Report Signer Produces deterministic audit reports and signs them using the watchdog’s long-term identity key.
Reputation Event Publishes scored assessments, supporting evidence, and timestamps as verifiable public records.

Node-local Control Plane

Component Role
Consistent Hash Engine Maps content identifiers to schedulers using virtual nodes and rebalancing logic.
Scheduler Health Monitor Probes liveness and round-trip latency continuously.
Decision Cache Stores content-to-scheduler assignments with bounded lifetime.
Bridge Aggregates global registry state and exposes a stable interface to local managers.
Manager API Facade Provides scheduler selection, preheat control, and keepalive coordination.
Policy Engine Evaluates intent, scope, and time-to-live constraints before task execution.
Task Orchestrator Creates, invalidates, and reconciles preheat and eviction tasks.

Data Plane (Dragonfly2)

Scheduler

Component Role
Scheduler API Receives placement requests and coordinates peer selection.
Task Manager Tracks lifecycle state and enforces time-to-live for distribution tasks.
Peer Manager Maintains peer registries and continuously scores peers based on performance.
Piece Manager Tracks chunk availability and validates checksums for integrity.
Topology Builder Constructs distribution trees and controls fan-out structure.
Load Controller Enforces fairness and rate limits across peers.
Failure Handler Detects faults, reassigns work, and repairs incomplete distributions.
Metrics Exporter Publishes latency, throughput, and cache hit rates.

Seed Peer

Component Role
Origin Fetcher Retrieves ranged data directly from origin storage.
Disk Cache Stores full objects locally and evicts them under pressure or policy.
Piece Server Exposes cached data as distributable chunks to peers.
Cache Garbage Collector Enforces retention and frees disk under constraints.

PEERS (dfdaemon)

Component Role
Piece Downloader Retrieves chunks from peers or seeds.
Integrity Verifier Validates chunk hashes before acceptance.
Local Cache Stores verified chunks for reuse.
Piece Uploader Redistributes chunks to requesting peers.
Retry Engine Handles transient failures and reschedules downloads.
Cache Garbage Collector Evicts unused chunks locally.

Origin Storage (Author Controlled)

Component Role
Object Gateway Serves content using HTTP range requests, enforces access controls, and exposes immutable object addresses.
Origin Metadata Database Stores object checksums, byte size, modification timestamps, and integrity verification fields.

Interactions: Critical registries

From Interaction To
SDK Core orchestrates processing Chunker
Chunker generates hashes Hasher
Hasher produces Merkle root Manifest Builder
Manifest Builder applies policy intent Policy Encoder
Policy Encoder prepares signed payload Signer
Signer publishes signed events Nostr Publisher
Chunker streams data Origin Uploader
Origin Uploader writes object data Object Gateway
Object Gateway records metadata Origin Metadata Database
Nostr Publisher submits events Relay A
Relay A replicates events Relay B
Relay B replicates events Relay C
Relay C streams events Relay Consumer
Relay Consumer forwards verified events Signature Validator
Signature Validator emits trusted data State Builder
State Builder persists state Aggregator Database
State Builder logs mutations Aggregator Write-Ahead Log
Aggregator Database hydrates cache Hot Cache
Hot Cache serves responses Query API
Relay A feeds events L1 Scanner
L1 Scanner builds truth state Ground Truth Database
Query API receives probe queries L2 Probe Engine
L2 Probe Engine records transcripts Evidence Store
Ground Truth Database supplies reference state Comparator
Evidence Store provides evidence Comparator
Comparator produces verdicts Report Signer
Report Signer publishes audit reports Relay A
State Builder shares state L2 State Synchronizer
L2 State Synchronizer derives root Checkpoint Builder
Checkpoint Builder requests signatures Quorum Signer
Quorum Signer stores checkpoint Checkpoint Database
Checkpoint Database publishes attestation Relay B
Resolver issues queries Query API
Query API returns signed data Verifier
Verifier produces verified sets Result Union
Result Union filters by reputation Reputation Filter
Reputation Filter triggers fallback Fallback Reader
Result Union supplies global view Bridge
Bridge exposes control api Manager API Facade
Manager API Facade enforces policy Policy Engine
Policy Engine creates tasks Task Orchestrator
Scheduler Health Monitor feeds health signals Decision Cache
Consistent Hash Engine assigns schedulers Decision Cache
Decision Cache guides routing Manager API Facade
Manager API Facade assigns scheduler Scheduler API
Manager API Facade requests preheat Scheduler API
Scheduler API requests origin data Origin Fetcher
Origin Fetcher fetches ranges Object Gateway
Origin Fetcher stores locally Disk Cache
Disk Cache serves chunks Piece Server
Piece Server streams chunks Piece Downloader
Piece Downloader verifies data Integrity Verifier
Integrity Verifier writes cache Local Cache
Local Cache uploads chunks Piece Uploader
Piece Uploader propagates data Piece Downloader
Signer publishes revocation Relay A
Task Orchestrator invalidates tasks Scheduler API
Scheduler API purges cached data Disk Cache
Client / Runtime selects indexers Resolver

Relays, indexers and archives

Relay and registry architecture

Select the diagram to open it at full size.

Author & Asset Origin

Component Role
Author Identity module Manages cryptographic keys or DIDs and signs every create, update, and delete operation.
Personal Relay Accepts only author-signed events, enforces local access rules, and serves as an authoritative personal metadata source.
Decentralized Asset Storage Persists immutable asset files using content addressing and exposes retrieval via hash or CID.

Layer 1

RELAY NETWORK (METADATA PLANE).

Component Role
Ingress Handler Accepts websocket connections, parses incoming events, and performs protocol-level validation.
Authentication Engine Validates optional challenge-response authentication such as NIP-42 before accepting writes.
Spam Filter Enforces proof-of-work, rate limits, and custom filtering rules to protect relay health.
Event Validator Verifies cryptographic signatures, event IDs, and schema correctness.
Relay Write-Ahead Log Ensures durable ingestion and crash-safe recovery of incoming events.
Relay Event Database Stores signed metadata events with configurable retention, indexing, and pruning policies.
Relay Indexer Builds basic indexes for author, kind, tags, and timestamps to support direct queries.
Negentropy Sync Engine Compares local state with peer relays and synchronizes missing events efficiently.
Retention Policy Engine Applies time-based or capacity-based deletion rules on stored events.
Relay Query Engine Executes filtered subscription queries over indexed metadata.
Subscription Manager Tracks active client subscriptions and streams matching events in real time.

Power User / Raw L1 Access

Component Role
Raw Nostr Client Subscribes directly to relays without relying on indexers.
Filter Engine Applies tag, author, and kind filters locally over streamed events.
Compute Executor Runs custom ranking or analysis code over raw datasets.

Layer 3

Component Role
Registry Scanner Queries Layer 1 for registry advertisements and builds a dynamic provider catalog.
Selection Engine Selects registries based on user choice, tags, or automated rules.
Fan-Out Engine Dispatches parallel queries to multiple registry APIs.
Response Collector Gathers asynchronous responses and tracks timeouts and failures.
Result Normalizer Unifies heterogeneous registry responses into a common schema.
Result Deduplicator Removes duplicate assets appearing across registries.
Federated Ranker Applies global ranking logic over merged results.
Presentation API Exposes a single unified search interface to end users.

Layer 2

Component Role
Bulk Subscriber Pulls complete historical event streams from relays using backfill mechanisms.
Archive Normalizer Ensures canonical ordering and schema consistency across datasets.
Archive Database Stores full historical metadata with long-term durability guarantees.
Sync Planner Computes diffs against peer archivers to identify missing data.
Export API Serves bulk snapshots, incremental exports, and recovery feeds to authorized consumers.
Sync Executor Transfers only missing records using efficient batch protocols.

Layer 2

INDEXERS / REGISTRY PROVIDERS.

Component Role
Relay Client Maintains persistent subscriptions to multiple relays and manages replay windows.
Event Normalizer Converts raw relay events into canonical internal representations.
Deduplication Engine Removes duplicates and resolves replaceable and deletion events deterministically.
Indexer Write-Ahead Log Records ingestion steps to ensure replay and recovery.
Indexer Database Stores normalized records, tag indexes, author mappings, and registry advertisements.
Search Index Builds inverted and vector-friendly indexes to support high-performance queries.
Query Planner Analyzes user queries and selects optimal execution strategies.
Ranking Engine Scores and orders results based on relevance, freshness, reputation, or custom logic.
Registry API Exposes search, filtering, access control, metrics, and quota management endpoints.
Provider Policy Engine Enforces specialization filters, content policies, and access constraints.
Metrics Collector Records query latency, usage statistics, and operational health indicators.

Asset Retrieval & Verification

Component Role
Asset Fetcher Retrieves immutable assets directly from decentralized storage using recorded identifiers.
Integrity Verifier Recomputes hashes to ensure retrieved assets match declared identities.

Meta-registration On L1

Component Role
Registry Descriptor Defines registry provider identity, specialization, API endpoints, and tags.
Descriptor Signer Signs the registry descriptor using the provider’s identity key.

Interactions: Relays, indexers and archives

From Interaction To
Author Identity module signs metadata Personal Relay
Author Identity module uploads assets Decentralized Asset Storage
Personal Relay pushes metadata Ingress Handler
Ingress Handler authenticates client Authentication Engine
Authentication Engine filters writes Spam Filter
Spam Filter passes valid events Event Validator
Event Validator logs event Relay Write-Ahead Log
Relay Write-Ahead Log persists event Relay Event Database
Relay Event Database indexes metadata Relay Indexer
Relay Indexer serves queries Relay Query Engine
Relay Query Engine streams results Subscription Manager
Relay Event Database applies retention Retention Policy Engine
Relay Event Database syncs state Negentropy Sync Engine
Relay Query Engine streams events Relay Client
Relay Client normalizes events Event Normalizer
Event Normalizer deduplicates records Deduplication Engine
Deduplication Engine logs ingestion Indexer Write-Ahead Log
Indexer Write-Ahead Log writes records Indexer Database
Indexer Database updates search structures Search Index
Search Index supports queries Query Planner
Query Planner executes ranking Ranking Engine
Ranking Engine returns results Registry API
Registry API enforces policy Provider Policy Engine
Registry API emits metrics Metrics Collector
Relay Query Engine feeds history Bulk Subscriber
Bulk Subscriber normalizes data Archive Normalizer
Archive Normalizer stores history Archive Database
Archive Database plans sync Sync Planner
Sync Planner executes sync Sync Executor
Sync Executor updates archive Archive Database
Archive Database serves exports Export API
Registry API creates descriptor Registry Descriptor
Registry Descriptor signs descriptor Descriptor Signer
Descriptor Signer publishes descriptor Ingress Handler
Relay Query Engine provides registry ads Registry Scanner
Registry Scanner selects registries Selection Engine
Selection Engine dispatches queries Fan-Out Engine
Fan-Out Engine collects responses Response Collector
Response Collector normalizes results Result Normalizer
Result Normalizer deduplicates assets Result Deduplicator
Result Deduplicator ranks results Federated Ranker
Federated Ranker serves results Presentation API
Relay Query Engine streams raw events Raw Nostr Client
Raw Nostr Client filters locally Filter Engine
Filter Engine executes code Compute Executor
Registry API provides asset references Asset Fetcher
Asset Fetcher downloads asset Decentralized Asset Storage
Asset Fetcher verifies integrity Integrity Verifier