noex ecosystem

noex-rules

Rule Engine with Complex Event Processing

Forward chaining engine with temporal pattern detection, three DSL flavors, integrated fact store, and production-ready REST/GraphQL APIs. Built on noex GenServer actors for fault-tolerant rule processing.

Key Features

Everything you need for production rule processing and event correlation

Forward Chaining Engine

Priority-based rule execution with automatic re-evaluation on fact changes, events, and timer expirations. Individual rule failures don't affect the rest of the system.

Complex Event Processing

Built-in temporal patterns: sequence detection, absence monitoring, count thresholds, and numeric aggregations — all with configurable time windows and grouping.

Three DSL Flavors

Write rules your way: fluent builder API with full TypeScript autocomplete, tagged template literals for compact syntax, or YAML files for configuration-driven workflows.

Fact Store with Wildcards

In-memory key-value storage with segmented wildcard pattern matching. Version tracking and change notifications power automatic rule re-evaluation.

Timer Management

Declarative timers with human-readable durations. One-shot and repeating schedules, optional persistence, and automatic event emission on expiration.

REST API & Web UI

Production-ready Fastify server with Swagger docs, SSE streaming, webhooks, and a React-based admin interface. Manage rules, facts, and events via HTTP.

Write Rules Your Way

Three DSL flavors for the same rule — pick the one that fits your workflow

rules.ts
import { Rule, onEvent, event, emit, setFact, ref }
  from '@hamicek/noex-rules/dsl';

const rule = Rule.create('order-notification')
  .description('Notify on high-value orders')
  .priority(10)
  .when(onEvent('order.created'))
  .if(event('amount').gte(100))
  .then(
    emit('notification.send', {
      orderId: ref('event.orderId'),
      message: 'High-value order received',
    })
  )
  .also(
    setFact('order:${event.orderId}:notified', true)
  )
  .build();

Complex Event Processing

Detect patterns across event streams with time windows and grouping

Sequence

Detect ordered events within a time window with optional strict mode and groupBy.

sequence()
  .event('order.created')
  .event('payment.received')
  .within('15m')
  .groupBy('orderId')

Absence

Trigger when an expected event does not occur within the time window.

absence()
  .after('order.created')
  .expected('payment.received')
  .within('15m')
  .groupBy('orderId')

Count

Detect when event frequency exceeds a threshold within a sliding or tumbling window.

count()
  .event('auth.login_failed')
  .threshold(5)
  .window('5m')
  .groupBy('userId')

Aggregate

Track numeric aggregations (sum, avg, min, max) over event fields in time windows.

aggregate()
  .event('order.paid')
  .field('amount')
  .function('sum')
  .threshold(10000)
  .window('1h')

Real-world Use Cases

From fraud detection to IoT — noex-rules powers event-driven business logic

Fraud Detection

Detect suspicious login patterns, unusual transaction amounts, and geographic anomalies in real-time.

Rule.create('brute-force-detection')
  .when(count()
    .event('auth.login_failed')
    .threshold(5)
    .window('5m')
    .groupBy('userId'))
  .then(emit('security.alert', {
    type: 'brute-force',
    userId: ref('trigger.groupKey'),
  }))
  .build();

Payment Orchestration

Manage payment flows with timeout handling, retry logic, and automatic escalation on failure.

Rule.create('payment-timeout')
  .when(absence()
    .after('order.created')
    .expected('payment.received')
    .within('15m')
    .groupBy('orderId'))
  .then(emit('order.cancel', {
    orderId: ref('trigger.groupKey'),
    reason: 'Payment timeout',
  }))
  .build();

Loyalty Programs

Calculate points, track tier upgrades, and trigger rewards based on customer activity patterns.

Rule.create('gold-tier-upgrade')
  .when(aggregate()
    .event('order.paid')
    .field('amount')
    .function('sum')
    .threshold(10000)
    .window('30d')
    .groupBy('customerId'))
  .then(setFact(
    'customer:${trigger.groupKey}:tier', 'gold'
  ))
  .build();

IoT Event Processing

Monitor sensor data streams, detect threshold breaches, and correlate events across devices.

Rule.create('device-overheat')
  .when(sequence()
    .event('sensor.temp_high')
    .event('sensor.temp_critical')
    .within('10m')
    .groupBy('deviceId'))
  .then(emit('alert.overheat', {
    deviceId: ref('trigger.groupKey'),
    severity: 'critical',
  }))
  .build();

How It Compares

noex-rules vs popular JavaScript rule engines

Featurenoex-rulesjson-rules-enginenoolsnode-rulesroolszen-engine
Forward ChainingYesYesYes (Rete)YesYesDecision tables
CEP / Temporal PatternsSequence, absence, count, aggregate
DSLFluent + templatesJSON onlyCustom DSLJSON onlyPlain objectsDMN / FEEL
YAML Rule Definitions
Fact Store with Pattern MatchingBuilt-in wildcardsAlmanacWorking memory
Timer ManagementBuilt-in DSL
Event CorrelationCorrelation + causation IDs
Wildcard Event SubscriptionsTopic patterns
REST APIBuilt-in (Fastify)
SSE + Webhooks
String Interpolation${expression}JS in DSLFEEL expressions
External Service Callscall_service actionCustom operatorsCustom functionsCustom handlersCustom nodes
OTP Supervisionnoex GenServer
Priority-based ExecutionYesYesSalienceYesYesRow order
OpenAPI / Swagger
StatusActiveActiveArchivedLow activityActiveActive

What Makes noex-rules Unique

Complex Event Processing

The only JS rule engine with built-in CEP: sequence detection, absence monitoring, frequency counting, and aggregate thresholds with time windows.

Three DSL Flavors

Fluent builder with TypeScript autocomplete, tagged template literals for quick prototyping, and YAML for configuration-driven workflows.

Integrated Fact Store

Wildcard pattern queries with automatic rule re-evaluation on fact changes. No separate state management needed.

Built-in Timer Management

Declarative timers with human-readable durations, repeat intervals, and automatic event emission on expiry.

Production-ready REST API

Fastify-based HTTP layer with SSE streaming, HMAC-signed webhooks, and Swagger documentation out of the box.

OTP Supervision

Built on noex GenServer actors. If the engine crashes, the supervisor restarts it while the rest of your application continues.

Start building intelligent event processing

Add noex-rules to your project in seconds

npm install @hamicek/noex-rules
$ npm install @hamicek/noex-rules

Support the Project

Love noex? Help us keep building amazing tools

Bitcoin
Bitcoin QR Code