# pivotlake/pivot architecture

> Architecture diagram of the GitHub repository pivotlake/pivot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pivotlake/pivot
- Repository: https://github.com/pivotlake/pivot

## Overview

Pivot is a Rust analytics database for querying data in open formats, either through a server or locally. The principal workflow is a client query entering the PostgreSQL-wire handler, reaching the execution and planning layers, and running as a parallel dataflow over catalog-resolved tables. The repository also includes persistent PivotLake and read-only Iceberg datastores, Parquet processing, and storage backends. Several runtime links are inferred because the sampled source does not show their call sites; those links are marked dashed.

Main entry points: [`datastore-pivotlake/src/lib.rs`](https://github.com/pivotlake/pivot/blob/main/datastore-pivotlake/src/lib.rs) (PivotLake datastore), [`dispatch/src/worker.rs`](https://github.com/pivotlake/pivot/blob/main/dispatch/src/worker.rs) (Worker threads), [`bin/src/execution/planning.rs`](https://github.com/pivotlake/pivot/blob/main/bin/src/execution/planning.rs) (Planning adapter), [`catalog/src/lib.rs`](https://github.com/pivotlake/pivot/blob/main/catalog/src/lib.rs) (Catalog API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Query interfaces"]
  node_pg_server["Wire server<br/>[query_handler.rs]"]
  node_local_shell["Local shell<br/>[repl.rs]"]
end

subgraph group_query["Query processing"]
  node_execution["Execution API<br/>[mod.rs]"]
  node_planning_adapter["Planning adapter<br/>[planning.rs]"]
  node_planner["SQL planner<br/>[compile.rs]"]
end

subgraph group_runtime["Parallel runtime"]
  node_dispatch_api["Dataflow builder<br/>[builder.rs]"]
  node_dataflow["Dataflow engine<br/>[data_flow.rs]"]
  node_worker["Worker threads<br/>[worker.rs]"]
  node_operators["Query operators<br/>[mod.rs]"]
  node_io["Async I/O<br/>[mod.rs]"]
  node_memory["Memory caches"]
end

subgraph group_data["Data and catalogs"]
  node_catalog_api["Catalog API<br/>[lib.rs]"]
  node_pivot_store[("PivotLake datastore<br/>[lib.rs]")]
  node_iceberg_store[("Iceberg datastore<br/>[lib.rs]")]
  node_parquet_reader["Parquet reader<br/>[scan.rs]"]
  node_parquet_writer["Parquet writer<br/>[mod.rs]"]
end

subgraph group_storage["Storage"]
  node_object_storage["Object storage<br/>[lib.rs]"]
  node_disk_metastore[("Disk metastore<br/>[lib.rs]")]
end

node_client(("SQL client"))

node_client -->|"submits SQL"| node_pg_server
node_pg_server -->|"executes queries"| node_execution
node_local_shell -.->|"runs queries"| node_execution
node_execution -.->|"plans statements"| node_planning_adapter
node_planning_adapter -.->|"compiles SQL"| node_planner
node_planner -.->|"resolves tables"| node_catalog_api
node_planning_adapter -.->|"builds dataflow"| node_dispatch_api
node_dispatch_api -->|"builds graph"| node_dataflow
node_worker -->|"drives execution"| node_dataflow
node_dataflow -->|"runs operators"| node_operators
node_worker -->|"submits I/O"| node_io
node_worker -->|"uses caches"| node_memory
node_catalog_api -->|"implements datastore"| node_pivot_store
node_catalog_api -->|"implements datastore"| node_iceberg_store
node_pivot_store -.->|"reads Parquet"| node_parquet_reader
node_pivot_store -.->|"writes Parquet"| node_parquet_writer
node_pivot_store -->|"stores objects"| node_object_storage
node_iceberg_store -.->|"loads table data"| node_object_storage
node_pivot_store -.->|"persists metadata"| node_disk_metastore

click node_pg_server "https://github.com/pivotlake/pivot/blob/main/bin/src/server/query_handler.rs"
click node_local_shell "https://github.com/pivotlake/pivot/blob/main/bin/src/shell/repl.rs"
click node_execution "https://github.com/pivotlake/pivot/blob/main/bin/src/execution/mod.rs"
click node_planning_adapter "https://github.com/pivotlake/pivot/blob/main/bin/src/execution/planning.rs"
click node_planner "https://github.com/pivotlake/pivot/blob/main/planner/src/compile.rs"
click node_catalog_api "https://github.com/pivotlake/pivot/blob/main/catalog/src/lib.rs"
click node_dispatch_api "https://github.com/pivotlake/pivot/blob/main/dispatch/src/api/builder.rs"
click node_dataflow "https://github.com/pivotlake/pivot/blob/main/dispatch/src/data_flow.rs"
click node_worker "https://github.com/pivotlake/pivot/blob/main/dispatch/src/worker.rs"
click node_operators "https://github.com/pivotlake/pivot/blob/main/dispatch/src/operations/unary/mod.rs"
click node_io "https://github.com/pivotlake/pivot/blob/main/dispatch/src/io/mod.rs"
click node_memory "https://github.com/pivotlake/pivot/blob/main/dispatch/src/memory/compressed_cache.rs"
click node_pivot_store "https://github.com/pivotlake/pivot/blob/main/datastore-pivotlake/src/lib.rs"
click node_iceberg_store "https://github.com/pivotlake/pivot/blob/main/datastore-iceberg/src/lib.rs"
click node_parquet_reader "https://github.com/pivotlake/pivot/blob/main/parquet-engine/src/reading/scan.rs"
click node_parquet_writer "https://github.com/pivotlake/pivot/blob/main/parquet-engine/src/writing/mod.rs"
click node_object_storage "https://github.com/pivotlake/pivot/blob/main/object-storage/src/lib.rs"
click node_disk_metastore "https://github.com/pivotlake/pivot/blob/main/metastore-disk/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pg_server,node_local_shell,node_client toneBlue
class node_execution,node_planning_adapter,node_planner toneAmber
class node_dispatch_api,node_dataflow,node_worker,node_operators,node_io,node_memory toneMint
class node_catalog_api,node_pivot_store,node_iceberg_store,node_parquet_reader,node_parquet_writer toneRose
class node_object_storage,node_disk_metastore toneIndigo
```

## Components

### Query interfaces

- [Wire server](https://github.com/pivotlake/pivot/blob/main/bin/src/server/query_handler.rs): `bin/src/server/query_handler.rs`
- [Local shell](https://github.com/pivotlake/pivot/blob/main/bin/src/shell/repl.rs): `bin/src/shell/repl.rs`

### Query processing

- [Execution API](https://github.com/pivotlake/pivot/blob/main/bin/src/execution/mod.rs): `bin/src/execution/mod.rs`
- [Planning adapter](https://github.com/pivotlake/pivot/blob/main/bin/src/execution/planning.rs): `bin/src/execution/planning.rs`
- [SQL planner](https://github.com/pivotlake/pivot/blob/main/planner/src/compile.rs): `planner/src/compile.rs`

### Parallel runtime

- [Dataflow builder](https://github.com/pivotlake/pivot/blob/main/dispatch/src/api/builder.rs): `dispatch/src/api/builder.rs`
- [Dataflow engine](https://github.com/pivotlake/pivot/blob/main/dispatch/src/data_flow.rs): `dispatch/src/data_flow.rs`
- [Worker threads](https://github.com/pivotlake/pivot/blob/main/dispatch/src/worker.rs): `dispatch/src/worker.rs`
- [Query operators](https://github.com/pivotlake/pivot/blob/main/dispatch/src/operations/unary/mod.rs): `dispatch/src/operations/unary/mod.rs`
- [Async I/O](https://github.com/pivotlake/pivot/blob/main/dispatch/src/io/mod.rs): `dispatch/src/io/mod.rs`
- [Memory caches](https://github.com/pivotlake/pivot/blob/main/dispatch/src/memory/compressed_cache.rs): `dispatch/src/memory/compressed_cache.rs`

### Data and catalogs

- [Catalog API](https://github.com/pivotlake/pivot/blob/main/catalog/src/lib.rs): `catalog/src/lib.rs`
- [PivotLake datastore](https://github.com/pivotlake/pivot/blob/main/datastore-pivotlake/src/lib.rs): `datastore-pivotlake/src/lib.rs`
- [Iceberg datastore](https://github.com/pivotlake/pivot/blob/main/datastore-iceberg/src/lib.rs): `datastore-iceberg/src/lib.rs`
- [Parquet reader](https://github.com/pivotlake/pivot/blob/main/parquet-engine/src/reading/scan.rs): `parquet-engine/src/reading/scan.rs`
- [Parquet writer](https://github.com/pivotlake/pivot/blob/main/parquet-engine/src/writing/mod.rs): `parquet-engine/src/writing/mod.rs`

### Storage

- [Object storage](https://github.com/pivotlake/pivot/blob/main/object-storage/src/lib.rs): `object-storage/src/lib.rs`
- [Disk metastore](https://github.com/pivotlake/pivot/blob/main/metastore-disk/src/lib.rs): `metastore-disk/src/lib.rs`

### Other components

- **SQL client**

## Connections

- SQL client → Wire server: submits SQL (evidence: `README.md`)
- Wire server → Execution API: executes queries (evidence: `bin/src/server/query_handler.rs`)
- Local shell → Execution API: runs queries
- Execution API → Planning adapter: plans statements (evidence: `bin/src/execution/mod.rs`)
- Planning adapter → SQL planner: compiles SQL
- SQL planner → Catalog API: resolves tables
- Planning adapter → Dataflow builder: builds dataflow
- Dataflow builder → Dataflow engine: builds graph (evidence: `dispatch/src/data_flow.rs`)
- Worker threads → Dataflow engine: drives execution (evidence: `dispatch/src/worker.rs`)
- Dataflow engine → Query operators: runs operators (evidence: `dispatch/src/data_flow.rs`)
- Worker threads → Async I/O: submits I/O (evidence: `dispatch/src/worker.rs`)
- Worker threads → Memory caches: uses caches (evidence: `dispatch/src/worker.rs`)
- Catalog API → PivotLake datastore: implements datastore (evidence: `datastore-pivotlake/src/lib.rs`)
- Catalog API → Iceberg datastore: implements datastore (evidence: `datastore-iceberg/src/lib.rs`)
- PivotLake datastore → Parquet reader: reads Parquet
- PivotLake datastore → Parquet writer: writes Parquet
- PivotLake datastore → Object storage: stores objects (evidence: `datastore-pivotlake/src/lib.rs`)
- Iceberg datastore → Object storage: loads table data
- PivotLake datastore → Disk metastore: persists metadata
