vectrust

πŸ› οΈ Vectrust Local Development Setup Guide

Welcome to the Vectrust development environment! This guide walks you through setting up your local machine to build, test, benchmark, and contribute to the Vectrust vector database engine.


1. System Prerequisites

Vectrust is written in 100% pure Rust and requires Rust 1.75+ (Edition 2021). It has zero external C/C++ or system library dependencies.

Install Rust & Cargo

If you don’t already have Rust installed, use rustup:

# macOS / Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Windows
# Download and run rustup-init.exe from https://rustup.rs

Verify your installation:

rustc --version   # Should report rustc 1.75.0 or higher
cargo --version   # Should report cargo 1.75.0 or higher

2. Clone the Repository

Clone the repository with Git:

git clone https://github.com/techwastiinfotech/vectrust.git
cd vectrust

3. Building the Project

Build Debug Library & Binary

cargo build

This compiles both the library crate (vectrust) and the CLI binary (vectrust).

Build Optimized Release Executable

For maximum SIMD loop unrolling and thin LTO optimization:

cargo build --release --bin vectrust

The resulting optimized executable will be located at:

Test running the executable:

cargo run --bin vectrust -- --help

4. Running the Test Suite

Vectrust has a comprehensive test suite covering SIMD vector math, HNSW graph construction, concurrent readers/writers, metadata filtering, and WAL/snapshot persistence.

Run All Unit & Integration Tests

cargo test

Run Tests with Full Stdout Output

cargo test -- --nocapture

Run a Specific Integration Test

# Concurrency & thread safety test
cargo test --test concurrency_tests

# HNSW graph CRUD & recall test
cargo test --test hnsw_tests

# Metadata filtering logic test
cargo test --test metadata_filtering_tests

# WAL persistence & atomic snapshot compaction test
cargo test --test persistence_tests

Continuous Test Watcher

Automatically re-run tests on every code edit:

cargo watch -x test

5. Running Examples & Benchmarks

Explore real-world usage patterns via the examples/ directory:

# 1. Quickstart (inserting, searching, payload inspection)
cargo run --example quickstart

# 2. Metadata filtering with nested JSON dot-notation
cargo run --example metadata_filtering

# 3. High-concurrency benchmark with streaming writes and Rayon batch queries
cargo run --release --example concurrent_search

# 4. HNSW vs Flat ground truth accuracy and latency benchmark
cargo run --release --example hnsw_vs_flat_benchmark

# 5. Persistent storage with simulated crash recovery and WAL replay
cargo run --example persistent_storage

6. Code Quality & Formatting

Before opening a pull request, verify that your code adheres to project formatting and linting rules:

Check Formatting

cargo fmt --check

To automatically format all code:

cargo fmt

Run Clippy Linter

cargo clippy --all-targets --all-features -- -D warnings

7. Generating & Previewing Documentation

Generate Rustdoc API Documentation

cargo doc --no-deps --all-features --open

Preview the Interactive GitHub Pages Documentation

The site/ directory contains the modern documentation website and live 2D vector playground:

# Using Python 3 built-in HTTP server:
python -m http.server 8080 --directory site

# Or using Node.js / npx serve:
npx serve site

Open your browser to http://localhost:8080 to interact with the documentation and simulator.


8. Directory Structure Overview

vectrust/
β”œβ”€β”€ Cargo.toml            # Package configuration and dependencies
β”œβ”€β”€ README.md             # Project overview & badges
β”œβ”€β”€ CONTRIBUTING.md       # Contribution guidelines & standards
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/        # GitHub Actions (CI, release, pages)
β”‚   └── ISSUE_TEMPLATE/   # Issue and PR templates
β”œβ”€β”€ docs/                 # Detailed architecture & API documentation
β”œβ”€β”€ site/                 # Interactive GitHub Pages documentation app
β”œβ”€β”€ examples/             # Standalone runnable example programs
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib.rs            # Public API exports & prelude
β”‚   β”œβ”€β”€ db.rs             # Top-level Vectrust instance coordinator
β”‚   β”œβ”€β”€ collection.rs     # Thread-safe collection reader/writer state
β”‚   β”œβ”€β”€ metric.rs         # SIMD-vectorized distance functions (L2, Cosine, Dot, L1)
β”‚   β”œβ”€β”€ filter.rs         # JSON metadata predicate evaluation engine
β”‚   β”œβ”€β”€ types.rs          # Core data models: Point, PointId, SearchQuery, Config
β”‚   β”œβ”€β”€ error.rs          # Error types (VectrustError, Result)
β”‚   β”œβ”€β”€ bin/
β”‚   β”‚   └── vectrust.rs   # CLI executable tool (info, check, benchmark, repl)
β”‚   β”œβ”€β”€ index/
β”‚   β”‚   β”œβ”€β”€ hnsw.rs       # HNSW proximity graph ANN index
β”‚   β”‚   └── flat.rs       # Flat brute-force Rayon linear scan index
β”‚   └── storage/
β”‚       β”œβ”€β”€ wal.rs        # Write-Ahead Log append journal & CRC32
β”‚       └── snapshot.rs   # Atomic snapshot serializer & CRC32 verification
└── tests/                # Integration test suites

9. Troubleshooting Common Issues

Issue: unsupported target or missing SIMD optimization

Issue: Permission denied during git push