MRules is shipped with various demo projects, packaged under the form of standalone maven projects, containing JUnit tests. They can all be downloaded via the Downloads page.

A licence file is mandatory to execute demos (a free trial licence can be requested with the contact form).

You will find here a summary and then a quick description of all available demonstrations.


Here is the list af all demo projects. Each one is detailled later.

  • E-Commerce site example: computes customer benefits depending on commands history.
  • Transportation fees computation example: Determines the computation method for calculating the reimbursement of employees transport costs, depending on different criterias (place, transportation mode, distance, etc …)
  • Classroom example: Computes students results (averages, accepted or no, mention, etc …)
  • VAT computation example: Find VAT to apply on a product depending on different criterias.
  • “Drools Fight”: Demo used for our comparative benchmark between MRules and Drools.
  • Spring Integration: Demo illustrating MRules integration in a Spring based project.
  • Advanced functionalities examples: Some examples of advanced usage, on no concrete cases.
  • Solving Sudoku grids: Sudoku Solver including comparison with Drools.
  • JSon Grammar Modelization: Configure the Grammar Engine to parse JSon Content.
  • JSon Web Editor: Extend the generic Web Editor to edit JSon content with auto-completion and syntax validation.

Business Rule Engine

The demonstrations below concern different use cases of the business rules engine.


We are creating here a commercial web sites, selling various products to customers. MRules is used to finalize the commands, performing the following steps:

  • Computing customer level, depending on command history:
    • GOLD if more than 1500 CUR in history.
    • SILVER if more than 1000 CUR or at least one command over 500 CUR in history.
    • STANDARD in other cases.
  • Computing VAT: 5.5% for articles of type FOOD, 20% for others.
  • Computing commands amounts.
  • Computing discounts:
    • Checking discounts validity (if not valid, raise an error)
    • Applying discounts
    • Computing if special discount is applyable: if at least 2 of [deliveryMode: ECONOMIC | deliveryCity: PARIS | level: GOLD]: 15 CUR discount is applied.
  • Computing final commands amounts.
  • Computing discounts that the customer earns with this command :
    • Final command amount > 500: 10% future discount
    • 5th command: 5% future discount

The JUnit test will do the following :

  • Build different types of baskets to test all cases
  • Perform all the operations listed above with Java code
  • Launch MRules to perform the same operations and check results
  • Compare execution times
  • Test that MRules configuration factory reads and writes the configuration correctly

Transportation fees

This is here a very simplified case of a company using MRules to compute fees which may be paid to employees to compensate transportation cost and time.

Depending on:

  • The town where the employee works (PARIS, LONDON, …)
  • The transportation mode (BICYCLE, CAR, BUS, …)
  • The amount of time spent travelling each days

The following data will be computed:

  • Will there be a payment ?
  • If so, what is the payment mode, between Compensation and Flat Rate ?
  • If Flat Rate, what is the fixed amount which will be paid ?

Three possible ways to write configurations are provided, in order to show differences in terms of complexity and execution time.

The JUnit test will do the following:

  • Build different cases
  • Launch MRules on all cases and check the results, for all three configurations
  • Benchmark execution on all three configurations
  • Test that MRules configuration factory reads and writes all three configurations correctly


MRules is used here to compute final results of all students of a classroom. Provided all marks obtained for all tests over the year, and the coefficient attributed to each test, the following output will be computed:

  • Student data:
    • The average mark
    • Is the student admitted ? If so, with a mention ? If not, is it possible to retry ?
  • Classroom data:
    • The classroom average mark
    • The number of admitted / rejected

Two possible configurations are provided, with slight differences on the way rules are written.

The JUnit test will do the following:

  • Build the test classroom input data
  • Perform all the operations listed above with Java code
  • Launch MRules to perform the same operations and check results
  • Compare execution times
  • Test that MRules configuration factory reads and writes the configuration correctly

VAT computation

