A real beginner's guide to building a rules engine

Nirali Shah

Audience level:
Novice

Description

Processing data based on rules is common and rules-engines are implemented in several ways. This talk will walk through my story about how I accidentally created a unique recursive-descent rules engine and a DSL to process recursively nested data, without any knowledge about language theory, covering concepts I used, the method, and applications in fields like cyber security.

Abstract

There are plenty of applications that process data based on rules. While working on one such application, I was dealing with data that was recursively nested in nature. My end goal was to apply rules on each piece of data and output those pieces that obeyed any of the rules along with the list of rules they satisfied. There were several problems I was trying to solve.

  1. Designing an appropriate data format to output nested data with rules obeyed in each layer of the nesting.
  2. Structuring the code.
  3. Reusing the code.
  4. Preprocessing recurring rules.
  5. Improving overall efficiency.

The module had to be flexible enough to allow adding or modifying rules dynamically without needing major code refactoring.

I have not taken any formal courses in language theory and learnt about some of the concepts I implemented when my code was reviewed by my mentor. The talk will cover systematically, the thought process and method I used to create a complete rules engine with a DSL (domain specific language) based rules interpreter, rules evaluator, and the intuition behind using concepts of recursive-descent and short-circuit evaluation.

The uniqueness of the method is in the fact that while the objects the rules are evaluated on are recursive, the DSL allows the rule definitions and output formats to be recursive as well. And since rules could be described using a DSL, adding or modifying rules only involved changing the DSL configuration instead of the actual code.

Subscribe to Receive PyData Updates

Subscribe