# hayson-engine
The storage engine behind [hayson](https://gl.theritual.eu/ritual/hayson) — a document database on
plain text files. This is the embeddable core: one table is one append-only JSONL file (or a
directory of them, partitioned by a field's value), alongside a `hayson.json` catalog document
holding every table's schema. In-memory registries (key → file offset, field indexes, a full-text
index) make lookups and queries fast without an on-disk index.
`hayson-engine` has no server, no network, and no isolation levels of its own — it is the same
core linked in-process by [`hayson-server`](https://gl.theritual.eu/ritual/hayson/-/tree/main/crates/hayson-server)
(over gRPC), [`hayson-cli`](https://gl.theritual.eu/ritual/hayson/-/tree/main/crates/hayson-cli)
(local mode) and `hayson-browser`, and mirrors the TypeScript
[`@theritual/hayson`](https://gl.theritual.eu/ritual/hayson/-/tree/main/packages/hayson) package on
the same on-disk format.
Database format: [`docs/format.md`](https://gl.theritual.eu/ritual/hayson/-/blob/main/docs/format.md).
## Installation
```sh
cargo add hayson-engine
```
## Usage
```rust
use hayson_engine::database::Database;
use std::path::Path;
let db = Database::open(Path::new("./my-db"))?;
```
The public API is a hand-curated list of twelve modules — `atomic`, `buffer`, `catalog`,
`compaction`, `crypto`, `database`, `errors`, `lock`, `query`, `schema`, `table`, `txn` — each
re-exporting the names it means to expose; see their module docs. The layers underneath (the log
files, the write queue, the in-memory registries, the index snapshots) are private, and
`tests/public_api.rs` holds the surface to that list.