Architecture
Crader is split into a write path (indexing and embedding) and a read path (search and navigation). The system stores all data in PostgreSQL with snapshot isolation, so readers always query a stable version of the codebase.
Write path
- Repository sync:
GitVolumeManagermaintains a bare mirror cache and creates ephemeral worktrees for specific commits. Repositories are stored underCRADER_REPO_VOLUME(default:./sheep_data/repositories). - Parsing and chunking:
TreeSitterRepoParserloads Tree-sitter grammars by extension and splits code into chunks. Chunks include byte ranges, line ranges, and metadata tags. Parent-child edges (child_of) are created during parsing. - Storage:
PostgresGraphStoragepersists repositories, snapshots, files, nodes, contents, edges, and the FTS index. - Embeddings (separate step):
CodeEmbedderstages node content, deduplicates by hash, then calls an embedding provider. Vectors are stored innode_embeddingsfor vector search.
Read path
- Search:
CodeRetrieverruns vector search and keyword search throughSearchExecutor. Results are merged using Reciprocal Rank Fusion. - Context expansion:
GraphWalkeradds parent context and outgoing definitions based on graph edges. - Navigation and reading:
CodeReaderreconstructs files from chunk content and uses the snapshot manifest for fast directory listing.CodeNavigatorexposes helpers for neighbors, parent blocks, callers, and callees.
Snapshot model
Each indexing run creates a snapshot tied to a commit hash. A repository points to a single active snapshot. Queries always target a specific snapshot, either explicitly or by resolving the active one.