-
Notifications
You must be signed in to change notification settings - Fork 2
Design Overview
Rick Hightower edited this page Feb 1, 2026
·
1 revision
Comprehensive architectural documentation for Agent Brain, a RAG-based document indexing and semantic search system.
Agent Brain is a production-grade RAG (Retrieval-Augmented Generation) system that combines:
- Hybrid Search: BM25 keyword matching + vector semantic search
- GraphRAG: Knowledge graph-based retrieval with entity relationships
- AST-Aware Code Indexing: Multi-language support with tree-sitter parsing
- Multi-Instance Architecture: Per-project isolation with automatic port allocation
- RRF Fusion: Reciprocal Rank Fusion for combining multiple retrieval results
| Document | Description |
|---|---|
| Architecture Overview | C4 diagrams, component architecture, technology stack |
| Query Architecture | Query routing, search modes (VECTOR, BM25, HYBRID, GRAPH, MULTI) |
| Indexing Pipeline | Document loading, chunking, embedding, graph extraction |
| Storage Architecture | ChromaDB, BM25 index, graph store, state management |
| Class Diagrams | Detailed class relationships and interfaces |
| Deployment Architecture | Local, multi-instance, Docker, Kubernetes deployments |
agent-brain-server/ # FastAPI REST API (core RAG functionality)
agent-brain-cli/ # Click CLI for management
agent-brain-plugin/ # Claude Code plugin (15 commands, 2 agents, 2 skills)
agent-brain-skill/ # Claude Code skill integration
| Mode | Algorithm | Best For |
|---|---|---|
VECTOR |
Cosine similarity | Conceptual queries, "how does X work" |
BM25 |
TF-IDF + BM25 | Exact terms, error messages, symbols |
HYBRID |
Vector + BM25 (alpha blend) | General search (default) |
GRAPH |
Knowledge graph traversal | Entity relationships |
MULTI |
RRF over all modes | Maximum recall |
| System | Purpose | Technology |
|---|---|---|
| Vector Store | Semantic similarity | ChromaDB (HNSW, cosine) |
| BM25 Index | Keyword retrieval | LlamaIndex BM25Retriever |
| Graph Store | Entity relationships | SimplePropertyGraphStore / Kuzu |
| Setting | Default | Description |
|---|---|---|
EMBEDDING_MODEL |
text-embedding-3-large | OpenAI embedding model |
EMBEDDING_DIMENSIONS |
3072 | Vector dimensions |
DEFAULT_CHUNK_SIZE |
512 | Tokens per chunk |
DEFAULT_TOP_K |
5 | Results per query |
ENABLE_GRAPH_INDEX |
false | GraphRAG toggle |
This documentation uses Mermaid diagrams throughout:
- C4 Diagrams: System context and component relationships
- Flowcharts: Process flows and decision trees
- Sequence Diagrams: API interactions and data flow
- Class Diagrams: Object model and interfaces
- Gantt Charts: Pipeline timing
Key architectural decisions:
- Hybrid Search First: Default to combining BM25 and vector search
- Optional GraphRAG: Graph indexing is opt-in to minimize resource usage
- Per-Project Isolation: Each project gets its own server instance and storage
- Singleton Services: Shared service instances within a process
- Async Throughout: All I/O operations are async for performance
When updating this documentation:
- Keep diagrams up-to-date with code changes
- Use consistent styling (high-contrast colors)
- Include step-by-step explanations
- Explain WHY decisions were made, not just WHAT
Last Updated: 2025-01-31 Version: 1.2.0
- Design-Architecture-Overview
- Design-Query-Architecture
- Design-Storage-Architecture
- Design-Class-Diagrams
- GraphRAG-Guide
- Agent-Skill-Hybrid-Search-Guide
- Agent-Skill-Graph-Search-Guide
- Agent-Skill-Vector-Search-Guide
- Agent-Skill-BM25-Search-Guide
Search
Server
Setup
- Pluggable-Providers-Spec
- GraphRAG-Integration-Spec
- Agent-Brain-Plugin-Spec
- Multi-Instance-Architecture-Spec