How brainwires/project-rag works
Project RAG is a local-first codebase indexing and retrieval system, exposed as both a Rust client library and an MCP server. The principal workflow is an assistant request routed through the MCP server to RagClient, which indexes project files into chunks, embeds and stores them, then serves hybrid search results. Separate capabilities cover git-history search and code navigation (definitions, references, and call graphs). The graph follows documented capabilities and sampled ownership; wiring inside unsampled client and server methods is shown only where the README describes it.
Main entry points: client/mod.rs RagClient · file_walker/mod.rs File Walker · mcp_server.rs MCP Server · vector_db/mod.rs Vector Database API
Components 23
Assistant Interface
- MCP Server
src/mcp_server.rs - RagClient
src/client/mod.rs - Request Types
src/types/mod.rs - Configuration
src/config/mod.rs
Code Indexing
- File Walker
src/indexer/file_walker/mod.rs - Language Detection
src/indexer/language.rs - AST Chunking
src/indexer/ast_parser.rs - Chunking
src/indexer/chunker.rs - PDF Extraction
src/indexer/pdf_extractor.rs
Search and Storage
- Local Embeddings
src/embedding/fastembed_manager.rs - Vector Database API
src/vector_db/mod.rs - LanceDB Backend
src/vector_db/lance_client/mod.rs - Qdrant Backend
src/vector_db/qdrant_client.rs - BM25 Search
src/bm25_search/mod.rs - File Hash Cache
src/cache.rs
History and Navigation
- Git Walker
src/git/walker.rs - Commit Chunking
src/git/chunker.rs - Git Cache
src/git_cache.rs - Relations Provider
src/relations/mod.rs - RepoMap Analysis
src/relations/repomap/mod.rs - Relations Store
src/relations/storage/lance_store.rs
Other components
- AI Assistant
- Qdrant Service
Connections 22
- AI Assistant → MCP Server: sends MCP requests
- MCP Server → RagClient: dispatches tools
- MCP Server → Request Types: uses schemas
- RagClient → Configuration: loads settings
- RagClient → File Walker: indexes files
- File Walker → Language Detection: detects language
- File Walker → AST Chunking: parses code
- File Walker → Chunking: chunks content
- File Walker → PDF Extraction: extracts PDFs
- RagClient → Local Embeddings: embeds chunks
- RagClient → Vector Database API: stores and searches
- Vector Database API → LanceDB Backend: uses default backend
- Vector Database API → Qdrant Backend: uses optional backend
- Qdrant Backend → Qdrant Service: reads and writes
- RagClient → BM25 Search: performs keyword search
- RagClient → File Hash Cache: tracks file changes
- RagClient → Git Walker: indexes commit history
- Git Walker → Commit Chunking: chunks commits
- RagClient → Git Cache: tracks indexed commits
- RagClient → Relations Provider: finds code relationships
- Relations Provider → RepoMap Analysis: uses fallback analysis
- RagClient → Relations Store: persists relations