Skip to content

Architecture

Replicated relays, gossip and verifiable aggregation over Hyperswarm, and the relay network they extend.

HyperNostr

HyperNostr architecture

Select the diagram to open it at full size.

Ingress & Verification

Component Role
Swarm Listener Receives events from L1
Signature Verification Authenticates author
Hash Verification Ensures immutability
Replay Guard Blocks old or reordered events

Shard Routing

Component Role
Hash Parser Extracts prefix
Shard Router Maps prefix → shard

Truth Layer

Shard 4A

  • Autobase-4A
  • DAG Builder
  • Finalizer

Shard 00

Component Role
Autobase-00 Ordered event log
DAG Builder Causal ordering
Finalizer Majority checkpoint

Indexer / Projection Pipeline

Component Role
Autobase Tailer Reads finalized log
Event Decoder Parses semantics
Projection Queue Back-pressure buffer
Projection Worker Writes read DB

Verified Read API

Component Role
API Router Request dispatch
Query Planner Shard & index selection
Proof Fetcher Reads proofs
Data Fetcher Reads SQL
Response Assembler Data + proof

State Layer

Component Role
State Reducer Applies finalized events
Hyperbee KV Store Current repo state
Merkle Root Calculator Global state hash

Read-Optimized Storage

Component Role
Merkle Proof Store Verification paths
SQL / Search DB Fast queries

Client / Consumer

Component Role
API Client HTTP / WS calls
Root Hash Fetcher Fetches latest root
Merkle Verifier Trust but verify
Client UI User search, browse

Nostr Clients

Component Role
Nostr Client Publishes and queries events
WebSocket Client Connects to relay

Hyper-Nostr Relay Node

WebSocket Relay Interface

Component Role
WebSocket Ingress Receives Nostr events
Client Auth; Policy checks NIP checks, rate limits
WebSocket Response Streams events to clients

Relay-to-Relay Replication

Component Role
Hyperswarm Relay discovery using the DHT, or an L1 relay
Peer Manager Maintains relay connections
Replication Streams Hypercore sync

Event Processing Pipeline

Component Role
Event Validator Signature, schema check
Event Normalizer Canonical event format
Event Deduplicator Drops repeated events

Local Distributed Storage

Component Role
Hypercore Append-Only Log Immutable event history
Local Event Index Fast client queries

Autonomous Consensus

Component Role
Autobase Orders events across relays
DAG linearizer Resolves ordering differences

Peer A (Relay or Aggregator)

Application Logic

Component Role
Write API Creates or updates data
Read API Queries local state

P2P Networking

Component Role
Topic Joiner Selects shared topic
Hyperswarm Node Peer discovery NAT traversal
Replication Engine store.replicate()

Truth & State

Component Role
Hyperbee DB Key-Value state derived from consensus
Autobase Merges multi-writer logs

Local Storage Stack

Component Role
Local Writer Hypercore Append-only log for this peer
Corestore Manages multiple Hypercores

Peer B (Relay or Aggregator)

P2P Networking

Component Role
Topic Joiner Selects shared topic
Hyperswarm Node Peer discovery & NAT traversal
Replication Engine store.replicate()

Local Storage Stack

Component Role
Corestore Manages multiple Hypercores
Local Writer Hypercore Append-only log for this peer

Application Logic

Component Role
Write API Creates or updates data
Read API Queries local state

Truth & State

Component Role
Autobase Merges multi-writer logs
Hyperbee DB Key-Value state derived from consensus

Author and relay gossip

Component Role
Author UI / CLI Creates or updates code assets
Local Repository FS Source code assets
Git / Asset Engine Manages versions & diffs
Hash Engine Computes content hashes
Key Store Author private keys
Metadata Builder Repo ID, tags, URL, hash
Signer Signs metadata
Nostr Pointer Event Signed metadata only
Relay Ingress Receives signed Nostr events
Event De-duplication Drops repeats
Short-term Cache Prevents rebroadcast loops
Event Broadcaster Publishes to swarm
Hyperswarm Overlay Peer discovery + transport
Encrypted Streams Authenticated P2P links

