Project

General

Profile

Actions

Cruxflowdesign » History » Revision 5

« Previous | Revision 5/21 (diff) | Next »
Shuvam Misra, 21/09/2023 04:04 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": "branchtype",
            "type": "enum",
            "vals": [ "urban", "semirural", "rural" ]
        },{
            "name": "branchcode",
            "type": "str"
        },{
            "name": "refererquality",
            "type": "int",
            "valmin": 0,
            "valmax": 5
        },{
            "name": "districtcode",
            "type": "int"
        }]
    }
    "flowschema": {
        "steps": [ "initialdoc", "aadhaarcheck", "creditbureauchk", "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.

The example above attempts to illustrate what a workflow may incorporate when a customer is applying to open a bank account and the workflow engine is guiding the processing centre about the sequence of steps to follow to complete the applicant's KYC (Know Your Customer) process. In this example, the workflow decisions will be taken based on the following parameters of the application:

  • accttype: whether the account being opened is a current account, a savings account, etc
  • acctholdertype: whether the applicant is an individual, a Hindu Undivided Family, an incorporated company, a partnership firm, etc
  • branchtype: whether the branch is in an urban area, a semi-rural area or a rural area -- customer assessment norms may be relaxed or done quite differently for rural and urban areas
  • branchcode: an integer code which has been assigned for each branch. With this attribute, it is possible to define patterns which match specific branches
  • refererquality: an integer which, it is assumed, will have a higher value if the quality of the referer is higher in the bank's eyes
  • `districtcode: an integer uniquely identifying the district where the applicant is located; customer KYC norms may differ from district to district

This set of six attributes of each account opening application can form a solid foundation to define a rich set of rules of how the KYC process will proceed.

In addition there will always be one additional attribute in the pattern section of each rule -- the step. This will specify the current step the process is on. The ruleset(s) will look at all the other attributes, the current step the process is at, and will attempt to come up with a specification of the next step to execute. That's the entire raison d'etre for a workflow engine.

Specifying a ruleset

The following is a hyopthetical ruleset for the process customerkyc.


Updated by Shuvam Misra over 1 year ago · 5 revisions