Documentation
Introduction to Stackhouse
What is Stackhouse and why should you use it?
Introduction to Stackhouse
🎯 What is Stackhouse?
Stackhouse is a next-generation database that evolves with your application, not against it. Schema-later, AI-native, and realtime.
Stackhouse is an open-source, AI-native database that combines the flexibility of NoSQL with the power of SQL, vector search, and serverless compute—all in one unified system.
📊 The Problem Stackhouse Solves
| Pain point | Why it hurts |
|---|---|
| Migrations | Schema locks, downtime required |
| Vector Search | Separate service, high latency/cost |
| Serverless Compute | Cloud functions only, vendor lock-in |
| Realtime Updates | Multiple tools, complex setup |
Stackhouse eliminates all of this.
✨ The Stackhouse Solution
🌟 Core Philosophy
1️⃣ Schema-Later™
Don't plan your schema upfront. Let it evolve naturally.
Traditional Database
- Day 1: Define schema → wait for migration → deploy
- Day 7: Add field → write migration → deploy
- Day 30: Restructure → complex migration → deploy
- Day 100: Performance → re-index everything → deploy
Result: development slows down as schema grows.
Stackhouse
- Day 1: Push JSON → ✅ works immediately
- Day 7: Push JSON → ✅ schema auto-evolves
- Day 30: Push JSON → ✅ handles any structure
- Day 100: Query → ✅ optimized automatically
Result: development stays fast forever.
Visual Example:
Request 1: POST /users {name: "Alice", age: 25}
Stackhouse infers and creates:
CREATE TABLE users (
name TEXT,
age INTEGER
);Request 2: POST /users {name: "Bob", age: 30, email: "bob@..."}
Stackhouse evolves the schema:
ALTER TABLE users ADD COLUMN email TEXT;Request 3: POST /users {name: "Carol", preferences: {theme: "dark"}}
Stackhouse adapts again:
ALTER TABLE users ADD COLUMN preferences JSON;2️⃣ AI-Native
Vector search is a first-class, unified API — not a bolt-on you have to wire up yourself — even though under the hood it proxies to a dedicated Qdrant instance rather than an in-process index (see Vector Search).
Semantic Search Example:
3️⃣ Realtime 2.0
Bi-directional WebSocket communication, not just server-sent events.
Benefits:
- ✅ Bidirectional subscribe/unsubscribe control messages
- ✅ Multiple table subscriptions per connection
- ✅ Server-initiated push on INSERT/UPDATE/DELETE
Note: this channel is for table-change subscriptions only — there is no arbitrary SQL query-over-WebSocket capability; use the REST query/SQL endpoints for that.
🏗️ Architecture Overview
All data lives in PostgreSQL — Stackhouse does not implement its own storage engine. See Architecture and Storage Engine for the verified breakdown. The JavaScript function runtime (
compute/functions.rs, powered byboa_engine) is implemented and its HTTP router is mounted under/v1/functionsinmain.rs.
🎯 Key Features Deep Dive
1. Automatic Schema Evolution
Initial state: empty database — no tables, no schema.
Insert User Document
POST /users
{ "name": "Alice", "age": 25 }Stackhouse infers:
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
name TEXT,
age BIGINT,
created_at TIMESTAMPTZ DEFAULT NOW()
);Insert Document with New Field
POST /users
{ "name": "Bob", "email": "bob@example.com" } // NEW FIELDStackhouse evolves:
ALTER TABLE users ADD COLUMN IF NOT EXISTS email TEXT;Insert Complex Nested Object
POST /users
{ "name": "Carol", "settings": { "theme": "dark", "notifications": true } }Stackhouse adapts:
ALTER TABLE users ADD COLUMN IF NOT EXISTS settings JSONB;Result: zero downtime, zero manual migrations!
2. PostgreSQL-Backed Storage
Stackhouse does not implement its own storage engine (no custom WAL/MemTable/SSTable stack exists in this codebase). All data is stored in PostgreSQL via sqlx — durability, WAL, compaction, MVCC, and caching are all delegated to Postgres itself.
See Storage Engine for the full breakdown.
3. Vector Similarity Search
Embed the document — "The quick brown fox jumps over the lazy dog"
Passed through an embedding model (e.g. sentence-transformers) to produce a vector: [0.23, -0.45, 0.67, 0.12, ..., 0.89] (384 dimensions for example).
Insert into Stackhouse
POST /v1/vectors/documents/upsert
{
"id": "doc1",
"embedding": [0.23, -0.45, ...],
"data": {"title": "..."}
}HNSW index build (via Qdrant)
- Approximate Nearest Neighbor
- Hierarchical graph structure
- O(log n) search complexity
- Built and served by an external Qdrant instance, not Stackhouse's own storage engine
Query time — "What did the fox do?"
The same embedding model produces a query vector [0.25, -0.43, 0.65, ...]:
POST /v1/vectors/documents/search
{
"vector": [0.25, -0.43, ...],
"top_k": 10
}Results, sorted by similarity
doc1(similarity: 0.88) — most similardoc15(similarity: 0.77)doc7(similarity: 0.69)- …
doc42(similarity: 0.33)
Distance metrics:
- Cosine Similarity (default) — semantic similarity
- Euclidean Distance — geometric distance
Use cases:
- ✅ Semantic search
- ✅ Recommendation systems
- ✅ Document similarity
- ✅ Image search (via vision embeddings)
- ✅ Duplicate detection
💪 Performance Characteristics
No throughput/latency numbers are published — actual performance is governed by the underlying PostgreSQL deployment (instance size, connection pool limits, indexes, network) and, for vector search, by the external Qdrant deployment, rather than by any fixed constant in Stackhouse's own code. There is no bundled benchmark suite in this repo today (see Benchmarks); measure against your own deployment before relying on any comparative number.
🎓 When to Use Stackhouse?
✅ Perfect For:
-
Rapid Prototyping
- Changing requirements? No problem.
- Unknown data model? Start anyway.
- Quick iterations? Native workflow.
-
AI/ML Applications
- Semantic search
- RAG (Retrieval Augmented Generation)
- Recommendation engines
- Similarity matching
-
Realtime Features
- Live dashboards
- Collaborative apps
- Notifications
- Gaming leaderboards
-
Serverless Compute
- Custom business logic
- Data transformations
- Edge computing
- Cost reduction
⚠️ Consider Alternatives For:
-
Legacy SQL Migrations
- If you have strict migration requirements
- Consider: Postgres, MySQL
-
Massive Analytics
- Petabyte-scale data warehousing
- Consider: Snowflake, BigQuery
-
Distributed Transactions
- Multi-region ACID transactions
- Consider: CockroachDB, Spanner
🚀 What's Next?
Continue your journey:
- Quick Start Guide - Get Stackhouse running in 5 minutes
- Architecture Deep Dive - Understand how it works
- API Reference - Explore the API
Ready to start? Continue to Quick Start 🚀