https://github.com/navikt/fp-nare
NARE - Not A Rule Engine
https://github.com/navikt/fp-nare
backend bibliotek familie felles foreldrepenger nare
Last synced: 5 months ago
JSON representation
NARE - Not A Rule Engine
- Host: GitHub
- URL: https://github.com/navikt/fp-nare
- Owner: navikt
- License: mit
- Created: 2019-03-04T10:38:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2026-01-07T13:54:40.000Z (6 months ago)
- Last Synced: 2026-01-14T03:35:36.853Z (5 months ago)
- Topics: backend, bibliotek, familie, felles, foreldrepenger, nare
- Language: Java
- Homepage:
- Size: 686 KB
- Stars: 2
- Watchers: 16
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
[](https://github.com/navikt/fp-nare/actions/workflows/build.yml)
[](https://sonarcloud.io/dashboard?id=navikt_fp-nare)
[](https://sonarcloud.io/summary/new_code?id=navikt_fp-nare)
[](https://sonarcloud.io/component_measures/metric/coverage/list?id=navikt_fp-nare)
[](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=navikt_fp-nare)
[](https://sonarcloud.io/component_measures/metric/security_rating/list?id=navikt_fp-nare)
[](https://sonarcloud.io/summary/new_code?id=navikt_fp-nare)


# NARE - Not A Rule Engine
NARE a variation of the Specification pattern, as described by Eric Evans & Martin Fowler here: https://martinfowler.com/apsupp/spec.pdf, adapter to handled more complex cases.
More generally, it is an implementation of an [Expression Tree](https://en.wikipedia.org/wiki/Binary_expression_tree), but one which can support both unary, binary and ternary nodes expressions.
# Purpose
To model decision trees so they can be visualised, documented, and traced (inputs, outputs, evaluation), for legal and regulatory review. Both the specification of a rule as well as its execution can be documented.
# Features
* Unary expressions:
- Sequence: Sequence of expressions, result = result from last evaluation.
- Foreach:
- Not
- Node: (node computation supplied by implementor) Allows for arbitrary evaluations to be included.
* Binary expressions:
- And
- Or
* Ternary expressions:
* - Computational If/Else: Simple if/then or if/then/else. Returns result from .
* N-ary expressions:
- Conditional If/Or/Else: Allows for evaluating only specific subtrees based on a provided condition.
# Rule documentation
The rule specification may be output to Asciidoc using the supplied Javadoc Doclet. This will output names of parameters and rules to a single asciidoc document, while the trees will be output to a json document as a set of nodes and edges. The output format in json is the same for both the specification and evaluation trees (except a few evaluation specific parameters), making both suitable for long term storage.
The json output for a graph is fairly easy to graph out using any appropriate graphing library (Vue, D3, etc.) that supports a node/edge layout.
# Examples
See tests for examples
* Usage example (running a rule): [Rule evaluation example (modrekvote)](https://github.com/navikt/fp-nare/blob/master/core/src/test/java/no/nav/fpsak/nare/specification/modrekvote/ModrekvoteTest.java)
* Specification example : [Rule specification example (modrekvote)](https://github.com/navikt/fp-nare/blob/master/core/src/test/java/no/nav/fpsak/nare/specification/modrekvote/Modrekvote.java)
* Generating documentation example (here using a unit test, can be adapted to whatever): [Doclet example](https://github.com/navikt/fp-nare/blob/master/core/src/test/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDocletTest.java)
# Contact
* **External**: Raise an issue here on GitHub
* **Internal**: Slack channel #teamforeldrepenger.