// docs
edit on GitHub ↗Architecture
Omni is a Rust workspace of focused crates plus a CLI.
| Crate | Role |
|---|---|
base | Shared types: the HTTP Method set, the Omni ABI types (OmniContext, OmniRequest, OmniResponse, OmniHeader, OmniBody), and ABI helpers. |
compiler | omnicom, the compiler. Discovers routes, builds the routing tree, and generates code. |
router | The runtime server that executes a compiled router. |
cli | The omni command-line entry point. |
The compile pipeline
- Discover.
walk_routeswalks the routes directory. Each handler file is parsed with tree-sitter, and functions are discovered and validated (a handler takes anOmniContextas its first parameter). Each becomes aNode, either anEndpoint(method)orMiddleware, carryingRouteFlagsdescribing what it uses (DB, context, header, body, dynamic, hot path). - Build the routing tree. The routes are loaded into a
ConditionTree, and optimization passes partition them into a decision tree keyed on cheap conditions (segment count, path length, prefix). See The router tree. - Lower to a generation tree.
GenTree::from_cond_treeturns the condition tree into aGenTreeofGenRoutes, each a per-method stack of middleware and handler references. - Generate. A
StackGeneratordrives language adapters (Go, Rust) that emit the router and wiring into the build directory.
The compiler context (OmnicomCtx) fixes the output layout: ./build for
output, ./build/bin for binaries, ./build/lib for generated libraries.