# scs891/easy-rules architecture

> Architecture diagram of the GitHub repository scs891/easy-rules, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/scs891/easy-rules
- Repository: https://github.com/scs891/easy-rules

## Overview

##### Project Type and Purpose
- The project is a Java library that implements a rules engine – it provides abstractions and APIs for defining, grouping, and firing business rules.
- It supports various programming models (annotation-based, programmatic via a fluent API, expression language-based) and allows composite rules.
- The available modules also demonstrate integration with different expression languages (MVEL, SpEL, JEXL) and include tutorials as well as a Maven archetype for scaffolding new rule-driven applications.

##### File Structure
- Notice that the project is multi-module with several key directories:
- easy‑rules‑core: Contains the core abstractions and rules engine implementation (such as Rule, RulesEngine, Facts, and built‑in APIs).
- easy‑rules‑archetype: A Maven archetype for quickly generating starter projects that use Easy Rules.
- easy‑rules‑jexl, easy‑rules‑mvel, easy‑rules‑spel: These modules provide support for using different expression languages to define conditions and actions.
- easy‑rules‑support: Contains supporting code for composite rules, rule definitions (including JSON and YAML readers), and other utility classes.
- easy‑rules‑tutorials: Example projects and tutorials demonstrating the usage of Easy Rules in various contexts.
- You also have configuration files (pom.xml in each module, GitHub workflows) that manage builds and dependencies.

a. Main Components:
- Core Engine: Represents the easy‑rules‑core module, hosting the fundamental classes like Rule, RulesEngine, Condition, Action, and Facts.
- Expression Language Integrators: These are the easy‑rules‑jexl, easy‑rules‑mvel, and easy‑rules‑spel modules that adapt the core engine to work with different expression languages.
- Support Utilities: The easy‑rules‑support module, which offers composite rule handler classes, abstraction for rule definitions, and resource readers for rule descriptors.
- Project Starter & Tutorials: The easy‑rules‑archetype module and easy‑rules‑tutorials module, which provide sample projects and usage scenarios.

b. Relationships and Interactions:
- The core engine is at the center of the architecture. All other modules extend or integrate with the core API.
- The expression modules depend on the core engine to provide rule functionality while implementing their own factories and rule classes (like MVELRule, SpELRule, and JexlRule).
- The support module wraps the core engine with additional capabilities (like composite rule grouping and reading external rule definitions in JSON/YAML).
- The archetype and tutorial modules depend on the core engine and demonstrate its usage.

c. Architectural Patterns and Design Principles:
- Modularity: Each module handles a specific aspect of the rules engine (core functionality, expression interpretation, supporting composite rules, and tutorials).
- Abstraction and Extensibility: The core engine provides a generic API (POJO based, annotation driven) that is extended via different modules for expression languages.
- Separation of Concerns: There is a clear separation between the rule definitions, the engine that fires rules, and the integration with various expression languages and composite behaviors.
- Plugin-like Architecture: Additional features (support for multiple expression languages or composite rules) are implemented as separate modules that “plug in” to the core engine.

d. Relevant Technologies, Frameworks, or Libraries:
- Java (the base language for the library).
- Maven for build and dependency management (each module includes its pom.xml).
- Expression Languages: MVEL, SpEL, and JEXL, as supported by their respective modules.
- Testing frameworks implied by the test directories (JUnit or similar) in each module.
- GitHub workflows for CI/CD (see .github/workflows/build.yml).

- At the center, place “Easy Rules Core” with its main responsibilities:
- Rule, RulesEngine, Facts
- Annotation-based and programmatic API for defining rules.
- Surround this core with:
- “Expression Language Modules”: include nodes for MVEL, SpEL, and JEXL modules that implement their own Rule types and factories.
- “Support Module”: for composite rules and rule definition readers (JSON/YAML).
- “Archetype & Tutorials”: for sample usage and new project scaffolding.
- Optionally, include a CI/CD node showing GitHub workflows which integrate with this multi-module Maven project.

##### Final Advice
- Be very detailed: show every dependency and how the modules interact with one another.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CI_CD["CI/CD Pipeline"]:::ci
    ARCH["Project Archetype (Starter)"]:::usage
    TUT["Tutorials & Usage Examples"]:::usage
    JEXL["JEXL Integration Module"]:::integration
    MVEL["MVEL Integration Module"]:::integration
    SPEL["SpEL Integration Module"]:::integration
    SUPPORT["Support Utilities (Composite Rules & Rule Definition Readers)"]:::support
    CORE["Easy Rules Core – API and Engine"]:::core

    %% CI/CD Pipeline triggers all modules
    CI_CD --> ARCH
    CI_CD --> TUT
    CI_CD --> JEXL
    CI_CD --> MVEL
    CI_CD --> SPEL
    CI_CD --> SUPPORT

    %% All modules depend on the Core Engine
    ARCH --> CORE
    TUT --> CORE
    JEXL --> CORE
    MVEL --> CORE
    SPEL --> CORE
    SUPPORT --> CORE

    %% Click Events
    click CI_CD "https://github.com/scs891/easy-rules/blob/master/.github/workflows/build.yml"
    click ARCH "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐archetype/"
    click TUT "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐tutorials/"
    click JEXL "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐jexl/"
    click MVEL "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐mvel/"
    click SPEL "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐spel/"
    click SUPPORT "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐support/"
    click CORE "https://github.com/scs891/easy-rules/tree/master/easy‐rules‐core/"

    %% Styles
    classDef ci fill:#ffcccc,stroke:#ff6666,stroke-width:2px;
    classDef integration fill:#cce5ff,stroke:#3399ff,stroke-width:2px;
    classDef support fill:#ffffcc,stroke:#cccc33,stroke-width:2px;
    classDef usage fill:#e6e6fa,stroke:#9370db,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#33cc33,stroke-width:2px;
```
