{"id":20380082,"url":"https://github.com/colinzhu/csv-business-rules-engine","last_synced_at":"2025-08-05T11:17:17.515Z","repository":{"id":162857279,"uuid":"592694889","full_name":"colinzhu/csv-business-rules-engine","owner":"colinzhu","description":"A design of business rules engine which handles business rules in JSON / CSV","archived":false,"fork":false,"pushed_at":"2023-01-30T14:21:50.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-15T07:31:03.352Z","etag":null,"topics":["rule-based","rule-engine"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colinzhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-01-24T10:27:15.000Z","updated_at":"2023-02-13T15:13:50.000Z","dependencies_parsed_at":"2023-06-27T18:18:32.825Z","dependency_job_id":null,"html_url":"https://github.com/colinzhu/csv-business-rules-engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinzhu%2Fcsv-business-rules-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinzhu%2Fcsv-business-rules-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinzhu%2Fcsv-business-rules-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinzhu%2Fcsv-business-rules-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colinzhu","download_url":"https://codeload.github.com/colinzhu/csv-business-rules-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241929592,"owners_count":20044004,"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":["rule-based","rule-engine"],"created_at":"2024-11-15T02:06:05.887Z","updated_at":"2025-03-04T22:21:25.093Z","avatar_url":"https://github.com/colinzhu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSV Business Rules Engine\n\nA design of business rules engine which handles business rules in CSV\n\n\u003cimg src=\"./csv-business-rules-engine.drawio.svg\" /\u003e\n\n### Feature\n\n- Quickly create rules with lambdas\n- Business rule configs stored in single table\n- Business rule configs stored as files\n- Cache and auto refresh cache of business rule configs\n- Simple\n\n### Config Service\n\n- Config Service manages (store, update, retrieve, delete etc.) configurations (configs)\n- Configs can be String of json, csv or any other format\n- Configs can be stored in DB or as files or extended to other medias e.g. git\n- Additional features can be added to Config Service, e.g. UI for business users to edit / approve\n- It can be deployed as a microservice similar to Spring Cloud Config\n- There are 2 options to refresh the config \n- a. Whenever there is an update to the config, notify the clients (Clients need to provide / implement an API)\n- b. Clients to check with Config Service periodically e.g. every 10s, 1min, 10min etc. And then clients can update its own cache\n- To improve the performance, Config Service can provide an API to retrieve only summary of the config, in case the config itself is too large\n\n### Rule Config\n\n- Rule Config is a kind of config, can be retrieved from ConfigService\n- Rule Config is NOT Rule, it's the metadata to be used when defining a Rule\n- Usually the business rules are stored as a table in Excel / CSV.\n  This CSV is treated as a **Rule Config**\n  When parsing the CSV, one record can be read as:\n  \u003e when (columnA = x and columnB = y) then use columnC\n- CSV format can be converted to JSON for application to process and store\n- JSON is for UI to render as a table for user to edit\n- JSON can be persisted as files or in database\n- If stored in database, different kinds of JSON will be store in one single table\n- By saving different versions of JSON into database, the application can support versioning\n- Rule config is OPTIONAL, it's not mandatory when creating a Rule\n- Other data types can be added by adding new parsers\n- The RuleConfigService supports cache and auto refresh cache of Rule Config \n\n### Rule\n\n- A Rule contains conditions(\"when\") and actions(\"then\", \"otherwise\"), and returns a Result\n- When defining a Rule, it's usual to use Rule Config, but not mandatory\n- There are 2 approaches to create a rule:\n- a. Create a java class to implement the Rule interface\n- b. Use the DefaultRuleBuilder to build a rule.\n\n### \"Fact\"\n\n- A \"Fact\" is a runtime object instance to be checked against / applied on a rule\n- To prevent creating different java classes for different types of fact, Jackson library's JsonNode is used as the type\n  for fact\n\n### RuleEngine\n\n- A component combines Rule and Fact, and kick off the processing.\n\n### Result\n\n- A result contains the rule's name, processing result, and a remark\n\n### Reference\n\n- Martin Fowler's [RulesEngine](https://martinfowler.com/bliki/RulesEngine.html)\n- [Easy Rules](https://github.com/j-easy/easy-rules) \n- [Using Redis to store configuration information](https://redis.com/ebook/part-2-core-concepts/chapter-5-using-redis-for-application-support/5-4-service-discovery-and-configuration/5-4-1-using-redis-to-store-configuration-information/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinzhu%2Fcsv-business-rules-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolinzhu%2Fcsv-business-rules-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinzhu%2Fcsv-business-rules-engine/lists"}