Project

General

Profile

Actions

Cruxflowdesign » History » Revision 3

« Previous | Revision 3/21 (diff) | Next »
Shuvam Misra, 21/09/2023 03:47 PM


Algorithms and data structures for the flow engine

We will refer heavily to the algorithms and data structures of the BRE here.

Here too, we need a rules schema, rulesets and a matching engine.

Rules schema

In the BRE, each rules schema has two parts: the pattern schema and the action schema. Each rulesschema block is tagged with a class attribute, specifying which class the schema applies to. There is one rules schema for each class of entities.

In the flow engine, there is no class -- there is a process instead. A workflow schema applies to a process.

The pattern schema specification is identical here to that used in the BRE.

In the flow engine, there is no actionschema, but a flowschema. The flow schema is much simpler than an action schema. The output of a flow engine matching exercise is just the ID of one step. Therefore the flow schema here is a list of possible steps.

"ruleschema": {
    "process": "customerkyc",
    "patternschema": {
        "attr": [{
            "name": "accttype",
            "type": "enum",
            "vals": [ "savings", "current", "recurring", "fixeddeposit", "ppf" ]
        },{
            "name": "acctholdertype",
            "type": "enum",
            "vals": [ "individual", "joint", "corporate", "hinduundivided", "partnership" ]
        },{
            "name": "
            "type": "float"
        },{
            "name": "fullname",
            "type": "str",
        },{
            "name": "ageinstock",
            "type": "int"
        },{
            "name": "inventoryqty",
            "type": "int"
        }]
    }
    "flowschema": {
        "steps": [ "initialdoc", "aadhaarcheck", "pancheck", "bankdetails", "referenchk", "complete" ]
    }
}

In the example above:

  • class is replaced with process
  • patternschema remains unchanged
  • actionschema is replaced with flowschema and the structure of flowschema is simplified to just one array of words. Each word here is an ID of a step. So, theflowschema.steps` lists all the valid steps which the flow engine may return after matching an entity with the rules.

Updated by Shuvam Misra over 1 year ago · 3 revisions