The Rule Enginer is a web application that allows users to create rules, evaluate them against provided data, and manage existing rules. This application is built using HTML, CSS, and JavaScript for the frontend, with a Spring Boot backend that handles API requests.
- Create new rules with a name and a logical expression.
- Select existing rules from a dropdown menu.
- Input user data (age, salary, department, experience) for evaluation.
- Evaluate selected rules against the provided data.
- Display results of evaluations in real-time.
- Frontend: HTML, CSS, JavaScript
- Backend: Spring Boot
- Database: MySql
- API: RESTful services
- Java 11 or higher
- Maven
- A web browser
-
Clone the Repository:
git clone https://github.com/Akhilmak/Rule-Engine.git cd rule-engine
-
Backend Setup:
- Navigate to the backend directory:
cd rule-engine
- Build the Spring Boot application:
mvn clean install
- Run the Spring Boot application:
mvn spring-boot:run
- Navigate to the backend directory:
-
Configure Database Connection:
- In your application.properties file, configure the database connection:
spring.datasource.url=jdbc:mysql://localhost:3306/zeotap spring.datasource.username=your_username spring.datasource.password=your_password spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true
Do not forget to create the database before starting the application.
- The frontend can be accessed at: http://localhost:8080
- Endpoint:
/api/rules/create
- Method:
POST
- Request Body:
{ "ruleName": "Your Rule Name", "ruleString": "(age > 30 AND department = 'Sales')" }
- Response: Returns the created rule Abstract Syntax Tree.
- Endpoint:
/api/rules
- Method:
GET
- Response: Returns a List of all rules with their IDs ,names and Rule Strings.
- Endpoint:
/api/rule/{id}
- Method:
GET
- Response: Returns the rule by it's id.
- Endpoint:
/api/rules/evaluate
- Method:
POST
- Request Body:
{ "ruleId": 1, "data": { "age": 35, "salary": 60000, "department": "Sales", "experience": 5 } }
- Response: Returns a boolean indicating if the evaluation was successful.
- Open the application in your web browser at http://localhost:8080.
- Create a new rule by entering a name and a logical expression.
- Select an existing rule from the dropdown menu.
- Enter user data for evaluation.
- Click the submit button to see the evaluation result.
The application includes basic error handling for both frontend validation and backend processing. If any errors occur during rule creation or evaluation, appropriate messages will be displayed to the user.