A simple 3-tier rule engine application(Simple UI, API and Backend, Data) to determine user eligibility based on attributes like age, department, income, spend etc.The system uses Abstract Syntax Tree (AST) to represent conditional rules and allow for dynamic creation,combination, and modification of these rules.
- Fetch and display rules from the server.
- Select multiple rules for combining.
- Evaluate selected rules against user data.
- Dynamic user input for age, department, salary, and experience.
- User-friendly UI with loading indicators and error handling.
- Frontend: React, Axios
- Backend: Node.js, Express.js
- Database: MongoDB
- Development Tools: Git, npm
Before you begin, ensure you have the following installed:
- Node.js (version 14 or above)
- npm (Node Package Manager, usually comes with Node.js)
- MongoDB (for database management)
-
Open your terminal.
-
Clone the repository using the following command:
git clone https://github.com/Gayatrisin123/Rule-Engine.git
cd rule-engine
cd server
npm install
cd client
npm install
Create a .env file in the backend directory.
PORT=5000 MONGODB_URI=
Replace with your actual MongoDB connection string.
Start the Backend Server
cd backend
npm start or npm run dev
The backend server will run on http://localhost:5000.
cd frontend
npm start
The frontend will run on http://localhost:3000.
Open your browser and navigate to http://localhost:3000.
You will see a list of rules fetched from the backend.
Select the rules you want to combine and evaluate.
Input user data in the provided fields (age, department, salary, experience).
Click "Evaluate" to check if the user data meets the criteria of the selected rule(s).
Click "Combine Selected Rules" to combine your selections.
Fetch All Rules: GET /api/rules
Combine Selected Rules: POST /api/rules/combine
Evaluate a Rule: POST /api/rules/evaluate
Refer to the API documentation for more details on each endpoint.
create a rule by enterinh any rule inside the create rule inbox
now click on create rule
now a alert will be pop up
copy the rule id for future reference
now the evaluation part
if you have rule id then write it in the rule id section
and fill all other details
and click on evaluate