Concepts
Mental models for Brain — typed memory, the write/read pipelines, identity-by-key, the entity graph, and the single-binary architecture.
The four pillars
Typed memory + entity graph
You write plain text. Brain embeds it, stores it as a memory, and asynchronously extracts a typed graph — entities, and Fact / Preference / Event statements and relations between them. Retrieval can walk that graph instead of reducing everything to cosine distance.
Identity by key
An API key is bound to a (namespace, space, permissions) scope when it's minted. Clients never send a scope — the server derives it from the key, and every memory, entity, and index is isolated per (namespace, space).
One write path, one read verb
Every write is an encode; every read is a recall. encode acks the moment the WAL is fsynced, then derives edges and the typed graph in the background. recall fuses three retrievers into a membership answer — Single, Many, or None.
Single binary, no external database
One process embeds everything: an mmap arena for vectors, a WAL, a redb metadata store, in-RAM HNSW, tantivy, and the bundled BGE-small embedder and GLiNER classifier. (The cross-encoder reranker is not bundled — it ships disabled.) Parallelism is sharding. The only outbound dependency is an LLM provider.
Reading order
If you read one thing on each page
Architecture — parallelism is sharding, and the trade is tail-latency predictability bought with throughput. Write pipeline — the ack barrier splits durability from derivation, but a fresh memory is semantically searchable immediately. Entities — an ambiguous resolution writes no link at all, silently. Identity by key — the namespace comes from the credential; the space is per-request at scale. Namespaces — never mint a key per end user. Policies — a disabled thing is always observable as disabled.
Was this page helpful?
Scaling and limits
Shards are chosen once, tenants are capped at single-shard throughput, and the engine is single-node — the boundaries to know before you build on it.
Architecture
Brain is one Rust binary with a strict one-way crate graph — an mmap arena, a WAL, redb, HNSW, tantivy, and bundled models, sharded thread-per-core. No external database.