Projects

Pricing Generator

Github Link
Code Link

Project Overview

The project is structured as a multi-module Maven project aimed at providing a dynamic pricing engine.

https://avid-bells-production.up.railway.app/

It consists of three main modules:

  • pricing-common: This module includes shared entities, utilities, and configurations that are common across the project, such as domain models (e.g., Customer, Pricing, Rule) and possibly shared utilities for data manipulation or communication between modules.

  • pricing-server: This module is responsible for exposing the functionalities of the pricing engine as a web service. It likely includes controllers for handling HTTP requests, services for business logic, and integration with the pricing-engine for rule evaluation.

  • pricing-engine: This module contains the core logic for evaluating pricing rules. It uses DSL (Domain-Specific Language) parsing and MVEL (MVFLEX Expression Language) to dynamically evaluate rules based on input data.

MVEL and DSL Parser

  • MVEL (MVFLEX Expression Language) is a powerful expression language for Java-based applications. It allows for the dynamic execution of scripts, expressions, and templates. In the context of this project, MVEL is used to evaluate conditions and actions defined within pricing rules. MVEL provides flexibility and dynamism, enabling the pricing engine to assess complex logic at runtime without recompiling code.

  • DSL Parser: The Domain-Specific Language (DSL) parser is a component designed to interpret and transform custom-defined language expressions into a format that can be understood and processed by the system. In this project, the DSL parser likely translates domain-specific expressions into MVEL expressions or directly executable Java code. This allows for the definition of pricing rules in a more readable and intuitive format, which can then be dynamically parsed and executed by the engine.

Multi-Maven Project Support

This project is structured as a multi-module Maven project, which is a common pattern for separating concerns and promoting modularity in Java applications. Maven facilitates this by allowing a parent project (pricing-policy-generator) to include submodules (pricing-common, pricing-server, pricing-engine). Each module can independently manage its dependencies, build configurations, and artifacts while sharing common configurations from the parent POM (Project Object Model) file.

Rule Evaluation Process

The rule evaluation process in the pricing engine involves iterating over each rule and dynamically evaluating its relevance based on the input data. Here's a simplified overview:

  1. DSL Parsing: For each rule, the DSL expressions (if present) are first parsed and resolved. This step transforms custom DSL syntax into executable logic or MVEL expressions. The DSL parser interprets domain-specific expressions and converts them into a format that can be processed by the system, preparing the rule for evaluation.

  2. MVEL Evaluation: Once the DSL part of a rule has been resolved, the engine uses MVEL to evaluate the rule's condition against the current context (e.g., customer data, pricing context). If the condition evaluates to true, the engine proceeds to execute the rule's action, also defined in MVEL. This could involve calculating a price, applying a discount, or setting certain flags.

  3. Loop Over Each Rule: The engine loops over each rule in the defined order, performing the above steps (DSL parsing followed by MVEL evaluation) for each. The order of rule evaluation can be crucial, as it may affect the outcome (e.g., some rules might override others).

Summary

This multi-module Maven project leverages the flexibility of MVEL for dynamic rule evaluation and introduces a DSL parser for easier rule definition. By structuring the project into common, server, and engine modules, it separates concerns and promotes reuse of common logic. The pricing engine dynamically evaluates each rule, transforming DSL expressions and applying MVEL logic to determine the appropriate pricing adjustments based on the inputs provided.

Take me there
Java
Spring Boot
MVEL
Pricing

My Tech Stack

React

React

NextJS

NextJS

TypeScript

TypeScript

GSAP

GSAP

HTML5

HTML5

CSS3

CSS3

GraphQL

GraphQL

Redux

Redux

Vue.js

Vue.js