Cruxflowdesign » History » Revision 2
Revision 1 (Shuvam Misra, 21/09/2023 01:10 PM) → Revision 2/21 (Shuvam Misra, 21/09/2023 03:40 PM)
# Algorithms and data structures for the flow engine {{>toc}} 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` rules schema 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. simpler. The output of a flow engine matching exercise is just the ID of one step. step ID. Therefore the flow schema here is a list of possible steps. ``` json "ruleschema": { "process": "customerkyc", "patternschema": { "attr": [{ "name": "cat", "type": "enum", "vals": [ "textbook", "notebook", "stationery", "refbooks" ] },{ "name": "mrp", "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, the `flowschema.steps` lists all the valid steps which the flow engine may return after matching an entity with the rules.