> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chowder.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How the in-process columnar SQL engine combines local or remote AI compute with Arrow-native results.

Chowder runs as an in-process, columnar AI OLAP engine inside your application. SQL planning and analytical execution stay in that process whether supported AI processing runs locally, in fully managed Chowder Cloud, or on a self-hosted server. Results return through the same Arrow-native interface.

![Chowder architecture: multimodal data flows through the AI-native SQL engine into typed Arrow results, with AI compute running locally, on self-hosted GPU servers, or in Chowder Cloud.](https://mintcdn.com/chowder/Z6iDzrdaRqHAKNw3/diagrams/chowder-architecture.svg?fit=max\&auto=format\&n=Z6iDzrdaRqHAKNw3\&q=85\&s=cfcd425e787a020d4881a3d15e63ebc5)

## Application and compute boundaries

The calling application owns the engine: it plans SQL, executes relational operators, schedules AI work, and manages its durable result cache and ephemeral nearest-neighbor indexes. The Python API controls the engine and consumes its Arrow batches.

Local AI compute uses model runtimes on the same machine, which may run in separate worker processes. Remote AI compute runs supported parsing, inference, embedding, and transcription operations on the selected server. Arrow Flight carries the bounded compute requests, input data, and result batches between them.

A self-hosted server is operated by you; Chowder Cloud provides fully managed AI compute. Both use the remote client in the embedded engine. [Core concepts](https://docs.chowder.ai/concepts/overview.md#start-locally-choose-where-ai-runs) introduces these deployment choices, and [Connect to remote AI compute](https://docs.chowder.ai/guides/remote-compute.md) covers client setup. Server operators can follow [Self-host AI compute](https://docs.chowder.ai/guides/self-host-ai-compute.md) in Advanced.

## Columnar execution foundation

Chowder’s Rust execution core extends Apache DataFusion with multimodal readers, inference-aware operators, and result reuse. Source readers expose typed columns in Arrow record batches. The columnar plan executes SQL projections, filters, joins, and aggregations over those batches, while Chowder’s inference-aware operators integrate model work into the physical plan.

A PDF page, image, or media window defines a logical input record. Its fields occupy positions in column arrays; the source's row grain does not change the columnar execution model. See [Core concepts](https://docs.chowder.ai/concepts/overview.md#row-grain) for source grains.

## Execution layers

| Layer | Responsibility |
| - | - |
| Python API | `Engine`, `Relation`, `StatementResult`, source convenience methods, and typed runtime configuration |
| Columnar SQL engine | Plan and execute relational operators over Arrow column arrays with DataFusion |
| Source readers | Parse or decode multimodal sources and emit typed columns in Arrow record batches |
| Inference-aware operators | Schedule bounded model work, apply eligible cheap filters first, and attach typed AI result columns |
| Model runtimes | Execute inference, embeddings, parsing, and transcription locally or through remote compute |
| Arrow boundary | Stream columnar record batches to Python consumers through the Arrow C stream |

## Query lifecycle

**1. Plan**

`Engine.sql()` parses and plans the query. Type and syntax errors surface before source or model work begins.

**2. Pull columnar batches**

Read-only execution starts when you iterate or materialize the returned `Relation`. Readers supply the requested fields as Arrow column arrays.

**3. Apply pushdown**

Readers receive the projected columns, structural predicates, and static or dynamic limits they can honor.

**4. Run AI operators**

Inference-aware operators schedule `infer` and `embed` with bounded concurrency, deduplicate eligible work, and keep typed results aligned with their inputs.

**5. Return Arrow**

The plan yields typed columns in Arrow record batches until the query completes or the consumer stops early.

Across executions, matching successful AI, parsing, and media results can be reused, while eligible nearest-neighbor indexes can be reused within an engine session. See [Caching](https://docs.chowder.ai/concepts/caching.md) for their separate validity and lifetime rules.

## AI-aware execution

Columnar execution and model-call scheduling solve different parts of the workload. Ordinary SQL predicates evaluate column arrays; inference-aware operators control which inputs reach a model and how many calls are in flight. Models may handle individual inputs or batches depending on the runtime.

Chowder uses `AiFilterExec` and `AiProjectExec` to integrate that scheduling into the columnar plan. For supported query shapes, execution can stop requesting model work when the query has enough matches, rather than evaluating an entire upstream batch first.

For a query such as:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    source,
    page_number
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
WHERE page_number <= 10
AND infer(
    content,
    'Does this page discuss operating income?',
    BOOL
).output
LIMIT 2;
```

the engine can filter the `page_number` column first, schedule inference for a bounded set of candidate pages, and request more candidates only if it still needs two matches. The page is the logical inference input; Arrow batches remain the data exchanged between query operators.

## Remote compute

`Engine(remote=True)` or `Engine(location=...)` selects remote AI compute while keeping the in-process columnar SQL engine and inference-aware control in your application. Supported parsing, inference, embedding, and transcription calls cross Arrow Flight to a self-hosted `chowder.serve()` endpoint or Chowder Cloud. The SQL expressions and Arrow-native result interface stay the same.

```python theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
import os
import chowder

SQL = """
SELECT *
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
LIMIT 5;
"""

engine = chowder.Engine(
    location="grpc+tls://compute.example.com:8816",
    token=os.environ["CHOWDER_API_TOKEN"],
)

relation = engine.sql(SQL)
result = relation.to_polars()

chowder.display(result)
engine.close()
```

The client still reads its source paths and ships bounded data to the server where required. Query content, prompts, and documents can transit the server, so treat it as part of your trust boundary.

See [Connect to remote AI compute](https://docs.chowder.ai/guides/remote-compute.md) for more details.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.