{"id":24641497,"url":"https://github.com/ayonious/nested-rules-engine","last_synced_at":"2025-05-12T15:06:25.796Z","repository":{"id":34219801,"uuid":"161554882","full_name":"ayonious/nested-rules-engine","owner":"ayonious","description":"🌲 Decision Tree based Rules Engine","archived":false,"fork":false,"pushed_at":"2025-01-08T23:12:39.000Z","size":649,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T00:28:53.427Z","etag":null,"topics":["decision-tree","dfs","rule-engine"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayonious.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-12T22:50:21.000Z","updated_at":"2024-10-13T20:12:53.000Z","dependencies_parsed_at":"2023-01-15T05:30:48.878Z","dependency_job_id":"20e13874-31c0-46f3-837e-044b03d7ee99","html_url":"https://github.com/ayonious/nested-rules-engine","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayonious%2Fnested-rules-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayonious%2Fnested-rules-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayonious%2Fnested-rules-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayonious%2Fnested-rules-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayonious","download_url":"https://codeload.github.com/ayonious/nested-rules-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235575655,"owners_count":19012159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decision-tree","dfs","rule-engine"],"created_at":"2025-01-25T12:13:47.430Z","updated_at":"2025-01-25T12:13:47.929Z","avatar_url":"https://github.com/ayonious.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003enested-rules-engine\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003e🌲Decision Tree based Rules Engine\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://circleci.com/gh/ayonious/nested-rules-engine\"\u003e\n    \u003cimg alt=\"CircleCI\" src=\"https://circleci.com/gh/ayonious/nested-rules-engine.svg?style=svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/ayonious/nested-rules-engine\"\u003e\n    \u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/ayonious/nested-rules-engine/branch/master/graph/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://badge.fury.io/js/nested-rules-engine\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://badge.fury.io/js/nested-rules-engine.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=nested-rules-engine\"\u003e\n    \u003cimg alt=\"install size\" src=\"https://packagephobia.now.sh/badge?p=nested-rules-engine@latest\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/prettier/prettier\"\u003e\n    \u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=plastic\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/semantic-release/semantic-release\"\u003e\n    \u003cimg alt=\"semantic-release\" src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Synopsis\n\nA simple Decision tree based Rule Engine described using json files. Rules are executed according to decision tree. Create a set of rules (make them nested as you like) and based on set of inputs run the rules.\n\n## Features\n\n1. Rules expressed in huaman readable JSON\n2. Create new set of inputs or change existing inputs as you traverse rules tree\n3. Do multiple executions or rules set\n\n## Installation\n\n```\nnpm install nested-rules-engine --save\n```\n\n## Basic Example\n\n```\nconst {executeEngine} = require('nested-rules-engine');\n\n// Step1: Define your conditional rules\nconst rules = {\n  \"you_are_a_human\": {\n    \"you_are_kind\": \"help_me_find_my_book\",\n    \"you_are_smart\": \"please_do_my_homework\",\n  },\n  \"default\": \"please_do_my_homework\"\n};\n\n// Step2: make set of inputs collection\nconst inputs = {\n  \"type\" : \"human\",\n  \"kindnessLevel\": 0,\n  \"intelligence\": 10\n}\n\n// Step3: Make your custom Functions\nconst functions = {\n  default : () =\u003e true,\n  you_are_a_human: ({type}) =\u003e type === 'human',\n  you_are_kind: ({kindnessLevel}) =\u003e kindnessLevel \u003e 300,\n  you_are_smart: ({intelligence}) =\u003e intelligence \u003e 5,\n  help_me_find_my_book: () =\u003e ({\n    payload: 'lets help someone',\n    effort: 'finding the book'\n  }),\n  please_do_my_homework: () =\u003e ({\n    payload: 'doing homework',\n    effort: 'im getting sick'\n  })\n};\n\n// Step4: Execute Engine\nconst res = executeEngine(inputs, functions, rules);\n\n// Output res:\n/*\n{\n  result: { payload: 'doing homework', effort: 'im getting sick' },\n  logs: []\n}\n*/\n```\n\n## Documentation\n\nEngine Execution Signature:\n\n```\nexecuteEngine(variables, functions, rules, options);\n```\n\n### Inputs\n\n- `variables` Collection of values on which rule engine will execute\n  You can change these collection of variables (Add/Edit/Delte them) as you traverse the decision tree of rules.\n\n- `functions` Collection of functions that decide which way the tree should be traversed.\n\n  - In case the function indicates a final decision in tree (leaf of decision tree): Output can be anything that you want to see as `result`\n  - In case the function is makes an intermediate decision (branch of decision tree):\n    - if output is `true`: this means this branch should be traversed\n    - else: the function will be executed\n\n- `rules` Decision Tree that will be traversed by this Rule Engine\n\n- `options` there are different options that you can provide to customize the execution nature\n  - verbose (boolean): Makes Sure you get enough logs while engine goes through all decision tree\n  - multiple (boolean): You can run multiple Decision Trees based on same inputs. Input sets are shared between each tree\n\n### Outputs\n\n- `result`: Result of the engine execution. format of Result will be defined by you through `functions`\n- `logs`: Detailed logs while engine got executed (by default its disabled)\n\n## Hard Examples\n\n1. Example with verbose output, multiple executions [Find Here](https://github.com/ayonious/nested-rules-engine/blob/master/test/multirun-verbose-example.js)\n2. Example with Creating new set of inputs while engine is executing [Find Here](https://github.com/ayonious/nested-rules-engine/blob/master/test/change-variables-example.js)\n\n## License\n\n[MIT](https://github.com/ayonious/nested-rules-engine/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayonious%2Fnested-rules-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayonious%2Fnested-rules-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayonious%2Fnested-rules-engine/lists"}