Interactions: HyperNostr

From Interaction To
Swarm Listener incoming event Signature Verification
Signature Verification valid signature Hash Verification
Hash Verification valid hash Replay Guard
Replay Guard verified event Hash Parser
Hash Parser hash prefix Shard Router
Shard Router route event Autobase-00
Shard Router route event Autobase-4A
Autobase-00 append DAG Builder
DAG Builder ordered graph Finalizer
Autobase-4A append DAG Builder
DAG Builder ordered graph Finalizer
Finalizer final events State Reducer
Finalizer final events State Reducer
State Reducer state update Hyperbee KV Store
Hyperbee KV Store state snapshot Merkle Root Calculator
Autobase-00 log stream Autobase Tailer
Autobase-4A log stream Autobase Tailer
Autobase Tailer raw events Event Decoder
Event Decoder parsed events Projection Queue
Projection Queue work items Projection Worker
Projection Worker indexed data SQL / Search DB
Projection Worker proof material Merkle Proof Store
API Router search request Query Planner
Query Planner data query Data Fetcher
Query Planner proof query Proof Fetcher
Data Fetcher result rows Response Assembler
Proof Fetcher merkle proof Response Assembler
Client UI user query API Client
API Client API call API Router
Response Assembler data + proof API Client
API Client response Merkle Verifier
Root Hash Fetcher root hash Merkle Verifier
Merkle Verifier verified result Client UI
Author UI / CLI edit / commit Local Repository FS
Local Repository FS version control Git / Asset Engine
Git / Asset Engine content bytes Hash Engine
Hash Engine hash Metadata Builder
Metadata Builder unsigned metadata Signer
Key Store private key Signer
Signer signed event Nostr Pointer Event
Nostr Pointer Event publish event Relay Ingress
Relay Ingress raw event Event De-duplication
Event De-duplication unique event Short-term Cache
Short-term Cache cached event Event Broadcaster
Event Broadcaster event gossip Encrypted Streams
Hyperswarm Overlay peer discovery Encrypted Streams
Write API application write request Hyperbee DB
Hyperbee DB state mutation Autobase
Autobase append operation Local Writer Hypercore
Local Writer Hypercore persist blocks Corestore
Write API application write request Hyperbee DB
Hyperbee DB state mutation Autobase
Autobase append operation Local Writer Hypercore
Local Writer Hypercore persist blocks Corestore
Topic Joiner join topic Hyperswarm Node
Topic Joiner join topic Hyperswarm Node
Hyperswarm Node peer discovered Replication Engine
Hyperswarm Node peer discovered Replication Engine
Replication Engine bi-directional core replication Replication Engine
Replication Engine bi-directional core replication Replication Engine
Replication Engine request missing blocks Corestore
Replication Engine request missing blocks Corestore
Corestore new blocks received Autobase
Corestore new blocks received Autobase
Autobase linearized view Hyperbee DB
Autobase linearized view Hyperbee DB
Read API query current state Hyperbee DB
Read API query current state Hyperbee DB
Nostr Client publish / query events WebSocket Client
WebSocket Ingress incoming event Client Auth; Policy checks
WebSocket Client WebSocket publish WebSocket Ingress
Client Auth; Policy checks validated event Event Validator
Event Validator valid event Event Normalizer
Event Normalizer canonical event Event Deduplicator
Event Deduplicator unique event Hypercore Append-Only Log
Hypercore Append-Only Log index update Local Event Index
Hypercore Append-Only Log append event Autobase
Autobase event graph DAG linearizer Resolves ordering differences
DAG linearizer Resolves ordering differences final order Hypercore Append-Only Log
Hyperswarm discover relays Peer Manager
Peer Manager establish connections Replication Streams
Replication Streams replicate logs Hypercore Append-Only Log
Local Event Index query result WebSocket Response
WebSocket Response event stream WebSocket Client

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