TinyRuleKit is a small Java framework for compiling JSON rule definitions into in-memory executable rules. Rule conditions and actions are resolved once during engine construction, then cached by trigger for fast runtime execution.
The framework is designed for projects that need simple, flexible, and fast rule engines without tying domain logic to a heavy weight rules platform. Rules stay in JSON, while conditions and actions are compiled into normal Java functions.
- JSON rule definitions using enum names directly for triggers, conditions, and actions.
- One-time precompilation of rules into executable conditions and actions.
- Trigger-indexed rule cache for runtime execution over only the relevant rules.
- Trigger guards for trigger-wide early returns before matching rules run.
- Reusable condition definitions with
refand!ref, resolved during build. - Advanced JSON operators including
all,any,not,!type,!all,!any, and restricted static type shorthand. - Practical builder API for configuring resolvers, expressions, and expression security.
- Optional expression layer: static rules do not require MVEL, and projects can plug in another expression engine.
- Expression security defaults with consumer-extensible policies, validators, and safe object views.
- JSON-level required tokens for early capability checks during precompilation.
- Loader format hints for simple arrays or metadata-rich documents.
- JUnit 5 test suite.
tinyrulekit: Maven project for the library artifact.docs: user guide and framework documentation.tinyrulekit/src/main/java/org/tinyrulekit/api: public extension points and rule runtime contracts.tinyrulekit/src/main/java/org/tinyrulekit/core: rule engine entry point.tinyrulekit/src/main/java/org/tinyrulekit/definition: JSON-facing rule definition records.tinyrulekit/src/main/java/org/tinyrulekit/expression: expression compilation and security validation.
Example code currently lives under the test sources as fixtures:
org.tinyrulekit.examples.game.
Start with the published documentation, then follow the guide in order if you are new to the framework.
A plain Markdown copy is available under local-docs for local reading.
Download the current release from TinyRuleKit v1.0.0.
<dependency>
<groupId>org.tinyrulekit</groupId>
<artifactId>tinyrulekit</artifactId>
<version>1.0.0</version>
</dependency>TinyRuleKit is consumed as a JAR. Maven and Gradle users should add the library dependency and let the build tool resolve transitive dependencies.
Applications that load JARs manually must place tinyrulekit-1.0.0.jar,
and gson-2.10.1.jar on the classpath.
MVEL is optional. Add org.mvel:mvel2 only when using the default expression
engine. Static rules and custom expression engines do not require it.
cd tinyrulekit
mvn clean testThe repository includes a local helper script, build-jar.bat, for generating
the library JAR from source during development. It is intentionally ignored by
Git.
This project is licensed under the MIT License.
Author: Jairo Linares.