Project

General

Profile

Cruxflowdesign » History » Version 3

Shuvam Misra, 21/09/2023 03:47 PM

1 1 Shuvam Misra
# Algorithms and data structures for the flow engine
2
3
{{>toc}}
4
5
We will refer heavily to the algorithms and data structures of the BRE here.
6
7
Here too, we need a rules schema, rulesets and a matching engine.
8
9
## Rules schema
10
11 2 Shuvam Misra
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.
12 1 Shuvam Misra
13
In the flow engine, there is no `class` -- there is a `process` instead. A workflow schema applies to a process.
14
15
The pattern schema specification is identical here to that used in the BRE. 
16
17 2 Shuvam Misra
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.
18 1 Shuvam Misra
19
``` json
20
"ruleschema": {
21
    "process": "customerkyc",
22
    "patternschema": {
23
        "attr": [{
24 3 Shuvam Misra
            "name": "accttype",
25 1 Shuvam Misra
            "type": "enum",
26 3 Shuvam Misra
            "vals": [ "savings", "current", "recurring", "fixeddeposit", "ppf" ]
27 1 Shuvam Misra
        },{
28 3 Shuvam Misra
            "name": "acctholdertype",
29
            "type": "enum",
30
            "vals": [ "individual", "joint", "corporate", "hinduundivided", "partnership" ]
31
        },{
32
            "name": "
33 1 Shuvam Misra
            "type": "float"
34
        },{
35
            "name": "fullname",
36
            "type": "str",
37
        },{
38
            "name": "ageinstock",
39
            "type": "int"
40
        },{
41
            "name": "inventoryqty",
42
            "type": "int"
43
        }]
44
    }
45
    "flowschema": {
46
        "steps": [ "initialdoc", "aadhaarcheck", "pancheck", "bankdetails", "referenchk", "complete" ]
47
    }
48
}
49
```
50 2 Shuvam Misra
In the example above:
51
* `class` is replaced with `process`
52
* `patternschema` remains unchanged
53
* `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, the `flowschema.steps` lists all the valid steps which the flow engine may return after matching an entity with the rules.