HyperspaceDB is a specialized, high-performance spatial AI and vector database designed for high-throughput hyperbolic and Euclidean embedding search. This document details its internal architecture, command-query separation, storage engine, real-time caching, WriteBuffer protocols, and federated synchronization algorithms.
The system strictly follows a Command-Query Separation (CQS) pattern, optimized for write-heavy continuous ingestion and low-latency search workflows.
graph TB
subgraph "Client Layer"
PY[Python SDK]
TS[TypeScript SDK]
GO[Go SDK]
CPP[C++ SDK]
DART[Dart SDK]
ROS2[ROS2 Node]
end
subgraph "API Layer"
GRPC[gRPC Server<br/>Tonic]
REST[REST API Server<br/>Axum]
end
subgraph "Real-Time Ingestion Tier"
WB[WriteBuffer<br/>DashMap RAM]
WAL[Write-Ahead Log<br/>Segmented]
CACHE[L0 Hot Tier Cache<br/>L1 DashMap / L2 HNSW]
end
subgraph "Core Engine (LSM-Tree + Cascade)"
MEM[MemTable<br/>Active HNSW]
CHUNK[Immutable Chunks<br/>SSTables]
ROUTER[Meta-Router<br/>IVF Centroids]
CASCADE[Cascade Pipeline<br/>MRL Truncation]
BACKEND[Chunk Backend<br/>Local/S3]
QUANT[Quantization<br/>Anisotropic SQ8/Binary]
end
subgraph "Storage Layer"
FLUSH[Flush Worker]
SNAP[Snapshots<br/>rkyv mmap]
S3[(S3 / Cloud Storage)]
end
subgraph "Replication & Anti-Entropy"
MERKLE[256-Bucket Merkle Tree]
GOSSIP[Gossip Swarm<br/>UDP socket]
end
subgraph "Visualization (Phase 4)"
DASH[React Dashboard]
DASH -->|/api/graph/explore| REST
DASH -->|Canvas| POINCARE[Poincaré Disk]
DASH -->|Canvas| MOMENTUM[Momentum HUD]
end
PY --> GRPC
TS --> GRPC
GO --> GRPC
CPP --> GRPC
DART --> GRPC
ROS2 --> GRPC
GRPC --> WB
GRPC --> WAL
REST --> CACHE
WB --> MEM
WAL -.-> FLUSH
FLUSH --> CHUNK
CHUNK --> BACKEND
BACKEND --> S3
style S3 fill:#f9f,stroke:#333,stroke-width:2px
style ROUTER fill:#9f9,stroke:#333,stroke-width:2px
style MEM fill:#99f,stroke:#333,stroke-width:2px
sequenceDiagram
participant Client
participant gRPC / Axum
participant WAL
participant WriteBuffer
participant IndexQueue
participant MemTable (HNSW)
Client->>gRPC / Axum: insert(vector, metadata)
gRPC / Axum->>WAL: append(operation)
WAL-->>gRPC / Axum: persisted
gRPC / Axum->>WriteBuffer: insert(internal_id, user_id, vector, metadata)
gRPC / Axum->>IndexQueue: dispatch_to_indexer(internal_id)
gRPC / Axum-->>Client: success (Reflex Ingest OK)
Note over IndexQueue, MemTable (HNSW): Asynchronous Indexing Task
IndexQueue->>MemTable (HNSW): build_links_for_node(internal_id)
MemTable (HNSW)-->>WriteBuffer: remove(internal_id) (Snapshot Promotion)
sequenceDiagram
participant Client
participant QueryEngine
participant L0 Cache (RAM)
participant WriteBuffer (RAM)
participant MemTable (HNSW)
participant Disk SST (Mmap)
Client->>QueryEngine: search(query_vector, k, filters)
QueryEngine->>L0 Cache (RAM): check_exact_match()
alt L0 Cache Hit
L0 Cache (RAM)-->>Client: returns top-k
else L0 Cache Miss
QueryEngine->>WriteBuffer (RAM): scan_linear_parallel(filters)
QueryEngine->>MemTable (HNSW): traverse_hnsw(truncated_32d)
QueryEngine->>Disk SST (Mmap): rerank_full_128d(candidates)
QueryEngine->>QueryEngine: merge_and_deduplicate()
QueryEngine-->>Client: returns final top-k
end
HyperspaceDB relies on principles from modern cosmology to execute vector search dynamically. The database maps semantic dispersion to real physical properties:
i8/f16). Nearing the Euclidean horizon ($||x|| \to 1$), exact relationships demand extreme mapping in pure f64.TriggerReconsolidation, restructuring the graph dynamically without full re-indexing.HyperspaceDB uses an LSM-Tree inspired architecture for vector search, optimized for high throughput, cloud tiering, and multi-vector schemas.
graph TD
subgraph "Local Disk"
WAL_FILES[wal_segment_*.log]
META[meta.json / state.json]
C0[chunk_0.hyp]
C1[chunk_1.hyp]
end
subgraph "Memory"
MEM_T[MemTable HNSW]
MMAP[Memory Map / Zero-Copy]
end
subgraph "Cloud"
S3[(S3 Bucket)]
end
C0 -.mmap.-> MMAP
C1 -.mmap.-> MMAP
WAL_FILES -.replay.-> MEM_T
C1 --Offload--> S3
S3 --Lazy Load--> C1
New vectors are first appended to the Write-Ahead Log (WAL) and simultaneously indexed in an in-memory HNSW MemTable.
[Magic: u8][Length: u32][CRC32: u32][OpCode: u8][Data...].HS_WAL_SEGMENT_SIZE_MB, it is rotated (frozen)..hyp).fsync after every write. Max safety.fsync in a background thread every N ms. Good compromise.Data is stored in segmented .hyp files, each containing a subset of the collection.
ScalarI8), reducing size by 8x or more.Cold chunks can be transparently offloaded to S3-compatible storage.
HS_MAX_LOCAL_CACHE_GB).To bypass the classic bottleneck of HNSW databases (where bulk-inserted vectors remain isolated until fully indexed in the background), HyperspaceDB implements a transparent, dual-layered memory tier.
Incoming Ingestion / Search Request
│
┌──────────┴──────────┐
▼ ▼
[WriteBuffer] [L0 Hot Tier Cache]
- In-memory DashMap - L1: DashMap (~1 µs lookups)
- Rayon-parallel - L2: Fallback ANN HNSW (~100 µs)
linear scanning - Automatic TTL Eviction
- Snapshot Promotion - Auto-rebuild (>30% tombstones)
hyperspace-cache)The L0 Cache resides directly on the client read-path to bypass both HNSW graph traversal and disk reads.
DashMap storing Arc<Vec<f64>> + Arc<HashMap> data indexed by ID. Lookups complete in ~1 µs.instant-distance) utilizing ArcSwap for lock-free reads during background rebuilds. Lookups complete in ~100 µs.__ttl key in vector metadata every 100 ms. Expired records are invalidated from L1 and flagged as tombstones in L2.metadata.forward to preload active keys and de-quantized vectors into the L1 and L2 cache, ensuring high cache hit rates from startup.The WriteBuffer guarantees that vectors are searchable from the millisecond they are inserted.
DashMap before queuing for background graph linkage.WriteBuffer, preventing memory bloat.We use a Generic Metric system (Metric<N>) to support multiple geometries efficiently, dispatched at compile-time via Const Generics.
graph TD
L2_0[Layer 2: Entry Point]
L1_0[Layer 1: Node 0]
L1_1[Layer 1: Node 1]
L0_0[Layer 0: Node 0]
L0_1[Layer 0: Node 1]
L0_2[Layer 0: Node 2]
L0_3[Layer 0: Node 3]
L2_0 --> L1_0
L2_0 --> L1_1
L1_0 --> L0_0
L1_0 --> L0_1
L1_1 --> L0_2
L1_1 --> L0_3
L0_0 --> L0_1
L0_1 --> L0_2
L0_2 --> L0_3
| Formula: $ d(u, v) = \text{acosh}\left(1 + 2 \frac{ | u-v | ^2}{(1- | u | ^2)(1- | v | ^2)}\right) $ |
| Optimization: Employs pre-computed scaling factors $\alpha = 1 - | u | ^2$ and bypasses expensive hyperbolic functions during graph routing. |
| Constraint: Vectors strictly satisfy $ | u | < 1$. |
| Formula: $ d(u, v) = \sum | CDF_u(i) - CDF_v(i) | $ |
HyperspaceDB implements a hybrid replication model supporting both high-availability Cloud deployments and dynamic Edge swarms.
last_logical_clock. The Leader replays WAL segments incrementally from that clock position.Used for decentralized networks without a central coordinator:
GossipMessage::Heartbeat (containing collection hashes and clock state) every 5 seconds over raw tokio::net::UdpSocket.PEER_TTL timeouts.graph TD
ROOT[Root Hash]
B0[Bucket 0<br/>Hash]
B1[Bucket 1<br/>Hash]
B255[Bucket 255<br/>Hash]
V0_0[Vec 0]
V0_1[Vec 256]
V1_0[Vec 1]
V1_1[Vec 257]
V255_0[Vec 255]
ROOT --> B0
ROOT --> B1
ROOT --> B255
B0 --> V0_0
B0 --> V0_1
B1 --> V1_0
B1 --> V1_1
B255 --> V255_0
Collection drop implementations ensure that active background indexing loops, UDP gossip heartbeats, and snapshot threads are immediately cancelled to prevent memory leaks and thread panics.dirty_decay_ms:0) to guarantee memory reclamation post-vacuuming.user_id prefixes: {user_id}_{collection_name}.x-hyperspace-user-id header, which restricts execution scope entirely to the tenant’s namespace.mmap segments) are tracked dynamically to support resource-based billing models.graph LR
subgraph "Core Runtime"
RUST[Rust Nightly]
SIMD[SIMD AVX2/NEON]
TOKIO[Tokio Async]
RAYON[Rayon Parallelism]
end
subgraph "Storage & Deserialization"
MMAP[memmap2 Zero-Copy]
RKYV[rkyv mmap serialization]
DASH[DashMap Sharding]
end
subgraph "Networking"
TONIC[Tonic gRPC]
AXUM[Axum REST API]
PROTO[Protobuf]
end
subgraph "WebAssembly / Browser"
WBIND[wasm-bindgen]
REXIE[rexie IndexedDB]
end
RUST --> SIMD
RUST --> TOKIO
RUST --> RAYON
RUST --> MMAP
RUST --> RKYV
RUST --> DASH
RUST --> TONIC
RUST --> AXUM
TONIC --> PROTO
RUST --> WBIND
WBIND --> REXIE
| Operation | Latency | Throughput | Notes |
|---|---|---|---|
| L1 Cache Lookup (exact) | ~1 µs | 1,000,000+ QPS | Bypasses all locks and IO |
| L2 Cache Search (ANN) | ~100 µs | 200,000+ QPS | Thread-safe, lock-free HNSW fallback |
| WriteBuffer Insert (WAL + RAM) | ~6.4 µs | 156,587 QPS | Immediate persist, async HNSW |
| WriteBuffer Linear Scan | < 2.0 ms | 50,000 QPS | 50k vectors, multi-threaded Rayon |
| Search (MRL Cascade) | 0.85 ms (p99) | 210,000 QPS | 64d RAM Head + 1536d Disk Rerank |
| Search (Hyperbolic) | 2.47 ms (p99) | 165,000 QPS | Poincaré 64d + SIMD |
| Search (Euclidean) | 16.12 ms (p99) | 17,800 QPS | Euclidean 1024d |
| Cold Startup / Lazy Load | < 50 ms | — | Fast mmap file handles |
| Synchronous Snapshot | ~500 ms | — | Synchronous serialization |
Copyright © 2026 YARlabs - Confidential & Proprietary