Skip to main content

Architecture

This page describes the concept behind ContextCrate and how its parts fit together. It is the starting point of the architecture section: Crates explains the isolation boundary, Pipeline the processing stages and Authorization who may do what. For installing it see Installation; for working with it see Using ContextCrate.

Design principles​

  • Everything belongs to a crate. A crate is the unit of isolation, authorization and indexing. Nothing is shared between crates except the installation's backing services.
  • Derived data is rebuildable. Raw artifacts and normalized documents are the source of truth. Chunks, embeddings and search indexes can be recreated at any time, which is what makes model changes and upgrades safe.
  • Delivery is at least once. Work is idempotent, and every stage verifies the crate it operates on.
  • Backends are interchangeable. The same domain code runs on H2 or PostgreSQL, a database queue or RabbitMQ, the filesystem or S3, and Lucene, OpenSearch, Elasticsearch, Qdrant or pgvector.
  • Retrieved content is untrusted. Crawled text, code and image descriptions are given to the answer model as data, never as instructions.

Components​

ComponentResponsibilityStandaloneDistributed
Control planeUI, REST API, MCP and OpenAI endpoints, authorization, configurationin the single processcontrol-plane role
Source workersFetch websites and Git repositoriesin the single processsource-web, source-git roles
Browser crawlerRenders JavaScript-heavy pagesin the single processcrawler-browser role
Parser and extractorParse, chunk, extract metadata and rulesin the single processparser, extractor roles
IndexerEmbeds chunks and writes the search indexin the single processindexer role
Relational databaseConfiguration, normalized documents, chunks, membersH2PostgreSQL
Work queueCoordinates the stagesdatabaseRabbitMQ
Artifact storeRaw fetched bodiesfilesystemS3-compatible storage
Search indexKeyword and vector searchLuceneOpenSearch, Elasticsearch, Qdrant or pgvector (see Search backends)
Model providersEmbeddings, reranking, answers, optional visionlocal ONNX or any OpenAI-compatible endpointsame

The roles and the backends are selected by configuration, see Configuration and Deployment.

From source to answer​

Ingestion. A run moves content through these stages, each handled by a worker:

  1. Fetch (WEB_FETCH, GIT_FETCH, BROWSER_FETCH): download pages or check out the repository under the safety policy, store raw bodies in the artifact store.
  2. Parse: turn HTML, Markdown, source code and text into a clean document and structural blocks. See Parsing.
  3. Chunk: pack blocks into passages. See Chunking.
  4. Extract: apply the crate's extraction rules.
  5. Index: compute embeddings and write the document and chunk records to the search index. See Embeddings.
  6. Describe images (optional, IMAGE_DESCRIBE): have a vision model describe meaningful images. See Images.
  7. Caption (optional, part of indexing): the answer model describes tables and diagram code before they are embedded; image descriptions are the captions of pictures. See Captions.

Querying. A question is optionally transformed (Query transformation), optionally turned into a hypothetical answer whose embedding drives the vector search (HyDE), retrieved with keyword, semantic or hybrid search (Retrieval), optionally in two steps, sections first and then only their chunks (Hierarchical retrieval), optionally narrowed to K relevant and mutually different chunks (Dartboard retrieval), optionally re-weighted by the ratings of earlier answers (Answer feedback), optionally reranked (Reranking) and graded (Grading); each kept chunk can be expanded with its neighbours (Context window); the answer model then writes a cited answer (Answers) that can be verified (Answer verification). Optionally, after the answer has been delivered, a separate judge model scores it in the background (RAG evaluation, pipeline stage EVALUATE).

Crate-aware processing​

Ownership propagation​

crate_id is stored on every crate-owned row rather than inferred only through joins. Pipeline schema v2 duplicates it in the envelope and JSON payload. This deliberate redundancy lets repositories scope queries efficiently and lets workers detect inconsistent or malicious references before doing work.

Delivery is at least once. Idempotency keys include crate identity, and entity relationships are verified at each stage.

Source model​

A source owns a stable endpoint and credentials. Any number of ingestion jobs may reference it, each with its own scope, ref, filters, limits, and normalization policy. An ingestion run snapshots both configurations. Connector-specific acquisition ends at AcquisitionRecord; normalization, extraction, and indexing are source-neutral.

Storage adapters​

The relational database owns canonical configuration and normalized content. Raw bodies use ArtifactStore with filesystem or S3 implementations. Search uses SearchIndex with Lucene, OpenSearch, Elasticsearch, Qdrant or pgvector implementations. Index data and embeddings are derived and rebuildable.

Backends are installation-wide services, while prefixes/directories and configuration are crate-specific.

Retrieval strategies​

Chunk indexing is crate-configurable. Standard retrieval sends chunks directly to the search backend. Proposition retrieval first uses the answer model to generate and grade facts, persists the evaluation, and indexes accepted propositions while retaining source-chunk identity. See Retrieval.

Provider resolution​

Embedding and answer settings are keyed by crate. An execution context selects the correct provider configuration for crawl-index work, search queries, and asynchronous answer streaming. Local model assets may share an installation cache, but vector namespaces and credentials do not.

Generation switch​

If the build fails, its error is recorded and its namespace is removed; the previous active generation is unchanged.

Where to go next​