██████╗ ███████╗███╗ ██╗███████╗
██╔══██╗██╔════╝████╗ ██║╚══███╔╝
██████╔╝█████╗ ██╔██╗ ██║ ███╔╝
██╔══██╗██╔══╝ ██║╚██╗██║ ███╔╝
██████╔╝███████╗██║ ╚████║███████╗
╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝
benz is a small, focused, in-memory graph query execution engine written in TypeScript.
It implements a lazy, interpreter-driven execution model inspired by real database engines and graph traversal systems.
This is not a database server. This is the core execution engine databases are built on.
-
Directed graph with index-free adjacency
-
Vertices owning both incoming and outgoing edges
-
Lazy, pull-based query execution (Volcano model)
-
Explicit interpreter with a program counter
-
Gremlin-style traversal using execution tokens
-
Composable pipetypes:
vertexinoutfilteruniquetake
-
Deterministic, resumable queries
-
Query plan inspection via
explain()
No external runtime dependencies.
From the repository root:
npm install
npm run demoYou should see output demonstrating:
- Graph structure validation (vertices and edges)
- Query plans printed via
explain() - Lazy execution producing results on first run
- Empty results on subsequent runs
This confirms that queries are stateful and consumed lazily.
Query the owner of a performance car variant:
vertex("911 GT3 RS")
→ out("variant-of")
→ out("variant-of")
→ out("model-of")
→ out("owned-by")
→ take(1)
This query:
- Starts execution from the last operator
- Pulls data backward through the pipeline
- Stops immediately after producing one result
Calling run() again returns an empty result.
This is intentional.
Every query can be inspected before execution:
query.explain()Example output:
BENZ QUERY PLAN
0 | vertex("911 GT3 RS")
1 | out("variant-of")
2 | out("variant-of")
3 | out("model-of")
4 | out("owned-by")
5 | take(1)
- Lazy, pull-based
- Interpreter-driven
- Gremlin pipeline
No optimizer magic. Nothing hidden.
- Vertices store edges directly
- Edges are pointers, not lookups
- Gremlins move through the graph
- Pipetypes transform gremlins
- Control flows backward, data flows forward
If this engine makes sense to you, SQL execution plans stop feeling opaque.
From the repository root:
npm run buildThis type-checks the entire engine and demo.
benz exists to make execution models concrete.
It is designed for:
- learning
- experimentation
- building higher-level systems on top
benz is complete as a core engine.
Future work belongs on top of it, not inside it:
- persistence layers
- planners and optimizers
- aliases and macros