Rule-based and event-driven decision engine for business automationβhandling complex logic, routing, and execution without manual intervention.
This engine automates business decisions by evaluating rules, processing events, and executing actionsβenabling consistent, repeatable execution at scale.
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Event ββββββΆβ Rule ββββββΆβ Decision ββββββΆβ Action β
β Input β β Engine β β Output β β Executor β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββ
β Audit β
β Log β
βββββββββββββββ
- Rule Engine - Define complex business rules in YAML or code
- Decision Trees - Visual decision flow with branching logic
- Event Processing - React to real-time events from any source
- Action Execution - Trigger workflows, APIs, notifications
- Audit Trail - Complete logging of all decisions for compliance
- A/B Testing - Test different rule sets in production
- Fallback Handling - Graceful degradation when rules don't match
src/
βββ api/ # REST API
β βββ decisions.py
β βββ rules.py
β βββ events.py
βββ core/ # Core engine
β βββ rule_engine.py
β βββ decision_tree.py
β βββ evaluator.py
β βββ context.py
βββ rules/ # Rule definitions
β βββ parser.py
β βββ validator.py
β βββ compiler.py
βββ actions/ # Action executors
β βββ base_action.py
β βββ webhook_action.py
β βββ email_action.py
β βββ workflow_action.py
βββ storage/ # Persistence
β βββ rule_store.py
β βββ decision_log.py
βββ monitoring/ # Observability
βββ metrics.py
βββ audit.py
# Clone repository
git clone https://github.com/daveedashar/automation-decision-engine.git
cd automation-decision-engine
# Install dependencies
pip install -r requirements.txt
# Run the service
python -m src.main# rules/lead_routing.yaml
name: lead_routing
version: 1.0
description: Route leads based on score and region
rules:
- name: high_value_enterprise
conditions:
all:
- field: lead_score
operator: gte
value: 80
- field: company_size
operator: eq
value: "enterprise"
actions:
- type: assign
to: "enterprise_team"
- type: notify
channel: "slack"
message: "π₯ High-value lead: {{lead.name}}"
priority: 100
- name: mid_market_qualified
conditions:
all:
- field: lead_score
operator: gte
value: 50
- field: company_size
operator: in
value: ["mid_market", "smb"]
actions:
- type: assign
to: "sales_team"
- type: add_to_sequence
sequence: "nurture_qualified"
priority: 50
- name: default_routing
conditions:
all: [] # Catch-all
actions:
- type: assign
to: "sdr_team"
priority: 0from src.core import DecisionEngine
engine = DecisionEngine()
engine.load_rules("rules/lead_routing.yaml")
# Evaluate
result = engine.evaluate({
"lead_score": 85,
"company_size": "enterprise",
"region": "north_america",
"lead": {
"name": "Acme Corp",
"email": "[email protected]"
}
})
print(result)
# {
# "rule_matched": "high_value_enterprise",
# "actions": [
# {"type": "assign", "to": "enterprise_team"},
# {"type": "notify", "channel": "slack", ...}
# ],
# "decision_id": "dec_abc123",
# "timestamp": "2026-01-03T22:30:00Z"
# }from src.core import Rule, Condition, Action
rule = Rule(
name="fraud_detection",
conditions=[
Condition("transaction_amount", "gte", 10000),
Condition("country", "in", ["high_risk_countries"]),
Condition("velocity_24h", "gte", 5),
],
match_type="all", # or "any"
actions=[
Action("flag", severity="high"),
Action("notify", team="fraud_ops"),
Action("hold_transaction"),
]
)
engine.add_rule(rule)| Operator | Description | Example |
|---|---|---|
eq |
Equals | field: status, operator: eq, value: "active" |
neq |
Not equals | field: type, operator: neq, value: "test" |
gt |
Greater than | field: amount, operator: gt, value: 100 |
gte |
Greater than or equal | field: score, operator: gte, value: 50 |
lt |
Less than | field: age, operator: lt, value: 30 |
lte |
Less than or equal | field: count, operator: lte, value: 10 |
in |
In list | field: country, operator: in, value: ["US", "UK"] |
not_in |
Not in list | field: status, operator: not_in, value: ["banned"] |
contains |
Contains substring | field: email, operator: contains, value: "@gmail" |
regex |
Regex match | field: phone, operator: regex, value: "^\+1" |
EVENT RECEIVED
β
βΌ
βββββββββββββββ
β Load Rules β
β (Priority) β
βββββββββββββββ
β
βΌ
βββββββββββββββ NO βββββββββββββββ
β Evaluate ββββββββββββββΆβ Next β
β Conditions β β Rule β
βββββββββββββββ βββββββββββββββ
β YES β
βΌ β
βββββββββββββββ β
β Execute β β
β Actions β β
βββββββββββββββ β
β β
βΌ β
βββββββββββββββ β
β Log ββββββββββββββββββββββ
β Decision β (if no match)
βββββββββββββββ
# Run tests
pytest tests/ -v
# Test specific rules
python -m src.cli test-rule rules/lead_routing.yaml --input test_data.json- Eliminated manual decision bottlenecks
- 100% consistent execution across all cases
- < 50ms decision latency
- Complete audit trail for compliance
MIT License - see LICENSE for details.
Daud Ashar
- GitHub: @daveedashar
- LinkedIn: /in/daudashar
- Email: [email protected]