Skip to content

πŸ€– AI-powered business rule engine with decision automation, workflow orchestration, and intelligent process optimization

Notifications You must be signed in to change notification settings

daveedashar/automation-decision-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Automation Decision Engine

Rule-based and event-driven decision engine for business automationβ€”handling complex logic, routing, and execution without manual intervention.

Python License Status


🎯 Overview

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      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

  • 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

πŸ—οΈ Architecture

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

πŸš€ Quick Start

# 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

πŸ“‹ Rule Definition (YAML)

# 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: 0

πŸ“‹ Usage Example

Evaluate a Decision

from 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"
# }

Define Rules in Code

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)

βš™οΈ Operators

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"

πŸ“Š Decision Flow

EVENT RECEIVED
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Load Rules β”‚
β”‚  (Priority) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     NO      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Evaluate   │────────────▢│   Next      β”‚
β”‚  Conditions β”‚             β”‚   Rule      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚ YES                        β”‚
      β–Ό                            β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚  Execute    β”‚                    β”‚
β”‚  Actions    β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
      β”‚                            β”‚
      β–Ό                            β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚  Log        β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚  Decision   β”‚     (if no match)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ§ͺ Testing

# Run tests
pytest tests/ -v

# Test specific rules
python -m src.cli test-rule rules/lead_routing.yaml --input test_data.json

πŸ“ˆ Outcomes

  • Eliminated manual decision bottlenecks
  • 100% consistent execution across all cases
  • < 50ms decision latency
  • Complete audit trail for compliance

πŸ“„ License

MIT License - see LICENSE for details.


πŸ‘€ Author

Daud Ashar

About

πŸ€– AI-powered business rule engine with decision automation, workflow orchestration, and intelligent process optimization

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published