How zenbakiak/skillet works
1. What this repo is
- Skillet is a single Rust crate that combines a formula language library with command-line tools and server runtimes.
- The core product boundary is: expression engine library vs. transport/adapters (CLI, HTTP, TCP, daemonization, plugin management).
2. Front-end language pipeline
- Input expressions flow through src/lexer.rs → src/parser.rs → src/ast.rs.
- This layer is responsible for tokenizing, syntax parsing, and building the AST for Excel-like formulas, method chaining, lambdas, arrays, JSON access, and safe navigation.
3. Core evaluation engine
- src/runtime/ contains the execution semantics for the language.
- src/runtime/evaluator.rs and src/runtime/evaluation/* handle AST execution, including assignment handling, higher-order functions, and core node evaluation.
- The runtime is split by domain: arithmetic, arrays, strings, logical ops, JSON, date/time, financial, statistical, type casting, and method dispatch.
4. Built-in function and method dispatch
- Built-ins are centralized in src/runtime/builtin_functions.rs and routed through src/runtime/function_dispatch.rs.
- Method chaining lives under src/runtime/method_calls/, with dedicated handlers for arrays, strings, conversion methods, lambdas, and predicates.
- This means the language supports both classic function-call syntax and Ruby-style chained methods through the same execution core.
5. Values, typing, and conversion boundaries
- src/types.rs defines the runtime Value model used across the library and servers.
- src/runtime/type_casting.rs and related utilities manage coercion between numbers, strings, booleans, arrays, JSON, dates, and currency.
- This typed value layer is the main boundary between parsed syntax and executable semantics.
6. State, extensibility, and concurrency
- src/custom.rs, src/js_plugin.rs, and src/concurrent_registry.rs support runtime extensibility.
- Custom functions can be registered/unregistered dynamically, and JavaScript plugins are treated as first-class runtime extensions.
- src/memory_pool.rs suggests the engine optimizes object allocation to reduce per-evaluation overhead, which matters for the high-performance claims.
7. Library API surface
- src/lib.rs exposes the public Rust API: parse, evaluate, evaluate-with-variables, JSON-backed evaluation, and custom function registration.
- This is the embedding boundary for other Rust applications: they can use the engine directly without starting a server.
8. HTTP server subsystem
- src/bin/http_server/ is a full REST adapter around the evaluator.
- Its submodules separate responsibilities:
- eval.rs for evaluation endpoints
- auth.rs for token protection
- js_management.rs for plugin lifecycle
- multipart.rs for upload handling
- cache.rs, stats.rs, daemon.rs, utils.rs, types.rs
- The HTTP server exposes both expression evaluation and JavaScript function management, making it the main network-facing control plane.
9. TCP server and CLI tools
- src/bin/sk_server.rs is the TCP server entry point; it runs the evaluator behind a JSON-based socket protocol.
- src/bin/sk_client.rs is the client for remote evaluation and benchmarking against the TCP server.
- src/bin/sk.rs is the direct CLI evaluator for local one-shot formula execution.
- src/bin/sk_http_server.rs and src/bin/sk_http_bench.rs wrap the HTTP server and its performance testing use cases.
10. Operational and deployment surface
- The repo includes Dockerfiles, docker-compose.yml, Shuttle config, and CI workflows for release automation.
- openapi.yml and the various docs/guide files indicate the HTTP API is a first-class deployable interface.
- The scripts/ and benches/ directories show a strong emphasis on reproducible benchmarking and server performance validation.
11. Testing and validation
- tests/ covers parser behavior, built-ins, method chaining, JSONPath, null handling, safe navigation, concurrency, and performance-oriented scenarios.
- hook_examples/ and examples/ provide integration samples for plugin behavior and embedding patterns.
- The repository also tracks benchmark outputs in performance_results/, which supports the architecture’s performance-sensitive design goals.
12. End-to-end data flow
- Typical flow: user input arrives via CLI, HTTP, TCP, or Rust API → lexer/parser build AST → runtime resolves variables/functions/methods/plugins → evaluator returns a typed Value → adapters serialize that result as text/JSON over the chosen transport.
- The main architectural seam is therefore between the pure evaluation engine and the I/O/runtime adapters that expose it to external callers.
Main entry points: evaluator.rs Evaluator · mod.rs HTTP server · function_dispatch.rs Dispatch · lib.rs Library API
Components 26
Core engine
Parsing, AST, values, and execution semantics for the formula language.
- Library API · Embedding surface for parsing, evaluation, variable binding, JSON-backed evaluation, and custom function registration.
src/lib.rs - Lexer · Converts formula text into tokens.
src/lexer.rs - Parser · Builds syntax structure from tokens for formulas, chaining, lambdas, arrays, and JSON access.
src/parser.rs - AST · Defines the expression tree consumed by the runtime.
src/ast.rs - Values · Typed value boundary shared by engine and adapters.
src/types.rs - Evaluator · Orchestrates AST execution and dispatch into runtime semantics.
src/runtime/evaluator.rs - Core eval · Primary AST node evaluation and execution flow.
src/runtime/evaluation/core.rs - Assignments · Handles variable assignment and update semantics during evaluation.
src/runtime/evaluation/assignments.rs - Higher-order · Evaluates lambdas and other higher-order language behaviors.
src/runtime/evaluation/higher_order.rs - Dispatch · Routes function calls to built-ins and method handlers.
src/runtime/function_dispatch.rs - Built-ins · Central catalog of built-in formula functions.
src/runtime/builtin_functions.rs - Method calls · Ruby-style chained methods for arrays, strings, conversions, lambdas, and predicates.
src/runtime/method_calls/mod.rs - Type casting · Coerces between numbers, strings, booleans, arrays, JSON, dates, and currency.
src/runtime/type_casting.rs
Adapters
CLI, HTTP, TCP, and server-facing entry points that expose the engine.
- HTTP server · REST adapter exposing evaluation and plugin management over HTTP.
src/bin/http_server/mod.rs - HTTP eval · Evaluation endpoints for HTTP requests.
src/bin/http_server/eval.rs - JS admin · Plugin lifecycle management endpoints.
src/bin/http_server/js_management.rs - HTTP ops · Auth, cache, multipart upload, daemon, stats, types, and utility support for the server.
src/bin/http_server/utils.rs - TCP server · JSON-over-socket server entry point for remote evaluation.
src/bin/sk_server.rs - CLI · Direct one-shot local formula evaluator.
src/bin/sk.rs - TCP client · Remote evaluation and benchmarking client for the TCP server.
src/bin/sk_client.rs
Extensibility
Custom functions, plugins, and shared runtime state.
- Custom funcs · Registers and unregisters user-defined functions at runtime.
src/custom.rs - JS plugins · Loads JavaScript-backed extensions into the runtime.
src/js_plugin.rs - Registry · Shared concurrent storage for runtime extensions and callable state.
src/concurrent_registry.rs - Memory pool · Optimizes object allocation and reuse during evaluation.
src/memory_pool.rs
Ops
Packaging, benchmarks, and deployment tooling around the core crate.
- HTTP bench · Performance wrapper for the HTTP server.
src/bin/sk_http_bench.rs - Scripts · Benchmarking, daemon, and build automation scripts.
scripts
Connections 30
- Library API → Lexer: parse · Public API starts by tokenizing input.
- Library API → Parser: parse · Public API exposes parsing.
- Library API → Evaluator: evaluate · Public API evaluates parsed expressions.
- Lexer → Parser: tokens · Parser consumes lexer output.
- Parser → AST: builds · Parser produces AST nodes.
- AST → Evaluator: executes · AST is executed by the runtime evaluator.
- Evaluator → Core eval: delegates · Evaluator delegates to core node execution.
- Evaluator → Assignments: delegates · Evaluator handles assignment semantics.
- Evaluator → Higher-order: delegates · Evaluator handles lambdas and higher-order behavior.
- Core eval → Dispatch: routes · Core execution routes functions and methods.
- Dispatch → Built-ins: resolves · Dispatch resolves built-in functions.
- Dispatch → Method calls: resolves · Dispatch resolves chained method calls.
- Dispatch → Type casting: coerces · Dispatch uses coercion boundaries during execution.
- Built-ins → Values: returns · Built-ins operate on and return typed values.
- Method calls → Values: returns · Method handlers consume and emit typed values.
- Type casting → Values: normalizes · Type casting normalizes runtime values.
- Custom funcs → Registry: stores · Custom functions are tracked in shared registry state.
- JS plugins → Registry: registers · JavaScript plugins are registered in shared state.
- Memory pool → Evaluator: optimizes · Memory pool supports execution performance.
- HTTP server → HTTP eval: serves · HTTP server exposes evaluation endpoints.
- HTTP server → JS admin: serves · HTTP server exposes plugin management endpoints.
- HTTP server → HTTP ops: supports · Server support modules provide auth, caching, uploads, daemonization, and stats.
- HTTP server → Evaluator: uses · HTTP adapter invokes the evaluator.
- JS admin → JS plugins: loads · HTTP management controls JavaScript plugin lifecycle.
- TCP server → Evaluator: uses · TCP server invokes the evaluator.
- CLI → Evaluator: uses · CLI evaluates formulas through the core engine.
- TCP client → TCP server: calls · Client talks to the TCP server.
- HTTP bench → HTTP server: measures · Benchmark tool exercises the HTTP server.
- Scripts → TCP server: operates · Operational scripts manage server processes and benchmarks.
- Scripts → HTTP server: operates · Operational scripts support HTTP deployment and testing.