Storage API
Crader uses PostgreSQL as the primary backend. The indexer writes directly through PostgresGraphStorage.
PostgresGraphStorage
from crader.storage.connector import PooledConnector
from crader.storage.postgres import PostgresGraphStorage
connector = PooledConnector(dsn=db_url)
storage = PostgresGraphStorage(connector)
Repository and snapshot lifecycle
ensure_repository(url, branch, name) -> repo_idcreate_snapshot(repository_id, commit_hash, force_new=False) -> (snapshot_id, is_new)- returns
(None, False)if another snapshot is currentlyindexing activate_snapshot(repository_id, snapshot_id, stats=None, manifest=None)get_active_snapshot_id(repository_id) -> snapshot_idfail_snapshot(snapshot_id, error)
Write operations
add_files,add_nodes,add_contentsadd_search_indexbuilds the FTS tableadd_edgeandadd_relations_rawadd relations- Raw bulk variants exist for high-throughput inserts (
add_nodes_raw, etc.)
Search
search_vectors(query_vector, limit, snapshot_id, filters=None)search_fts(query, limit, snapshot_id, filters=None)
Filter keys:
path_prefixlanguage/exclude_languagecategory/exclude_categoryrole/exclude_role
Navigation helpers
get_context_neighbors(node_id)get_neighbor_chunk(node_id, direction)get_neighbor_metadata(node_id)get_incoming_references(node_id)get_outgoing_calls(node_id)
Embedding pipeline helpers
prepare_embedding_staging()load_staging_data()backfill_staging_vectors(snapshot_id)fetch_staging_delta(snapshot_id)flush_staged_hits(snapshot_id)save_embeddings_direct(records)
SQLite backend
SqliteGraphStorage exists for local experiments and tests. The main indexer uses PostgreSQL and does not switch backends automatically.