Isolated databases, mesh networking, consistent hash rings, and the 3-layer presence system. How nodes form a decentralized backend.
Every node is a complete, self-contained marketplace backend. There is no shared database -- ever. Each node maintains its own isolated PostgreSQL instance and its own Redis. Protocol data replicates via gossip; chat data is sharded via rendezvous hashing. This isolation model is the foundation of the network's decentralization guarantees.
| Data Type | Replication Strategy |
|---|---|
| Protocol events | Fully replicated via gossip to every node |
| Listings, orders, collections | Fully replicated via gossip |
| Profiles and reputation | Fully replicated via gossip |
| Governance state (proposals, votes, delegations) | Fully replicated via gossip |
| Chat messages and threads | Sharded via rendezvous hashing |
| Presence data | 3-layer priority system (local socket > remote broadcast > gateway hint) |
| Media cache entries | Sharded via separate media shard assignment |
| PSBT shares | Independent threshold scheme -- NOT affected by chat/media sharding |
Each node's PostgreSQL and Redis are entirely private. Nodes never connect to another node's database. All cross-node communication flows through the gossip mesh and WebSocket connections.
Chat data ownership is determined by rendezvous hashing:
score = SHA256(nodeId + ":" + threadId)
topN = sort all nodes by score descending
replicas = ceil(nodeCount / 3)The shard ring refreshes from the heartbeat table. Only nodes with a heartbeat within the last 5 minutes are included. The ring is cached for 30 seconds.
Operators can opt into storing all data locally instead of only their assigned shards:
| Environment Variable | Effect |
|---|---|
FULL_NODE_CHAT=1 | Node stores ALL chat threads regardless of shard assignment |
FULL_NODE_MEDIA=1 | Node stores ALL media cache entries regardless of shard assignment |
When full-node mode is active, isShardOwner returns true for the local node unconditionally. This is useful for archive nodes or operators who want local search across all conversations.
Critical: Full-node mode does NOT affect PSBT shard distribution. PSBT shares are controlled by the separate MPC threshold scheme and are never influenced by chat/media shard settings.
Every node runs six processes:
Each node's PostgreSQL instance contains tables organized into six domains:
Marketplace tables: listings, orders, profiles, collections, media_cache -- all product and transaction data for the decentralized marketplace.
Agent tables: node_registry, agent_mesh, mesh_latency, agent_pools -- node identity, mesh topology measurements, and agent pool assignments.
Governance tables: proposals, votes, delegations, governance_config -- on-chain governance state including vote delegation relationships and proposal lifecycle.
Realtime tables: chat_threads, chat_messages, presence, typing_indicators -- sharded chat data and presence state.
Rewards tables: reward_claims, mpc_ceremonies, treasury_operations, epoch_snapshots -- signature-based reward distribution, MPC ceremony logs, and treasury audit trail.
Protocol events: protocol_events -- the complete event log. Every signed event gossiped through the network is stored here for full auditability.
When a node boots, it follows this sequence:
FULL_NODE_CHAT and FULL_NODE_MEDIA env vars, configure shard ownership overrides| Mode | Max Connections | Idle Timeout |
|---|---|---|
| Cluster mode | 4 connections | 5 seconds |
| Single-node mode | 10 connections | default |
Cluster mode uses a smaller pool because multiple replicas share the same PostgreSQL host. Single-node mode gets a larger pool since it has exclusive access.
The Rust node-core runs continuous scanner loops to monitor on-chain activity:
User presence resolves through a priority system: