rust-logic-graph 0.2.0

A modular reasoning graph framework for distributed logic orchestration
Documentation

๐Ÿง  Rust Logic Graph

Rust License: MIT

A high-performance reasoning graph framework for Rust with GRL (Grule Rule Language) support. Build complex workflows with conditional execution, topological ordering, and async processing.

use rust_logic_graph::{Graph, Orchestrator, GraphIO};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let def = GraphIO::load_from_file("workflow.json")?;
    let mut graph = Graph::new(def);
    Orchestrator::execute_graph(&mut graph).await?;
    Ok(())
}

โœจ Key Features

  • ๐Ÿ”ฅ GRL Support - rust-rule-engine integration with RETE algorithm
  • ๐Ÿ”„ Topological Execution - Automatic DAG-based node ordering
  • โšก Async Runtime - Built on Tokio for high concurrency
  • ๐Ÿ“Š Multiple Node Types - RuleNode, DBNode, AINode
  • ๐Ÿ“ JSON Configuration - Simple workflow definitions
  • ๐ŸŽฏ 97% Drools Compatible - Easy migration from Java

๐Ÿš€ Quick Start

Installation

[dependencies]
rust-logic-graph = "0.2.0"

# With specific integrations
rust-logic-graph = { version = "0.2.0", features = ["postgres", "openai"] }

# With all integrations
rust-logic-graph = { version = "0.2.0", features = ["all-integrations"] }

Simple Example

use rust_logic_graph::{RuleEngine, GrlRule};

let grl = r#"
rule "Discount" {
    when
        cart_total > 100 && is_member == true
    then
        discount = 0.15;
}
"#;

let mut engine = RuleEngine::new();
engine.add_grl_rule(grl)?;

Run Examples

# Basic workflow
cargo run --example simple_flow

# GRL rules
cargo run --example grl_rules

# Advanced integration
cargo run --example grl_graph_flow

๐Ÿ“š Documentation

Document Description
Integrations Guide Database & AI integrations (NEW in v0.2.0)
GRL Guide Complete GRL syntax and examples
Use Cases 33+ real-world applications
Extending Create custom nodes and integrations
Implementation Technical details
GRL Integration Integration guide

๐ŸŽฏ Use Cases

Rust Logic Graph powers applications in:

  • ๐Ÿ’ฐ Finance - Loan approval, fraud detection, risk assessment
  • ๐Ÿ›’ E-commerce - Dynamic pricing, recommendations, fulfillment
  • ๐Ÿฅ Healthcare - Patient triage, clinical decisions, monitoring
  • ๐Ÿญ Manufacturing - Predictive maintenance, QC automation
  • ๐Ÿ›ก๏ธ Insurance - Claims processing, underwriting
  • ๐Ÿ“Š Marketing - Lead scoring, campaign optimization
  • โš–๏ธ Compliance - AML monitoring, GDPR automation

View all 33+ use cases โ†’


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         rust-rule-engine (GRL)          โ”‚
โ”‚        RETE Algorithm โ€ข 2-24x Faster    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        Rust Logic Graph Core            โ”‚
โ”‚  โ€ข Graph Definition                     โ”‚
โ”‚  โ€ข Topological Executor                 โ”‚
โ”‚  โ€ข Context Management                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚            โ”‚            โ”‚
โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”
โ”‚ Rule  โ”‚   โ”‚  DB   โ”‚   โ”‚  AI   โ”‚
โ”‚ Node  โ”‚   โ”‚ Node  โ”‚   โ”‚ Node  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ฅ GRL Example

rule "HighValueLoan" salience 100 {
    when
        loan_amount > 100000 &&
        credit_score < 750
    then
        requires_manual_review = true;
        approval_tier = "senior";
}

rule "AutoApproval" salience 50 {
    when
        credit_score >= 700 &&
        income >= loan_amount * 3 &&
        debt_ratio < 0.4
    then
        auto_approve = true;
        interest_rate = 3.5;
}

Learn more about GRL โ†’


๐Ÿ“Š Performance

  • RETE Algorithm: Optimized pattern matching
  • 2-24x Faster: Than alternatives at 50+ rules
  • 97% Drools Compatible: Easy migration path
  • Async by Default: High concurrency support

๐Ÿงช Testing

# Run all tests
cargo test

# Run with output
cargo test -- --nocapture

# Run specific example
cargo run --example grl_rules

Result: โœ… 6/6 tests passing


๐Ÿ“ฆ Project Status

Version: 0.2.0 (Beta) Status: Production-ready with real integrations

What's Working

  • โœ… Core graph execution engine
  • โœ… GRL rule engine integration
  • โœ… Three node types (Rule, DB, AI)
  • โœ… Topological sorting
  • โœ… Async execution
  • โœ… JSON I/O
  • โœ… Database integrations (PostgreSQL, MySQL, Redis, MongoDB)
  • โœ… AI integrations (OpenAI, Claude, Ollama)
  • โœ… Comprehensive documentation

Roadmap

  • Parallel node execution (v0.3.0)
  • Performance optimizations (v0.3.0)
  • GraphQL API (v0.6.0)
  • Web UI for visualization (v0.7.0)
  • Production release (v1.0.0)

See ROADMAP.md for details


๐Ÿค Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create your feature branch
  3. Write tests for new features
  4. Submit a pull request

๐Ÿ“– Examples

Example Description Lines
simple_flow.rs Basic 3-node pipeline 36
advanced_flow.rs Complex 6-node workflow 120
grl_rules.rs GRL rule examples 110
grl_graph_flow.rs GRL + Graph integration 140

๐ŸŒŸ Why Rust Logic Graph?

vs. Traditional Rule Engines

  • โœ… Async by default - No blocking I/O
  • โœ… Type safety - Rust's type system
  • โœ… Modern syntax - GRL support
  • โœ… Graph-based - Complex workflows

vs. Workflow Engines

  • โœ… Embedded - No external services
  • โœ… Fast - Compiled Rust code
  • โœ… Flexible - Custom nodes
  • โœ… Rule-based - Business logic in rules

๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ”— Links


๐Ÿ‘ฅ Authors

James Vu - Initial work


๐Ÿ™ Acknowledgments

Built with:


โญ Star us on GitHub if you find this useful! โญ

Documentation โ€ข Examples โ€ข Use Cases