ZEN Engine: A Cross-Platform Business Rules Engine Powered by Rust
Summary
ZEN Engine is an open-source, cross-platform Business Rules Engine written in Rust. It provides native bindings for various languages like NodeJS, Python, Go, and JVM, enabling developers to integrate powerful decision-making logic into their applications. The engine utilizes the JSON Decision Model (JDM) for defining and executing complex business rules efficiently.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
ZEN Engine is an open-source, cross-platform Business Rules Engine (BRE) meticulously crafted in Rust. It provides robust native bindings for a wide array of programming languages, including NodeJS, Python, Go, Kotlin (JVM), and Java, allowing seamless integration of complex decision-making logic into diverse applications. At its core, ZEN Engine is designed to load and execute JSON Decision Models (JDM), offering a standardized and efficient way to define and manage business rules. This powerful engine empowers developers to build intelligent, adaptable systems with ease.
Installation
Getting started with ZEN Engine, especially with its Rust core, is straightforward. For Rust projects, you can add zen-engine
as a dependency in your Cargo.toml
file.
[dependencies]
zen-engine = "0"
For other supported platforms, native bindings are available and can be integrated via their respective package managers:
- NodeJS: Install via npm.
- Python: Install via pip.
- Go: Integrate using Go modules.
Refer to the official documentation for detailed installation instructions for each platform.
Examples
The following Rust example demonstrates how to load a JSON Decision Model and evaluate it using the ZEN Engine. This snippet showcases the simplicity and power of integrating the engine into your Rust application.
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;
}
This example initializes a DecisionEngine
, loads decision content from a JSON file, creates a decision, and then evaluates it with a given input.
Why Use It?
ZEN Engine stands out as an excellent choice for implementing business rules due to several key advantages:
- Cross-Platform Compatibility: With native bindings for Rust, NodeJS, Python, Go, Kotlin (JVM), and Java, ZEN Engine offers unparalleled flexibility, allowing you to use it across your preferred technology stack.
- High Performance: Built on Rust, known for its speed and memory efficiency, the engine delivers high-performance rule execution, crucial for demanding applications.
- JSON Decision Model (JDM): It leverages JDM, a clear and structured JSON-based format for defining decision models, making rules human-readable, maintainable, and easily shareable.
- Rich Decision Logic: Supports various node types like Decision Tables, Switch Nodes, Function Nodes, Expression Nodes, and Decision Nodes, enabling the creation of highly complex and dynamic decision flows.
- Modularity and Reusability: The ability to invoke and reuse other decision models promotes modular design, reducing redundancy and improving maintainability in large systems.
- Open-Source: Released under the MIT License, ZEN Engine is free to use, modify, and distribute, fostering community collaboration and transparency.
Links
Explore ZEN Engine further through these official resources:
- GitHub Repository: gorules/zen
- Official Documentation: Rust Engine Docs
- JDM Editor (GitHub): gorules/jdm-editor
- Free Online JDM Editor: editor.gorules.io
- NodeJS Binding (npmjs): @gorules/zen-engine
- Python Binding (pypi): zen-engine
- Rust Binding (crates.io): zen-engine
- Go Binding (GitHub): gorules/zen-go