๐ง 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
- ๐ Multiple Node Types - RuleNode, DBNode, AINode
- ๐ JSON Configuration - Simple workflow definitions
- ๐ฏ 97% Drools Compatible - Easy migration from Java
๐ Quick Start
Installation
[]
= "0.2.0"
# With specific integrations
= { = "0.2.0", = ["postgres", "openai"] }
# With all integrations
= { = "0.2.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 |
|---|---|
| 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: โ 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:
- 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 |
๐ 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
- 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