๐ง Rust Logic Graph
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 ;
async
โจ Key Features
- ๐ฅ GRL Support - rust-rule-engine v0.14.0 with RETE-UL algorithm (2-24x faster)
- ๐ Topological Execution - Automatic DAG-based node ordering
- โก Async Runtime - Built on Tokio for high concurrency
- โก Parallel Execution - Automatic parallel execution of independent nodes (v0.5.0)
- ๐พ Caching Layer - High-performance result caching with TTL, eviction policies, and memory limits (v0.5.0)
- ๐ง Memory Optimization - Context pooling and allocation tracking (v0.7.0)
- ๐ ๏ธ CLI Developer Tools - Graph validation, dry-run, profiling, and visualization (v0.5.0)
- ๐จ Web Graph Editor - Next.js visual editor with drag-and-drop interface (v0.8.0)
- ๐ Multiple Node Types - RuleNode, DBNode, AINode
- ๐ JSON Configuration - Simple workflow definitions
- ๐ฏ 98% Drools Compatible - Easy migration from Java
- ๐ Streaming Processing - Stream-based execution with backpressure (v0.3.0)
- ๐๏ธ Database Integrations - PostgreSQL, MySQL, Redis, MongoDB (v0.2.0)
- ๐ค AI/LLM Integrations - OpenAI, Claude, Ollama (v0.2.0)
๐ Quick Start
Installation
[]
= "0.7.0"
# With specific integrations
= { = "0.6.0", = ["postgres", "openai"] }
# With all integrations
= { = "0.6.0", = ["all-integrations"] }
Simple Example
use ;
let grl = r#"
rule "Discount" {
when
cart_total > 100 && is_member == true
then
discount = 0.15;
}
"#;
let mut engine = new;
engine.add_grl_rule?;
Web Graph Editor (NEW in v0.8.0)
# Navigate to graph editor
# Install dependencies
# Run development server
Open http://localhost:3000 to access the visual graph editor.
Full Graph Editor Documentation โ
CLI Tools (v0.5.0)
# Build the CLI tool
# Validate a graph
# Visualize graph structure
# Profile performance
# Dry-run without execution
Run Examples
# Basic workflow
# GRL rules
# Advanced integration
๐ Documentation
| Document | Description |
|---|---|
| Graph Editor Guide | Visual web-based graph editor with Next.js (NEW in v0.8.0) |
| Memory Optimization Guide | Context pooling and allocation tracking (v0.7.0) |
| CLI Tool Guide | Developer tools for validation, profiling, and visualization (v0.5.0) |
| Cache Guide | Caching layer with TTL and eviction policies (v0.5.0) |
| Migration Guide | Upgrade guide to v0.14.0 with RETE-UL (v0.5.0) |
| Integrations Guide | Database & AI integrations (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 |
๐ฏ 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
๐๏ธ Architecture

๐ฅ 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;
}
๐ Performance
- RETE-UL Algorithm: Advanced pattern matching with unlinking (v0.14.0)
- 2-24x Faster: Than v0.10 at 50+ rules
- 98% Drools Compatible: Easy migration path
- Async by Default: High concurrency support
- Parallel Execution: Automatic layer-based parallelism
- Smart Caching: Result caching with TTL and eviction policies
๐งช Testing & CLI Tools
# Run all tests
# Build CLI tool
# Validate graph
# Visualize graph structure
# Profile performance
# Dry-run execution
Test Results: โ 32/32 tests passing
Learn more about CLI tools โ
๐ฆ Project Status
Version: 0.7.0 (Latest) Status: Production-ready with parallel execution, caching, and CLI tools
What's Working
- โ Core graph execution engine
- โ RETE-UL algorithm (v0.14.0) - 2-24x faster
- โ Three node types (Rule, DB, AI)
- โ Topological sorting
- โ Async execution
- โ JSON I/O
- โ Database integrations (PostgreSQL, MySQL, Redis, MongoDB)
- โ AI integrations (OpenAI, Claude, Ollama)
- โ Streaming processing with backpressure and chunking
- โ Parallel execution with automatic layer detection
- โ Caching layer with TTL, eviction policies, memory limits (v0.5.0)
- โ Memory optimization with context pooling (v0.7.0)
- โ CLI Developer Tools - validate, profile, visualize, dry-run (v0.5.0)
- โ Web Graph Editor - Next.js visual editor with drag-and-drop (v0.8.0)
- โ Stream operators (map, filter, fold)
- โ Comprehensive documentation
Roadmap
- Streaming processing (v0.3.0) - COMPLETED โ
- Parallel node execution (v0.4.0) - COMPLETED โ
- Caching layer (v0.5.0) - COMPLETED โ
- CLI Developer Tools (v0.5.0) - COMPLETED โ
- RETE-UL upgrade (v0.5.0) - COMPLETED โ
- Memory Optimization (v0.7.0) - COMPLETED โ
- Web Graph Editor (v0.8.0) - COMPLETED โ
- GraphQL API (v0.9.0)
- Production release (v1.0.0)
See ROADMAP.md for details
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create your feature branch
- Write tests for new features
- 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 |
postgres_flow.rs |
PostgreSQL integration | 100 |
openai_flow.rs |
OpenAI GPT integration | 150 |
streaming_flow.rs |
Streaming with backpressure | 200 |
parallel_execution.rs |
Parallel node execution | 250 |
CLI Tool Examples (v0.5.0)
| File | Description |
|---|---|
examples/sample_graph.json |
Linear workflow with 5 nodes |
examples/cyclic_graph.json |
Graph with cycle for testing |
examples/sample_context.json |
Sample input data |
See CLI_TOOL.md for usage examples
๐ 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
๐ Changelog
v0.5.0 (2025-11-06) - Performance & Developer Tools Release
Breaking Changes:
- โก Upgraded rust-rule-engine from v0.10 โ v0.14.0
- Now uses RETE-UL algorithm (2-24x faster)
- Better memory efficiency
- Improved conflict resolution
- See Migration Guide
New Features:
- ๐ ๏ธ CLI Developer Tools (
rlgbinary)- Graph validation with comprehensive checks
- Dry-run execution mode
- Performance profiling with statistics
- ASCII graph visualization
- See CLI Tool Guide
- ๐พ Caching Layer - High-performance result caching
- TTL-based expiration
- Multiple eviction policies (LRU, LFU, FIFO)
- Memory limits and statistics
- See Cache Guide
- โก Parallel Node Execution - Automatic detection and parallel execution
- Layer detection algorithm using topological sort
- Concurrent execution within layers
- Parallelism analysis and statistics
- ๐ ParallelExecutor - New executor with parallel capabilities
- ๐ New Examples - CLI examples and test graphs
- โ 32 Tests - Comprehensive test coverage
Improvements:
- Updated documentation with CLI tools, caching, and migration guides
- Performance benchmarking utilities
- Example graph files for testing
Compatibility:
- All 32 tests passing
- API is backward compatible (100%)
- Performance: 2-24x faster rule matching
v0.3.0 (2025-11-03) - Streaming & Performance Release
New Features:
- ๐ Streaming Processing - Stream-based node execution
- Backpressure handling with bounded channels
- Large dataset support with chunking
- Stream operators (map, filter, fold, async map)
- ๐ New Example -
streaming_flow.rswith 6 demonstrations - โ 8 New Tests - Streaming module testing
Performance:
- Processed 10,000 items in chunks
- ~432 items/sec throughput with backpressure
v0.2.0 (2025-11-02) - Integrations Release
New Features:
- ๐๏ธ Database Integrations - PostgreSQL, MySQL, Redis, MongoDB
- ๐ค AI/LLM Integrations - OpenAI GPT-4, Claude 3.5, Ollama
- ๐ Integration Examples -
postgres_flow.rs,openai_flow.rs - ๐ INTEGRATIONS.md - Comprehensive integration guide
- ๐๏ธ Feature Flags - Optional dependencies for integrations
v0.1.0 (2025-11-01) - Initial Release
Core Features:
- ๐ง Core graph execution engine
- ๐ฅ GRL (Grule Rule Language) integration
- ๐ Topological sorting
- โก Async execution with Tokio
- ๐ Three node types (Rule, DB, AI)
- ๐ JSON I/O for graphs
- ๐ 4 working examples
- โ 6/6 tests passing
๐ License
MIT License - see LICENSE for details.
๐ Links
- Repository: https://github.com/KSD-CO/rust-logic-graph
- rust-rule-engine: https://crates.io/crates/rust-rule-engine
- Documentation: docs/
- Issues: GitHub Issues
๐ฅ Authors
James Vu - Initial work
๐ Acknowledgments
Built with:
- rust-rule-engine v0.14.0 - GRL support with RETE-UL
- Tokio - Async runtime
- Petgraph - Graph algorithms
- Serde - Serialization
- Clap - CLI framework
โญ Star us on GitHub if you find this useful! โญ
Documentation โข Examples โข Use Cases