• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
kamenxrider

kamenxrider

slimarmor

Semantic vector DB on Val Town SQLite — DiskANN, hybrid search
Public
Like
slimarmor
Home
Code
6
README.md
H
api.ts
plandan.md
review.md
turso-doc.md
vectordb.ts
Environment variables
4
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
2/2/2026
Viewing readonly version of main branch: v28
View latest version
README.md

🛡️ SlimArmor - Mini Vector DB for Val Town

A lightweight, optimized vector database built on Val Town's SQLite (powered by Turso/libSQL) with Nebius Qwen3-Embedding-8B embeddings.

Features

  • 4096-dimensional embeddings via Nebius Qwen3-Embedding-8B
  • Semantic search with cosine similarity
  • Distance scores in search results (0 = identical, 1 = orthogonal, 2 = opposite)
  • Smart re-embedding - only re-embeds when text changes (content hash check)
  • Optimized index for storage efficiency

Index Optimizations

OptimizationBenefit
compress_neighbors=float875% less index storage
max_neighbors=6466% fewer neighbors vs default
Distance filteringFilter out low-relevance results

Storage Estimate

~22KB per record → ~45,000 records per 1GB

API Endpoints

MethodEndpointDescription
GET/Stats + API info
GET/testSmoke test with demo data
POST/upsertInsert/update record {id, text, meta?}
POST/searchSearch {query, k?, maxDistance?}
POST/deleteDelete record {id}
GET/get?id=...Get single record
GET/list?limit=...List record IDs
POST/reindexRecreate index with optimized settings

Usage

Upsert a record

curl -X POST https://YOUR_ENDPOINT/upsert \ -H "Content-Type: application/json" \ -d '{"id": "doc-1", "text": "Dogs are loyal pets", "meta": {"category": "animals"}}'

Search

curl -X POST https://YOUR_ENDPOINT/search \ -H "Content-Type: application/json" \ -d '{"query": "furry pets", "k": 5}'

Search with distance filter

Only return results with distance ≤ 0.5 (more relevant):

curl -X POST https://YOUR_ENDPOINT/search \ -H "Content-Type: application/json" \ -d '{"query": "furry pets", "k": 10, "maxDistance": 0.5}'

Understanding Distance Scores

The distance field uses cosine distance:

DistanceMeaning
0.0 - 0.3Very similar
0.3 - 0.5Related
0.5 - 0.7Somewhat related
0.7+Likely unrelated

Recommended: Use maxDistance: 0.5 to filter out noise.

Import as a Module

You can import vectordb.ts directly in other Val Town projects:

import * as db from "https://esm.town/v/kamenxrider/slimarmor/vectordb.ts"; // Setup (creates table + index if not exists) await db.setup(); // Upsert await db.upsert("my-doc", "Some text to embed", { category: "notes" }); // Search const results = await db.search("search query", 10, 0.5); // Returns: [{ id, text, meta, distance }, ...] // Delete await db.remove("my-doc"); // Stats const stats = await db.stats(); // Returns: { count: 5, estimated_storage_mb: 0.11 }

Environment Variables

VariableDescription
NEBIUS_API_KEYYour Nebius API key for embeddings

Files

FileDescription
vectordb.tsCore vector DB library (importable)
api.tsHTTP API endpoints
README.mdThis file

Tech Stack

  • Runtime: Val Town (Deno)
  • Database: Val Town SQLite (Turso/libSQL)
  • Embeddings: Nebius Qwen3-Embedding-8B (4096 dims)
  • Vector Index: DiskANN with cosine similarity

License

MIT

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.