Skip to main content
Memvid is designed around a simple but powerful principle: everything in one file. This page explains the architecture that makes this possible.

Core Design Principles

1. Single-File Guarantee

Every .mv2 file is completely self-contained:
  • No sidecars - Never creates .wal, .shm, .lock, or journal files
  • Fully portable - Copy, move, or share the file freely
  • No database - No external services required

2. Crash Safety

The embedded Write-Ahead Log (WAL) ensures data integrity:
  • Writes go to WAL first, then to permanent storage
  • Automatic recovery on file open after crashes
  • Recovery completes in under 250ms even for large files

3. Determinism

Same inputs produce identical bytes on the same platform:
  • Reproducible builds for testing and QA
  • Verifiable file integrity with checksums
  • Predictable behavior across runs

4. Performance

Optimized for fast search and retrieval:
  • Search latency: ~5ms for 50K documents
  • Cold start: under 200ms
  • WAL append: under 0.1ms per write

File Layout

The .mv2 file format has a well-defined structure: The 4 KB header contains:

Embedded WAL

The WAL is sized based on total file capacity: Checkpoint triggers:
  • WAL reaches 75% capacity
  • User calls seal()
  • Every 1,000 transactions
  • Clean shutdown

Frames

Frames are the fundamental unit of storage. Each frame contains:
  • Payload - The actual content (text, binary, media)
  • Metadata - Title, URI, timestamps, tags, labels
  • Checksum - BLAKE3 hash for verification
  • Encoding - Plain or Zstd compressed

Search Architecture

Memvid supports three search modes:

Lexical Search (BM25)

Fast keyword search using BM25 ranking:
  • Full-text search with term frequency scoring
  • Date range filters: date:[2024-01-01 TO 2024-12-31]
  • Tokenization and stemming
Semantic similarity search using embeddings:
  • Fast approximate nearest neighbor search
  • Optional Product Quantization (PQ) for 16x compression
  • Configurable embedding models
Combines both approaches:
  1. Run lexical search for keyword matches
  2. Run vector search for semantic similarity
  3. Merge and rerank results
  4. Return top-k hits

Developer Walkthrough

Here’s how to work with Memvid in practice:

Using the CLI

Using the Python SDK

Using the Node.js SDK

Verification and Repair

Memvid includes built-in tools for file health:

Verify

Check file integrity without modification:

Doctor

Diagnose and repair issues:

Single-File Check

Ensure no auxiliary files were created:

Checksums and Integrity

Defense in depth with cascading checksums:

Next Steps