Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt

Use this file to discover all available pages before exploring further.

VectoriaDB is a production-ready in-memory vector database built on transformers.js. Use it to surface the right tool, prompt, or document snippet from natural-language queries without shipping data to an external service.

Features

Offline Embeddings

Embeddings run locally via transformers.js, so your data never leaves the server and you avoid API quotas.

Type-safe Metadata

Strong generics ensure every document you index keeps the same shape as your metadata interface.

Operational Guardrails

Built-in rate limits, batch validation, HNSW indexing, and storage adapters keep the index production ready.

When to Use VectoriaDB

  • Tool discovery - Surface the right tool from natural-language queries
  • Document search - Semantic search over documents, prompts, or code snippets
  • Recommendation systems - Find similar items based on text embeddings
  • Offline-first applications - No external API dependencies
The default Xenova all-MiniLM-L6-v2 model is ~22 MB. The first initialization downloads and caches it under cacheDir; subsequent boots reuse the local copy.

Installation

npm install vectoriadb

Quick Start

import { VectoriaDB, DocumentMetadata } from 'vectoriadb';

interface ToolDocument extends DocumentMetadata {
  toolName: string;
  owner: string;
  tags: string[];
  risk: 'safe' | 'destructive';
}

const toolIndex = new VectoriaDB<ToolDocument>({
  cacheDir: './.cache/transformers',
  defaultSimilarityThreshold: 0.4,
});

await toolIndex.initialize(); // downloads and warms the embedding model once

// Add a document
await toolIndex.add('users:list', 'List all users with pagination', {
  id: 'users:list',
  toolName: 'list',
  owner: 'users',
  tags: ['read'],
  risk: 'safe',
});

// Search
const results = await toolIndex.search('find users');
console.log(results[0].metadata.toolName); // 'list'
initialize() must run before add, search, or update. Calling it twice is safe because VectoriaDB short-circuits if it is already ready.

Core Concepts

Documents

Each document has:
  • id - Unique identifier
  • text - Natural language text to embed
  • metadata - Type-safe custom data

Embeddings

VectoriaDB generates embeddings locally using transformers.js. The default model is all-MiniLM-L6-v2 which provides good quality with fast inference. Search returns documents ranked by cosine similarity to your query. You can filter results by metadata and set minimum similarity thresholds.

Configuration Options

OptionTypeDefaultDescription
modelNamestring'Xenova/all-MiniLM-L6-v2'Embedding model to use
cacheDirstring'./.cache/transformers'Model cache directory
dimensionsnumberAuto-detectedVector dimensions
defaultSimilarityThresholdnumber0.3Minimum similarity score
defaultTopKnumber10Default results limit
useHNSWbooleanfalseEnable HNSW index
maxDocumentsnumber100000Max documents (DoS protection)
maxDocumentSizenumber1000000Max document size in chars
maxBatchSizenumber1000Max batch operation size
verboseErrorsbooleantrueEnable detailed errors

Indexing

Adding and updating documents

Search

Querying the index

Persistence

Storage adapters

HNSW

Scaling to large datasets

TF-IDF

Zero-dependency alternative