MCPcopy Index your code
hub / github.com/Rupamthxt/VectraDB

github.com/Rupamthxt/VectraDB @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
107 symbols 245 edges 18 files 32 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🟢 Open to work: I am a backend Systems Engineer currently looking for a full-time role in deep infrastructure, database internals, or low-latency systems. I specialize in Go, memory optimization (bypassing GC), and bare-metal hardware. If your team is solving hard throughput problems, let's talk: rupamthxt@gmail.com | LinkedIn

VectraDB ⚡

High-Performance, In-Memory Vector Database written in Go. 550,000+ Writes/sec | 14,000+ QPS Search | HNSW Indexing

VectraDB is a lightweight, cloud-native vector store designed for AI infrastructure and high-throughput embedding workloads. It leverages Arena Memory Allocation to bypass Go's Garbage Collection overhead and implements IVF (Inverted File Index) for ultra-fast Approximate Nearest Neighbor (ANN) search.

🚀 Distributed Mode Available Want to see how this scales? I implemented Multi-Raft Consensus for High Availability and Strong Consistency.

Architecture

graph TD
    A[Client Request] -->|Insert Vector| B(WAL - Write Ahead Log)
    B -->|Durability Sync| C{MemTable}
    C -->|Batch Full| D[Paged Arena Allocator]

    subgraph "Memory Management"
    D -->|Alloc 4MB Page| E[Off-Heap Memory Block]
    E -->|Pointer Arithmetic| F[Vector Node]
    end

    subgraph "Indexing"
    F -->|Insert| G[HNSW Graph Layers]
    end

    style B fill:#f9f,stroke:#333,stroke-width:2px
    style D fill:#bbf,stroke:#333,stroke-width:2px

🚀 Key Features

  • Zero-Copy Architecture: Uses a custom memory arena ([]float32 slab) to minimize GC pauses and maximize CPU cache locality.
  • HNSW Indexing: Implements HNSW graph to reduce search complexity from $O(N)$ to $O(N/K)$, achieving 30x speedups over brute force.
  • High Concurrency: Sharded, lock-free read paths achieving linear scaling across CPU cores.
  • Hybrid Storage: Hot path for vector math (SIMD-ready) and Cold path for metadata retrieval.
  • Persistence: Snapshots to disk (Gob serialization) for crash recovery.
  • Production Ready: Dockerized (15MB image) with Multi-Stage builds.

🛠️ Architecture

VectraDB avoids the common pitfall of storing millions of small structs. Instead, it uses a Columnar-like memory layout:

  1. The Arena: A contiguous block of memory holding only float32 vector data. This ensures high cache hit rates during the dot-product loop.
  2. The HNSW Index: An in-memory HNSW index, drastically reducing the search space.
  3. The Min-Heap: A specialized priority queue implementation (zero-allocation) to track "Top-K" results efficiently.

📊 Benchmarks

Running on standard hardware (M1/M2 or AWS c5.large) with 128-dimensional vectors:

Operation Throughput Latency (p99) Notes
Ingestion (Write) ~550,000 ops/sec < 0.2ms Arena allocation speed
Brute Force Search ~430 QPS ~10ms Baseline (100% Recall)
HNSW Search ~14,000 QPS < 0.1ms 30x Speedup (Approximate)

Benchmark run with 50,000 vectors, 8 concurrent workers.

📦 Installation & Usage

1. Run via Docker (Recommended)

make docker-run
# Or manually:
# docker run -p 8080:8080 -v $(pwd)/data:/root/ vectradb:latest

2. Run Locally

make run

3. API Examples

Insert a Vector:

curl -X POST http://localhost:8080/api/v1/insert \
  -H "Content-Type: application/json" \
  -d '{
    "id": "user_123",
    "vector": [0.1, 0.5, 0.9],
    "metadata": {"role": "engineer"}
  }'

Search:

curl -X POST http://localhost:8080/api/v1/search \
  -d '{"vector": [0.1, 0.5, 0.8], "k": 3}'

📈 Monitoring & Metrics

When running the benchmark binary you can expose Prometheus metrics on http://localhost:9091/metrics (port is configurable with -metrics-port). The program instruments:

  • vectradb_insert_requests_total
  • vectradb_insert_duration_seconds
  • vectradb_search_requests_total
  • vectradb_search_duration_seconds
  • vectradb_vectors_total

Grafana can scrape Prometheus (configured to target localhost:9091) and visualize these counters/histograms while the benchmark simulates load.

# prometheus.yml snippet
scrape_configs:
  - job_name: vectradb_bench
    static_configs:
      - targets: ['localhost:9091']

The main server (make run or docker-run) already exposes /metrics on port 8080 so you can monitor a running cluster as well.

🧠 Future Roadmap

  • Add nprobe parameter to search multiple IVF clusters (Trade-off: Speed vs Recall).
  • Implement Product Quantization (PQ) for memory compression.
  • Support gRPC interface for low-latency internal communication.

Built by Rupam as a High-Performance Systems Engineering Portfolio Project.

Extension points exported contracts — how you extend this code

ShardHandler (Interface)
(no doc) [7 implementers]
internal/store/shard.go

Core symbols most depended-on inside this repo

Search
called by 9
internal/store/shard.go
Add
called by 8
internal/store/hnsw.go
Get
called by 7
internal/store/db.go
Delete
called by 7
internal/store/shard.go
Insert
called by 6
internal/store/shard.go
Close
called by 5
internal/store/disk.go
Quantize
called by 5
internal/store/quantize.go
NewVectraDB
called by 4
internal/store/db.go

Shape

Method 54
Struct 28
Function 22
Interface 2
TypeAlias 1

Languages

Go100%

Modules by API surface

internal/store/shard.go11 symbols
internal/store/hnsw.go10 symbols
internal/store/db.go8 symbols
internal/http/handler.go8 symbols
internal/store/heap.go7 symbols
internal/store/disk.go6 symbols
internal/http/dto.go6 symbols
internal/cluster/fsm.go6 symbols
cmd/server/main.go6 symbols
cmd/node/main.go6 symbols
cmd/loadtest/main.go6 symbols
cmd/benchmark/main.go6 symbols

For agents

$ claude mcp add VectraDB \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact