Skip to main content
Brain is a knowledge graph engine that gives AI agents persistent memory that gets smarter with use. It stores content as Obsidian-compatible markdown on disk, indexes it into PostgreSQL with hybrid BM25 + vector + trigram search, and closes the loop with autonomous optimization — reflecting on result quality, de-duplicating, re-linking, and tuning its own retrieval parameters. No other memory layer does that.

What makes Brain different

Closed-loop intelligence

Generate → Reflect → Curate → Evolve. brain auto-kb runs a fully autonomous loop — searches, scores, finds duplicates, proposes new links, sweeps retrieval parameters, grades itself A–F. Your knowledge base improves while you sleep.

Knowledge graph, not just a vector store

Documents form a typed graph. brain link auto-generates tag-overlap + semantic links. brain graph reports orphans and components. brain dedup collapses near-duplicates with audit trails. Retrieval results are uplifted by graph proximity, not only embeddings.

Hybrid retrieval with authority

BM25 + pgvector + trigram in parallel, fused with Reciprocal Rank Fusion (k=60). Results weighted by source type, frontmatter confidence, and link-graph authority. Fewer strong hits over many noisy ones — by design.

Zero lock-in, zero assumed infra

Your vault is just markdown — open in Obsidian, edit in vim, version in git. Brain ships with an embedded Postgres (pgserve), so you don’t run a database. Ephemeral, local-disk, or synced-to-remote — one CLI, three modes.

Architecture, end to end

Obsidian vault (filesystem)     Postgres (metadata + search)
┌─────────────────────────┐     ┌──────────────────────────┐
│  search/bm25.md         │     │  brain_documents          │
│  graphs/links.md        │───> │  brain_chunks             │
│  _domains/              │     │  brain_links              │
│  _decisions/            │     │  brain_domains            │
│  _reflections/          │     │  brain_strategy_segments  │
│  brain.json             │     │  brain_observations       │
└─────────────────────────┘     └──────────────────────────┘

                                           v
                         ┌────────────────────────────────────┐
                         │  Retrieval: BM25 + vector + trigram │
                         │  RRF fusion · link boost · authority │
                         │  Domain routing · confidence gating  │
                         └────────────────────────────────────┘

                                           v
                         ┌────────────────────────────────────┐
                         │  Closed loop: auto-kb              │
                         │  reflect · dedup · link · sweep    │
                         │  score · decisions · evolve        │
                         └────────────────────────────────────┘
The filesystem is the source of truth for content. Postgres is the source of truth for metadata, search indexes, and embeddings. brain update syncs filesystem to Postgres (hash-skips unchanged files). The closed loop writes its decisions and reflections back to the vault — not hidden in a database row.

Command surface (grouped)

GroupCommandsPurpose
Lifecyclebrain init · brain update · brain ingest · brain autoschema · brain serveCreate vault, sync to Postgres, classify and organize, stand up a server
Querybrain search · brain get · brain analyzeHybrid search, fetch by path/id, LLM analysis via rlmx
Knowledge graphbrain link · brain graph · brain dedup · brain health · brain score · brain decisions · brain forgetGenerate links, audit structure, remove dupes, grade quality A–F
Intelligencebrain domain · brain reflect · brain strategy · brain sweep · brain auto-kbRoute by knowledge area, reflect on quality, sweep params, self-optimize
See Retrieval, Closed-loop intelligence, and Knowledge graph for the deep dives.

Brain types (vault templates)

Brain ships with specialized templates so the AI classifier (brain autoschema) knows where to put things:
TypePurpose
genericGeneral-purpose knowledge base
engineeringCodebase knowledge, architecture decisions
pmProduct specs, roadmaps, stakeholder context
gtmGo-to-market playbooks, competitive intel
researchPapers, findings, hypotheses
opsRunbooks, incident history, infrastructure
personalPersonal notes, learning journal
Pick one at brain init time — it seeds the domain set and the autoschema classifier’s priors.

Deployment modes

Brain is designed to run anywhere an agent runs — no external Postgres required for dev, but ready for production when you need it.
ModeTriggerStorageUse case
EphemeralNeither env var setpgserve RAM-onlyTests, CI, exploration
Data-dirBRAIN_DATA_DIR=/pathpgserve persists to diskSingle-machine personal brain
PersistentDATABASE_URL=postgres://…pgserve RAM + WAL sync to remote PostgresProduction, multi-agent, HA
See Configuration for the full env-var reference.

What’s next

Quickstart

Install, create a brain, run your first search in under 5 minutes.

Closed-loop intelligence

The hero feature — how Brain improves itself without you.