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.
Vectrust is written in 100% pure Rust and requires Rust 1.75+ (Edition 2021). It has zero external C/C++ or system library dependencies.
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
cargo-watch: Automatically recompiles or runs tests on file change:
cargo install cargo-watch
cargo-criterion: Micro-benchmarking analysis tool:
cargo install cargo-criterion
Clone the repository with Git:
git clone https://github.com/techwastiinfotech/vectrust.git
cd vectrust
cargo build
This compiles both the library crate (vectrust) and the CLI binary (vectrust).
For maximum SIMD loop unrolling and thin LTO optimization:
cargo build --release --bin vectrust
The resulting optimized executable will be located at:
./target/release/vectrust.\target\release\vectrust.exeTest running the executable:
cargo run --bin vectrust -- --help
Vectrust has a comprehensive test suite covering SIMD vector math, HNSW graph construction, concurrent readers/writers, metadata filtering, and WAL/snapshot persistence.
cargo test
cargo test -- --nocapture
# 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
Automatically re-run tests on every code edit:
cargo watch -x test
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
Before opening a pull request, verify that your code adheres to project formatting and linting rules:
cargo fmt --check
To automatically format all code:
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo doc --no-deps --all-features --open
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.
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
unsupported target or missing SIMD optimization--release when benchmarking to enable LLVM autovectorization.git config core.sshCommand "ssh -i ~/.ssh/id_rsa_techwasti"