Architecture
How KiteDB is structured internally
KiteDB is built as a layered system. Each layer has a specific job, and they work together to provide fast, reliable graph storage.
The Three Layers
Query Layer
db.insert(user).values({...})Graph Layer
createNode(), addEdge(), getNeighborsOut()Storage Layer
Query Layer
This is what you interact with. It provides the Drizzle-style API with full TypeScript type inference. When you write db.insert(user).values(...), the query layer validates your schema, converts TypeScript types to storage types, and calls into the graph layer.
Graph Layer
Manages the graph abstraction: nodes with properties, edges between nodes, and traversals. Handles transaction boundaries and coordinates reads between the snapshot and delta.
Storage Layer
The foundation. Stores data in a format optimized for graph operations. The key insight here is the Snapshot + Delta model, which separates immutable historical data from pending changes.
What Happens When You Insert a Node
Let's trace through a simple insert:
Query Layer
user has required propertiesage: 30 → internal I64 typecreateNode(...)Graph Layer
NodeID (monotonic counter)Storage Layer
createdNodes mapWhat Happens When You Read
Reads merge data from two sources:
Key Index Lookup
delta.keyIndex (recent changes)NodeIDProperty Fetch
delta.modifiedNodes for changesWhy This Design
| Design Choice | Benefit |
|---|---|
| Snapshot + Delta | Reads don't block writes. Snapshot is immutable, delta is small. |
| CSR format for edges | Traversals read contiguous memory. CPU cache loves this. |
| WAL for durability | Committed data survives crashes. Recovery is fast. |
| Single file | Portable, atomic operations, simpler deployment. |
| Memory-mapped I/O | OS handles caching. Zero-copy reads. |
Next Steps
- Snapshot + Delta – The core storage model in detail
- CSR Format – How edges are stored
- Single-File Format – The .kitedb file layout