MRules is used here to compute VAT rate ans maximum  to be applied on commercial products, depending on some input parameters:

  • Region (FRANCE, SPAIN, …)
  • The customer type (Company, Association, Person)
  • The product type (Food, Book, …)
  • The commande date

These rules are applied, in this order:

  • If France and product type is Book, since 2016-01-01: VAT 5.5% and 3% max discount.
  • If France and product type is Book: VAT 5.5% and 5% max discount.
  • If Association: VAT 5.5%.
  • If product type is Book: VAT 10%.
  • If product type is Food: VAT 5.5% and 0% max discount.
  • If Company and product type is Electronics: VAT 10% and 15% max discount.
  • If Person and product type is in House or Music: VAT 10% and 25% max discount.
  • In any other case: VAT 20%.

This demo is interesting because rules are written using the simple grammar, and also because it illustrates the behaviour of stopping execution after first validated rule.

The JUnit test will do the following:

  • Build some test data
  • Launch MRules to perform the operations and check results
  • Benchmark execution
  • Test that MRules configuration factory reads and writes the configuration correctly


Even if MRules has not been created in the purpose of solving this type of problems, but is more dedicated to business rules, the power of the library and its simplicity allow to easily use it to do so.

We use here the very basic backtracking algorithm, which is more or less a brute force way to solve all types of grid, even empty ones 🙂

This demo will show you:

  • Advanced usage of functions
  • How to iterate on number ranges
  • How  to return a value from the rule set to the calling Java program

We also have included a Java solver, and one provided by Drools examples, in order to compare how rules are written, and how fast they are executed, knowing that this solver is based on an algorithm more complicated than the back tracking.

The JUnit test will do the following:

  • Build different test grids
  • Solve them with the Java solver
  • Solve them with the Drools solver
  • Solve them with the MRules solver
  • Check that grids are solved if they can be
  • Compare execution times
  • Test that MRules configuration factory reads and writes the configuration correctly

Drools Fight

This demo was realised for our benchmark between Drools and MRules. Everything is described with details here.

Spring Integration

Demo illustrating MRules integration in a Spring based project. You will see in this demo how to inject a rule engine instance using either Spring Annotations or the good old Spring XML context.


This last demo project just illustrates some advance features, but does not simulate a functional case.

You will see here how to:

  •  Deactivate part of the optimization process for a specific rule set
  • Create a sublist by selecting items in a main list if conditions are verified
  • Round several numbers
  • Return the 3 first characters of a String, or “N/A”
  • Run a system command and test result. If incorrect, raise an error.
  • Test if input bean has a property (i.e. if the field exists in the Java class)
  • Add 21 year, 1 month and remove 1 day to current date, set a variable with the result and print it. Then, compute the difference in year between current date and the variable. If not 21: raise an error.

Grammar Engine

The following demonstrations illustrate the usage of the functional grammar engine library.

JSon Grammar Modelization

This demonstration shows how to use the MRules Grammar Engine to modelize your own grammar. Here, in few lines of configuration, we created a JSON parser.

By implementing two different possible standards (RFC-4627 et ECMA-404), we demonstrate how to mutualize configuration and how to efficiently use the product.

Also, the internationalization of a grammar and the usage of the documentation generator are presented.

JSON Editor Demo

Based on the JSON grammar created in the previous demonstration, this demonstration extends and specializes the generic Web editor in order to include the 4 variants of JSon grammars (2 standards * 2 languages) and to obtain a JSon text editor.

By launching the Springboot standalone version, you will be able, directly in your browser, to:

  • Edit JSon content with an efficient and intuitive auto-completion and with syntax validation when typing.
  • Change variant and therefore check that auto-completion and syntax validation change according to the selected standard and language.
  • Generate the automatic documentation via a link.


The Sodoku Solver Demonstration proposes a configuration using the natural language syntax offered by an extension of the rule engine engine based on the grammar engine library.