๐ง 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 integration with RETE algorithm
- ๐ Topological Execution - Automatic DAG-based node ordering
- โก Async Runtime - Built on Tokio for high concurrency
- โก Parallel Execution - Automatic parallel execution of independent nodes (NEW in v0.4.0)
- ๏ฟฝ๏ธ Caching Layer - High-performance result caching with TTL, eviction policies, and memory limits (NEW in v0.5.0)
- ๏ฟฝ๐ Multiple Node Types - RuleNode, DBNode, AINode
- ๐ JSON Configuration - Simple workflow definitions
- ๐ฏ 97% Drools Compatible - Easy migration from Java
- ๐ Streaming Processing - Stream-based execution with backpressure (NEW in 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.4.0"
# With specific integrations
= { = "0.4.0", = ["postgres", "openai"] }
# With all integrations
= { = "0.4.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?;
Run Examples
# Basic workflow
# GRL rules
# Advanced integration
๐ Documentation
| Document | Description |
|---|---|
| Cache Guide | Caching layer with TTL and eviction policies (NEW in v0.4.0) |
| 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
๐๏ธ 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;
}
๐ 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
# Run with output
# Run specific example
Result: โ 17/17 tests passing
๐ฆ Project Status
Version: 0.4.0 (Latest) Status: Production-ready with parallel execution and streaming
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)
- โ Streaming processing with backpressure and chunking (NEW!)
- โ Parallel execution with automatic layer detection (NEW!)
- โ Stream operators (map, filter, fold)
- โ Comprehensive documentation
Roadmap
- Streaming processing (v0.3.0) - COMPLETED
- Parallel node execution (v0.3.0) - COMPLETED
- Caching layer (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:
- 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 (NEW!) | 200 |
parallel_execution.rs |
Parallel node execution (NEW!) | 250 |
๐ 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.4.0 (2025-11-06) - Parallel Execution Release
New Features:
- โก Parallel Node Execution - Automatic detection and parallel execution of independent nodes
- Layer detection algorithm using topological sort
- Concurrent execution within layers
- Parallelism analysis and statistics
- Theoretical speedup calculation
- ๐ ParallelExecutor - New executor with parallel capabilities
- ๐ Performance Analysis -
get_parallelism_stats()for graph analysis - ๐ New Example -
parallel_execution.rswith 5 scenarios - โ 3 New Tests - Comprehensive parallel execution testing
Improvements:
- Updated documentation with parallel execution details
- Added parallelism comparison examples
- Performance benchmarking utilities
Compatibility:
- All 17 tests passing
- Backward compatible with v0.3.0
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 - GRL support
- Tokio - Async runtime
- Petgraph - Graph algorithms
- Serde - Serialization
โญ Star us on GitHub if you find this useful! โญ
Documentation โข Examples โข Use Cases