I Built a Lightweight Rule Engine for JS, C#, and Dart — Here's How It Works
Source: Dev.to

The Problem
I kept running into the same pattern across different projects: events happen, some conditions need to be checked, and based on those conditions, certain actions should execute. Authentication flows, game mechanics, IoT automation, e‑commerce logic — they all follow this pattern.
Most rule engines I found were either too heavy for what I needed or locked into a single language. So I built my own.
What is ARE?
ARE (Action Rule Event) is a lightweight, dependency‑free rule engine. The concept is straightforward:
- Events – Things that happen (user logs in, temperature changes, order placed)
- Rules – Conditions to evaluate (if temperature > 30, if order total > 100)
- Actions – What to execute when conditions are met (send notification, apply discount)
The pipeline: Event → Middleware → Condition Evaluation → Rule Matching → Action Execution
Multi‑Platform
I wanted this to work wherever I work, so ARE is available on three platforms:
- JavaScript/TypeScript → npm
- C# / .NET → NuGet
- Dart / Flutter → pub.dev
Same API design across all three. If you know one, you know them all.
The Playground
Documentation is fine, but I wanted people to actually feel how the engine works. So I built an interactive playground with three real‑world scenarios:
- 🎮 RPG Game – Combat rules, loot drops, zone effects, boss battles
- 🏠 Smart Home – Sensor events, schedules, energy management, security
- 🛒 E‑Commerce – Order processing, inventory alerts, customer rewards
Each scenario comes with pre‑configured events, rules, and actions. You fire an event and watch the engine process it in real time.
🔗 Try it: https://are-playground.netlify.app
Features I’m Proud Of
- Rule Flow Diagram – An animated pipeline showing each stage of processing
- Rule Debugger – Expand any rule to see a condition‑by‑condition breakdown (field checked, operator used, expected vs. actual, pass/fail)
- Relationship Graph – Visual map of how events connect to rules and rules connect to actions; hover to highlight connections
- Interactive Tutorial – Guided tour for first‑time visitors that walks through every panel
- Full CRUD – Add, edit, or delete events, rules, and actions on the fly; create your own scenarios without writing code
- Code Sandbox – Write your own ARE logic from scratch with a Monaco editor
Tech Stack
- React 19 + TypeScript
- Vite
- Tailwind CSS v4
- Zustand for state management
- Framer Motion for animations
- i18next (English + Turkish)
What’s Next
I’m looking for feedback. If you try the playground, I’d love to know:
- Is the event → rule → action concept clear?
- What use cases would you apply this to?
- What’s missing that would make this useful for your projects?
GitHub: https://github.com/BeratARPA/ARE
Thanks for reading. Happy to answer any questions.