Monorch
Architecture
Four trees. Rust owns truth.
TypeScript owns I/O. One user package. No parallel APIs. The engine advances runs; your handlers stream AiEvent.
Stack
From marketing down to the engine.
01apps/www
Marketing + docs only
Never imports engine internals. Not a Studio.
02examples/fastify
BYO HTTP smoke
Full handler sample (Fastify host). Same APIs for Hono or Nest.
03examples/npm-smoke
Published npm smoke
Installs @monorch/ai from the registry — validates tarball + native load without workspace link.
04packages/ai
@monorch/ai
Sole TypeScript user API: agents, tools, graphs, memory, MCP, OTel.
05bindings/node
@monorch/runtime
N-API only. No business logic in the binding crate.
06engine/
Rust source of truth
Schema, tool auth, agent run state, graph cursor.
Rules
Hard boundaries.
- 01Validate, auth, agent, and graph state live in Rust only.
- 02Provider HTTP, node execute, edge predicates, and checkpointer I/O live in TypeScript.
- 03Prefer graph() over workflow() for new code — see /docs/api for the public contract.
- 04Examples never become frameworks.
Request path
Handler → engine → events.
Your route calls agent.stream or graph.start. TypeScript talks to the model and runs node callbacks. Rust advances the run, prepares tool args, and stores status. Events leave as AiEvent for SSE, logs, and OTel.