# nakui

> Excel-style reactive engine, on solid principles — exact `Decimal`, topological cascade, WAL, time-travel — in Rust, with a [Llimphi](https://github.com/tawasuyu/llimphi) UI.

`nakui` is a spreadsheet with a head: exact `Decimal` (not `f64`), topological-order cascade, WAL before applying, atomic invariants, and time-travel via immutable history. Three views over the same token graph — **matrix** (classic Excel), **graph** (dependency DAG) and **form** (single record) — guided by the schema's `view_hint`. Long-term it is a **DAG token engine**, foundation for verticals (Fintech, IAM, Logistics, MedTech).

<p align="center">
  <img src="docs/nakui_showreel.gif" alt="nakui showreel — a live spreadsheet with computed formulas, an ERP dashboard of stat cards and charts, and a dependency graph view" width="900">
  <br>
  <sub>one shell, three views — live spreadsheet (yupay formulas) · ERP dashboard · dependency graph</sub>
</p>

## Run

```sh
cargo run --release -p nakui-ui-llimphi        # the ERP/sheet/graph shell
cargo run --release -p nakui-sheet-llimphi     # the matrix (spreadsheet) view
cargo run --release -p nakui-explorer-llimphi  # the token-graph / event-log explorer
```

## Install

```sh
cargo build --release
# binaries land in target/release/
```

- **Linux / macOS / Windows** — Llimphi UI.
- **Wawa** — `nakui-core` and `nakui-sheet-nakuicore` compile to WASM.
- Local persistence with WAL in `$XDG_DATA_HOME/nakui/`.

## Crates

| Crate | Role |
|---|---|
| `nakui-core` | Engine: tokens, schema, DAG, cascade, WAL; Rhai executor + optional SurrealDB. |
| `nakui-backend` | GUI-agnostic backend: MemoryStore + EventLog + executors, WAL/snapshot recovery. |
| `nakui-sheet` | Matrix view: ranges, cells, formulas, pivot engine. |
| `nakui-sheet-nakuicore` | `nakui-sheet` ↔ `nakui-core` event-log bridge. |
| `nakui-sheet-llimphi` | Matrix (spreadsheet) UI on Llimphi. |
| `nakui-ui-llimphi` | UI shell — view selector, sidebar, the four meta-views. |
| `nakui-explorer-llimphi` | Token-graph / event-log explorer. |
| `yupay-core` | Excel-style formula engine: lex / parse / eval, bilingual (es/qu/en). |
| `yupay-fns` | Function catalog (SUMA, BUSCARV, SI…) over `yupay-core`. |

Production modules live in `01_yachay/nakui/modules/` — `crm`, `inventory`, `sales`, `treasury`: Nickel schema (`schema.ncl`) + Rhai morphisms, executed by the `nakui-core` executor kernel.

## How dependencies work

nakui is a full app: its UI integrates the meta-runtime, panels and content-addressed sources. Llimphi and every foundational dependency are pulled as **git dependencies** from the [`tawasuyu`](https://github.com/tawasuyu/tawasuyu) monorepo — the suite's source of truth. The engine crates (`nakui-core`, `nakui-sheet`, `yupay-core`, `yupay-fns`) are pure compute; only the `*-llimphi` crates pull the GPU UI stack.

## Considerations

- **No `f64`.** Exact `Decimal` throughout the engine; numeric format lives in the view, not the data.
- **WAL before mutate.** Every operation goes through the log; in-memory data only changes once the WAL is synced.
- **Not Excel.** No formula compatibility with XLSX; forms and the graph are first-class, not addons.

## License

MIT. Builds on [Llimphi](https://github.com/tawasuyu/llimphi) and the [tawasuyu](https://github.com/tawasuyu/tawasuyu) suite.
