Skip to main content

Architecture

Agent Brain is a transport-neutral orchestration layer between AI coding agents and a local data stack.

Agents -> MCP or REST -> Brain Engine -> service layer -> PostgreSQL + Qdrant + Redis + NATS + Ollama

Packages

| Package | Role | | ----------------------- | ------------------------------------------------------------------ | | packages/mcp-server | MCP adapter and tool handlers | | packages/brain-engine | REST API, WebSocket API, memory services, cache, and Ollama client | | packages/desktop | Tauri app for stack lifecycle and dashboard UX | | packages/shared-types | Shared tool contracts and type definitions |

Data layer

PostgreSQL is the source of truth for memories, projects, agents, and metadata. Qdrant stores vector indexes for semantic search. Redis handles hot cache operations. NATS carries events between services. Ollama handles local model calls.

Memory write flow

agent -> brain_remember
  -> secrets scanner
  -> content hash deduplication
  -> Ollama embedding
  -> PostgreSQL insert
  -> Qdrant vector upsert
  -> event publish
  -> conflict check

Recall flow

agent -> brain_recall
  -> embed query
  -> vector search
  -> hydrate rows from PostgreSQL
  -> rank by similarity, importance, and recency
  -> return context briefing

Semantic cache flow

agent -> brain_cache_check
  -> embed query
  -> search cache vector index
  -> hit if similarity clears threshold
  -> otherwise caller generates fresh response