# pratyaydeep/kibbr architecture

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

- Interactive diagram: https://gitdiagram.com/pratyaydeep/kibbr
- Repository: https://github.com/pratyaydeep/kibbr

## Overview

kibbr is a structured-JSON log store: clients submit NDJSON, the engine separates each line’s shape from its values, persists values in typed column files, and answers TrieQL queries. The primary workflow is HTTP ingest and query, with CLI commands providing alternate access and operations such as bulk load and compaction. The README and engine overview document the major stages and capabilities; source excerpts are limited, so finer internal call relationships are not asserted.

Main entry points: [`src/engine/ingest.rs`](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/ingest.rs) (Live ingest), [`src/engine/database.rs`](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/database.rs) (Database handle), [`src/engine/rows/disk.rs`](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/rows/disk.rs) (Row stores), [`src/server/handlers.rs`](https://github.com/pratyaydeep/kibbr/blob/main/src/server/handlers.rs) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and operations"]
  node_console["Web console<br/>[screens.mjs]"]
  node_http["HTTP API<br/>[handlers.rs]"]
  node_routes["HTTP routing<br/>[routes.rs]"]
  node_server["Server runtime<br/>[run.rs]"]
  node_cli["CLI commands<br/>[cli.rs]"]
  node_cliquery["CLI query<br/>[query.rs]"]
  node_bulkload["Bulk load<br/>[load.rs]"]
  node_compact["Compaction<br/>[compact.rs]"]
end

subgraph group_ingest["Ingest and modeling"]
  node_parse["Line parsing<br/>[flatten.rs]"]
  node_model["Typed values<br/>[infer.rs]"]
  node_ingestengine["Live ingest<br/>[ingest.rs]"]
  node_templates["Shape trie<br/>[trie.rs]"]
end

subgraph group_storage["Durable storage"]
  node_database["Database handle<br/>[database.rs]"]
  node_wal[("Write-ahead log<br/>[wal.rs]")]
  node_rows[("Row stores<br/>[disk.rs]")]
  node_format["Column file format<br/>[build.rs]"]
  node_lifecycle["Recovery lifecycle<br/>[lifecycle.rs]"]
end

subgraph group_query["Query and results"]
  node_trieql["TrieQL language<br/>[trieql.rs]"]
  node_planner["Query planning<br/>[plan.rs]"]
  node_execute["Query execution<br/>[execute.rs]"]
  node_answer["Query answers<br/>[answer.rs]"]
end

node_client(("Log clients"))

node_client -->|"sends requests"| node_routes
node_console -->|"uses HTTP API"| node_routes
node_routes -->|"routes requests"| node_http
node_server -->|"serves over"| node_database
node_cli -->|"offers queries"| node_cliquery
node_cliquery -->|"executes queries"| node_database
node_http -->|"uses database"| node_database
node_http -->|"accepts ingest"| node_ingestengine
node_bulkload -->|"loads logs"| node_database
node_compact -->|"compacts days"| node_rows
node_database -->|"opens and restores"| node_lifecycle
node_ingestengine -->|"parses lines"| node_parse
node_parse -->|"infers types"| node_model
node_ingestengine -->|"records shapes"| node_templates
node_ingestengine -->|"writes durable log"| node_wal
node_ingestengine -->|"stores values"| node_rows
node_rows -->|"encodes columns"| node_format
node_cliquery -->|"builds queries"| node_trieql
node_trieql -->|"produces plans"| node_planner
node_planner -->|"filters shapes"| node_templates
node_planner -->|"guides scans"| node_execute
node_execute -->|"scans columns"| node_rows
node_execute -->|"forms results"| node_answer
node_lifecycle -->|"replays log"| node_wal

click node_console "https://github.com/pratyaydeep/kibbr/blob/main/web/scripts/screens.mjs"
click node_http "https://github.com/pratyaydeep/kibbr/blob/main/src/server/handlers.rs"
click node_routes "https://github.com/pratyaydeep/kibbr/blob/main/src/server/routes.rs"
click node_server "https://github.com/pratyaydeep/kibbr/blob/main/src/server/run.rs"
click node_cli "https://github.com/pratyaydeep/kibbr/blob/main/src/cli.rs"
click node_cliquery "https://github.com/pratyaydeep/kibbr/blob/main/src/cli/query.rs"
click node_bulkload "https://github.com/pratyaydeep/kibbr/blob/main/src/cli/load.rs"
click node_compact "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/compact.rs"
click node_parse "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/parse/flatten.rs"
click node_model "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/model/infer.rs"
click node_ingestengine "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/ingest.rs"
click node_templates "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/templates/trie.rs"
click node_database "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/database.rs"
click node_wal "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/wal.rs"
click node_rows "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/rows/disk.rs"
click node_format "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/format/build.rs"
click node_lifecycle "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/lifecycle.rs"
click node_trieql "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/trieql.rs"
click node_planner "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/plan.rs"
click node_execute "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/execute.rs"
click node_answer "https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/answer.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_console,node_http,node_routes,node_server,node_cli,node_cliquery,node_bulkload,node_compact,node_client toneBlue
class node_parse,node_model,node_ingestengine,node_templates toneAmber
class node_database,node_wal,node_rows,node_format,node_lifecycle toneMint
class node_trieql,node_planner,node_execute,node_answer toneRose
```

## Components

### Access and operations

- [Web console](https://github.com/pratyaydeep/kibbr/blob/main/web/scripts/screens.mjs): `web/scripts/screens.mjs`
- [HTTP API](https://github.com/pratyaydeep/kibbr/blob/main/src/server/handlers.rs): `src/server/handlers.rs`
- [HTTP routing](https://github.com/pratyaydeep/kibbr/blob/main/src/server/routes.rs): `src/server/routes.rs`
- [Server runtime](https://github.com/pratyaydeep/kibbr/blob/main/src/server/run.rs): `src/server/run.rs`
- [CLI commands](https://github.com/pratyaydeep/kibbr/blob/main/src/cli.rs): `src/cli.rs`
- [CLI query](https://github.com/pratyaydeep/kibbr/blob/main/src/cli/query.rs): `src/cli/query.rs`
- [Bulk load](https://github.com/pratyaydeep/kibbr/blob/main/src/cli/load.rs): `src/cli/load.rs`
- [Compaction](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/compact.rs): `src/engine/compact.rs`

### Ingest and modeling

- [Line parsing](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/parse/flatten.rs): `src/engine/parse/flatten.rs`
- [Typed values](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/model/infer.rs): `src/engine/model/infer.rs`
- [Live ingest](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/ingest.rs): `src/engine/ingest.rs`
- [Shape trie](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/templates/trie.rs): `src/engine/templates/trie.rs`

### Durable storage

- [Database handle](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/database.rs): `src/engine/database.rs`
- [Write-ahead log](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/wal.rs): `src/engine/wal.rs`
- [Row stores](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/rows/disk.rs): `src/engine/rows/disk.rs`
- [Column file format](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/format/build.rs): `src/engine/format/build.rs`
- [Recovery lifecycle](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/lifecycle.rs): `src/engine/lifecycle.rs`

### Query and results

- [TrieQL language](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/trieql.rs): `src/engine/query/trieql.rs`
- [Query planning](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/plan.rs): `src/engine/query/plan.rs`
- [Query execution](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/execute.rs): `src/engine/query/execute.rs`
- [Query answers](https://github.com/pratyaydeep/kibbr/blob/main/src/engine/query/answer.rs): `src/engine/query/answer.rs`

### Other components

- **Log clients**

## Connections

- Log clients → HTTP routing: sends requests (evidence: `README.md`)
- Web console → HTTP routing: uses HTTP API (evidence: `README.md`)
- HTTP routing → HTTP API: routes requests (evidence: `src/server.rs`)
- Server runtime → Database handle: serves over
- CLI commands → CLI query: offers queries (evidence: `README.md`)
- CLI query → Database handle: executes queries (evidence: `src/cli/query.rs`)
- HTTP API → Database handle: uses database
- HTTP API → Live ingest: accepts ingest (evidence: `README.md`)
- Bulk load → Database handle: loads logs
- Compaction → Row stores: compacts days
- Database handle → Recovery lifecycle: opens and restores (evidence: `src/engine/lib.rs`)
- Live ingest → Line parsing: parses lines
- Line parsing → Typed values: infers types
- Live ingest → Shape trie: records shapes
- Live ingest → Write-ahead log: writes durable log (evidence: `src/engine/lib.rs`)
- Live ingest → Row stores: stores values
- Row stores → Column file format: encodes columns
- CLI query → TrieQL language: builds queries (evidence: `README.md`)
- TrieQL language → Query planning: produces plans
- Query planning → Shape trie: filters shapes (evidence: `README.md`)
- Query planning → Query execution: guides scans
- Query execution → Row stores: scans columns
- Query execution → Query answers: forms results
- Recovery lifecycle → Write-ahead log: replays log (evidence: `src/engine/lib.rs`)
