Open-source Business Rules Engine
ZEN Engine is business friendly Open-Source Business Rules Engine (BRE) to execute decision models according to the GoRules JSON Decision Model (JDM) standard.
It is written in Rust and provides native bindings for NodeJS, Go and Python. ZEN Engine allows to load and execute JSON Decision Model (JDM) from JSON files.
Visit our GitHub ZEN Engine.
Usage
ZEN Engine is built as embeddable BRE for your Rust, NodeJS, Go or Python applications.
Installation
Rust
[dependencies]
zen-engine = "0"
Node.js
NPM
npm i @gorules/zen-engine
Yarn
yarn add @gorules/zen-engine
PNPM
pnpm i @gorules/zen-engine
Python
pip install zen-engine
Go
go get https://github.com/gorules/zen-go
Evaluating Decision - Simple Usage
ZENEngine parses JDM from JSON content. It is up to you to obtain the JSON content, e.g. from file system, database or service call.
Rust
use serde_json::json;
use zen_engine::DecisionEngine;
use zen_engine::model::DecisionContent;
async fn evaluate() {
let decision_content: DecisionContent = serde_json::from_str(include_str!("jdm_graph.json")).unwrap();
let engine = DecisionEngine::default();
let decision = engine.create_decision(decision_content.into());
let result = decision.evaluate(&json!({ "input": 12 })).await;
}
Node.js
import { ZenEngine } from '@gorules/zen-engine';
import fs from 'fs/promises';
(async () => {
// Example filesystem content, it is up to you how you obtain content
const content = await fs.readFile('./jdm_graph.json');
const engine = new ZenEngine();
const decision = engine.createDecision(content);
const result = await decision.evaluate({ input: 15 });
})();
Python
import zen
# Example filesystem content, it is up to you how you obtain content
with open("./jdm_graph.json", "r") as f:
content = f.read()
engine = zen.ZenEngine()
decision = engine.create_decision(content)
result = decision.evaluate({"input": 15})
Go
package main
import (
"github.com/gorules/zen-go"
"os"
)
func main() {
engine := zen.NewEngine(zen.EngineConfig{})
graph, err := os.ReadFile("./jdm-graph.json")
if err != nil {
return
}
decision, err := engine.CreateDecision(graph)
if err != nil {
return
}
response, err := decision.Evaluate(map[string]any{"input": 15})
}`
If you are looking for a Business Rules Management System (BRMS) over REST, take a look at GoRules BRMS.
Support matrix
Arch | Rust | NodeJS | Go | Python |
---|---|---|---|---|
linux-x64-gnu | ✔️ | ✔️ | ✔️ | ✔️ |
linux-arm64-gnu | ✔️ | ✔️ | ✔️ | ✔️ |
darwin-x64 | ✔️ | ✔️ | ✔️ | ✔️ |
darwin-arm64 | ✔️ | ✔️ | ✔️ | ✔️ |
win32-x64-msvc | ✔️ | ✔️ | ✔️ | ✔️ |