# rxnt/json-rules-engine-simplified architecture

> Architecture diagram of the GitHub repository rxnt/json-rules-engine-simplified, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rxnt/json-rules-engine-simplified
- Repository: https://github.com/rxnt/json-rules-engine-simplified

## Overview

This is a small JSON rules-engine library. A caller supplies rules and form data to Engine; Engine optionally validates rules against a schema, evaluates conditions, and resolves matching events. Boolean and field predicates perform the condition checks, while utilities support nested-field access and schema references. The map reflects the sampled runtime sources and README; it does not infer event handling beyond returning matched event objects.

Main entry points: [`src/Engine.js`](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/Engine.js) (Engine), [`src/conditionsMeet.js`](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/conditionsMeet.js) (Condition Evaluator), [`src/validation.js`](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/validation.js) (Rule Validation), [`src/applicableActions.js`](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/applicableActions.js) (Applicable Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Engine API"]
  node_engine["Engine<br/>[Engine.js]"]
  node_entry["Public Export<br/>[index.js]"]
end

subgraph group_evaluation["Rule Evaluation"]
  node_actions["Applicable Actions"]
  node_conditions["Condition Evaluator<br/>[conditionsMeet.js]"]
  node_fieldcheck["Field Predicates<br/>[checkField.js]"]
end

subgraph group_support["Validation And Utilities"]
  node_validation["Rule Validation<br/>[validation.js]"]
  node_utils["Shared Utilities<br/>[utils.js]"]
  node_constants["Boolean Operators<br/>[constants.js]"]
end

node_caller(("Library Caller"))
node_predicate["Predicate Library"]
node_selectn["Nested Field Access"]
node_events["Matched Events"]

node_caller -->|"imports"| node_entry
node_entry -->|"exports"| node_engine
node_caller -->|"supplies rules"| node_engine
node_caller -->|"runs with data"| node_engine
node_engine -->|"validates rules"| node_validation
node_engine -->|"evaluates rules"| node_actions
node_actions -->|"checks conditions"| node_conditions
node_conditions -->|"checks field"| node_fieldcheck
node_conditions -->|"resolves fields"| node_utils
node_fieldcheck -->|"invokes predicates"| node_predicate
node_conditions -->|"uses operators"| node_constants
node_fieldcheck -->|"uses operators"| node_constants
node_validation -->|"uses schema helpers"| node_utils
node_validation -->|"uses operators"| node_constants
node_validation -->|"checks predicate names"| node_predicate
node_utils -->|"selects nested fields"| node_selectn
node_actions -->|"returns matches"| node_events
node_engine -->|"resolves events"| node_caller

click node_engine "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/Engine.js"
click node_entry "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/index.js"
click node_actions "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/applicableActions.js"
click node_conditions "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/conditionsMeet.js"
click node_fieldcheck "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/checkField.js"
click node_validation "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/validation.js"
click node_utils "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/utils.js"
click node_constants "https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/constants.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_engine,node_entry toneBlue
class node_actions,node_conditions,node_fieldcheck toneAmber
class node_validation,node_utils,node_constants toneMint
class node_caller,node_predicate,node_selectn,node_events toneIndigo
```

## Components

### Engine API

- [Engine](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/Engine.js): `src/Engine.js`
- [Public Export](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/index.js): `src/index.js`

### Rule Evaluation

- [Applicable Actions](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/applicableActions.js): `src/applicableActions.js`
- [Condition Evaluator](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/conditionsMeet.js): `src/conditionsMeet.js`
- [Field Predicates](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/checkField.js): `src/checkField.js`

### Validation And Utilities

- [Rule Validation](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/validation.js): `src/validation.js`
- [Shared Utilities](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/utils.js): `src/utils.js`
- [Boolean Operators](https://github.com/rxnt/json-rules-engine-simplified/blob/master/src/constants.js): `src/constants.js`

### Other components

- **Library Caller**
- **Predicate Library**
- **Nested Field Access**
- **Matched Events**

## Connections

- Library Caller → Public Export: imports (evidence: `src/index.js`)
- Public Export → Engine: exports (evidence: `src/index.js`)
- Library Caller → Engine: supplies rules (evidence: `README.md`)
- Library Caller → Engine: runs with data (evidence: `README.md`)
- Engine → Rule Validation: validates rules (evidence: `src/Engine.js`)
- Engine → Applicable Actions: evaluates rules (evidence: `src/Engine.js`)
- Applicable Actions → Condition Evaluator: checks conditions (evidence: `src/applicableActions.js`)
- Condition Evaluator → Field Predicates: checks field (evidence: `src/conditionsMeet.js`)
- Condition Evaluator → Shared Utilities: resolves fields (evidence: `src/conditionsMeet.js`)
- Field Predicates → Predicate Library: invokes predicates (evidence: `src/checkField.js`)
- Condition Evaluator → Boolean Operators: uses operators (evidence: `src/conditionsMeet.js`)
- Field Predicates → Boolean Operators: uses operators (evidence: `src/checkField.js`)
- Rule Validation → Shared Utilities: uses schema helpers (evidence: `src/validation.js`)
- Rule Validation → Boolean Operators: uses operators (evidence: `src/validation.js`)
- Rule Validation → Predicate Library: checks predicate names (evidence: `src/validation.js`)
- Shared Utilities → Nested Field Access: selects nested fields (evidence: `src/utils.js`)
- Applicable Actions → Matched Events: returns matches (evidence: `src/applicableActions.js`)
- Engine → Library Caller: resolves events (evidence: `src/Engine.js`)
