{"id":18431097,"url":"https://github.com/sandesh300/rule-engine-application","last_synced_at":"2026-05-04T01:32:30.361Z","repository":{"id":259425484,"uuid":"874293227","full_name":"sandesh300/Rule-Engine-Application","owner":"sandesh300","description":"rule engine application using AST","archived":false,"fork":false,"pushed_at":"2024-10-25T07:45:45.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T00:50:03.654Z","etag":null,"topics":["java","postgresql","react","spring-boot"],"latest_commit_sha":null,"homepage":"https://rule-engine-bd7555.netlify.app/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandesh300.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T15:13:53.000Z","updated_at":"2025-02-07T17:00:37.000Z","dependencies_parsed_at":"2024-10-25T09:16:42.225Z","dependency_job_id":"6ca725a4-8d71-4bcd-b240-3a1a6acc4bfa","html_url":"https://github.com/sandesh300/Rule-Engine-Application","commit_stats":null,"previous_names":["sandesh300/rule-engine-application"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sandesh300/Rule-Engine-Application","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandesh300%2FRule-Engine-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandesh300%2FRule-Engine-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandesh300%2FRule-Engine-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandesh300%2FRule-Engine-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandesh300","download_url":"https://codeload.github.com/sandesh300/Rule-Engine-Application/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandesh300%2FRule-Engine-Application/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32591598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","postgresql","react","spring-boot"],"created_at":"2024-11-06T05:23:31.409Z","updated_at":"2026-05-04T01:32:30.343Z","avatar_url":"https://github.com/sandesh300.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rule Engine with Abstract Syntax Tree\n\nA rule engine application that uses Abstract Syntax Tree (AST) to create, evaluate, and manage complex business rules. The system supports dynamic rule creation, combination, and modification with a focus on user attribute evaluation.\n\n---\n### Application Deployment Link - https://rule-engine-bd7555.netlify.app\n\n### Deployment\n\nThe application has been deployed with the following technologies and services:\n\n1. **Backend (Spring Boot):**\n   - Deployed to **Docker Hub** as a containerized application.\n   - [Docker Hub Repository URL](sandesh030/rule-engine-deployment)\n\n2. **Backend Docker Image:**\n   - Docker image deployed to **Render.com** for hosting the backend services.\n   - [Render Deployment URL](https://rule-engine-deployment-latest.onrender.com)\n\n3. **Database:**\n   - PostgreSQL database deployed on **Neon Postgres Cloud Database** for efficient and scalable data management.\n   - [Neon Postgres Cloud URL](https://console.neon.tech/app/projects/solitary-forest-16973334/branches/br-spring-butterfly-a8e2xdam/tables)\n\n4. **Frontend:**\n   - React application deployed to **Netlify** for seamless frontend hosting.\n   - [Frontend Deployment URL](https://rule-engine-bd7555.netlify.app/)\n\n---\n\n## 🚀 Features\n\n- Create complex rules using logical operators (AND/OR)\n- Evaluate user data against defined rules\n- Combine multiple rules into a single rule\n- Modify existing rules\n- Visualize rules as Abstract Syntax Trees\n- RESTful API for rule management\n- React-based UI for rule visualization and management\n\n## 🛠 Technology Stack\n\n### Backend\n- Java 17\n- Spring Boot 3.1.0\n- PostgreSQL 15\n- JUnit 5\n- Mockito\n- Spring Data JPA\n\n### Frontend\n- React 18\n- TypeScript\n- Tailwind CSS\n- Axios\n- React Query\n- React Flow (for AST visualization)\n\n## 📋 Prerequisites\n\n- Java 17 or higher\n- Node.js 18 or higher\n- PostgreSQL 15\n- Maven 3.8+\n\n## 🏗 Project Structure\n\n```\nrule-engine/\n├── backend/\n│   ├── src/\n│   │   ├── main/\n│   │   │   ├── java/com/ruleengine/\n│   │   │   │   ├── controller/\n│   │   │   │   │   ├── RuleController.java\n│   │   │   │   ├── service/\n│   │   │   │   │   ├── RuleServices.java\n│   │   │   │   ├── model/\n│   │   │   │   │   ├── Node.java\n│   │   │   │   │   ├── Rule.java\n│   │   │   │   ├── repository/\n│   │   │   │   │   ├── RuleRepository.java\n│   │   │   │   └── exception/\n│   │   │   │       ├── GlobalHandlerException.java\n│   │   │   │       ├── CustomException.java\n│   │   │   └── resources/\n│   │   │        ├── application.properties\n│   │   └── test/\n│   │       ├── RuleServiceTest.java\n│   └── pom.xml\n├── frontend/\n│   ├── src/\n│   │   ├── components/\n│   │         ├── CombineRule.js\n│   │         ├── CreateRule.js\n│   │         ├── EvaluateRule.js\n│   │         ├── Home.js\n│   │         ├── ModifyRule.js\n│   │         ├── Navbar.js\n│   │  \n│   ├── package.json\n│   └── tsconfig.json\n└── README.md\n```\n\n## 🔧 Installation \u0026 Setup\n\n### Backend Setup\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/sandesh300/Rule-Engine-Application.git\ncd rule-engine\n```\n\n2. Configure PostgreSQL:\n```properties\n# application.properties\nspring.datasource.url=jdbc:postgresql://localhost:5432/rule_engine\nspring.datasource.username=your_username\nspring.datasource.password=your_password\nspring.datasource.driver-class-name=org.postgresql.Driver\n\nspring.jpa.database=postgresql\nspring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect\nspring.jpa.hibernate.ddl-auto=update\nspring.jpa.properties.hibernate.format_sql=true\nspring.jpa.show-sql=false\n```\n\n3. Build and run the application:\n```bash\nmvn clean install\nmvn spring-boot:run\n```\n\n### Frontend Setup\n\n1. Navigate to the frontend directory:\n```bash\ncd rule-engine-ui\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Start the development server:\n```bash\nnpm start\n```\n\n## 🎯 API Endpoints\n\n### Rule Management\n\n```\nPOST   /api/rules/create          - Create a new rule\nGET    /api/rules/getRules        - Get all rules\nPUT    /api/rules/modify          - Modify existing rule\nDELETE /api/rules/delete          - Delete a rule\nPOST   /api/rules/evaluate        - Evaluate data against a rule\nPOST   /api/rules/combine         - Combine multiple rules\n```\n\n### Backend REST APIs Documentation Link\n[Backend REST APIs Documentation](https://walnut-wrist-9da.notion.site/Rule-Engine-with-AST-129a272bc3e580c0ac0cfc7f01e5c221)\n\n## 🎨 Design Choices\n\n### Abstract Syntax Tree (AST)\n- Nodes represent operators (AND/OR) and operands (conditions)\n- Binary tree structure for efficient rule evaluation\n- Node structure:\n  ```java\n  class Node {\n      String type;        // \"operator\" or \"operand\"\n      Node left;          // Left child\n      Node right;         // Right child\n      String value;       // Operator or condition value\n  }\n  ```\n\n### Database Schema\n```sql\nCREATE TABLE rules (\n    id BIGSERIAL PRIMARY KEY,\n    rule_name VARCHAR(255) NOT NULL,\n    root_node JSONB NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n```\n\n### Rule Combination Strategy\n- AND operator for combining multiple rules\n- Preserves individual rule integrity\n- Optimizes for evaluation performance\n\n## 🧪 Testing\n\n### Test Coverage\n- Unit tests for services and controllers\n- Integration tests for API endpoints\n- Frontend component tests\n- End-to-end testing for critical flows\n\n### Test Cases Documentation Link\n[Test Cases Documentation](https://walnut-wrist-9da.notion.site/Rule-Engine-using-AST-Test-Cases-129a272bc3e580a082e9c45cc99ccc51)\n\n### Running Tests\n\nBackend:\n```bash\ncd backend\nmvn test\n```\n\nFrontend:\n```bash\ncd frontend\nnpm test\n```\n\n## ⚠️ Validation \u0026 Error Handling\n\n### Rule String Validation\n- Syntax validation for rule strings\n- Parentheses balance checking\n- Operator validation\n- Data type compatibility checks\n\n### User Data Validation\n- Required field validation\n- Data type validation\n- Value range validation\n- Department catalog validation\n\n### Error Response Format\n```json\n{\n    \"error\": \"Error message\",\n    \"details\": \"Additional error details\",\n    \"timestamp\": \"2024-10-24T10:00:00Z\"\n}\n```\n\n### Validation Error Handling Link\n[Validation Error Handling](https://walnut-wrist-9da.notion.site/Rule-Engine-using-AST-Validation-Error-Handling-129a272bc3e580bb9a1acd849dee8eb7)\n\n## 📦 Dependencies\n\n### Backend Dependencies\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-web\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-data-jpa\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.postgresql\u003c/groupId\u003e\n        \u003cartifactId\u003epostgresql\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.projectlombok\u003c/groupId\u003e\n        \u003cartifactId\u003elombok\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-test\u003c/artifactId\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.mockito\u003c/groupId\u003e\n        \u003cartifactId\u003emockito-core\u003c/artifactId\u003e\n        \u003cversion\u003e5.11.0\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.junit.jupiter\u003c/groupId\u003e\n        \u003cartifactId\u003ejunit-jupiter-api\u003c/artifactId\u003e\n        \u003cversion\u003e5.10.3\u003c/version\u003e \u003c!-- Or any latest stable version --\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Frontend Dependencies\n```json\n{\n    \"dependencies\": {\n        \"react\": \"^18.2.0\",\n        \"react-dom\": \"^18.2.0\",\n        \"axios\": \"^1.6.0\",\n        \"react-query\": \"^3.39.3\",\n        \"reactflow\": \"^11.10.1\",\n        \"tailwindcss\": \"^3.3.5\"\n    }\n}\n```\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandesh300%2Frule-engine-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandesh300%2Frule-engine-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandesh300%2Frule-engine-application/lists"}