Introduction
The Policy system is a rule engine that evaluates human-readable business rules against structured data. Instead of writing validation logic in code, you write policies in a natural-language DSL.
The Three Tiers
1. Engine
The engine is the core evaluator. It accepts a rule (policy text) and data (JSON), evaluates the rule against the data, and returns a result.
POST https://api.policy.keloran.dev/run{ "rule": "A **Person** gets approved if __age__ of **Person** is greater than 18.", "data": { "Person": { "age": 25 } }}2. Orchestrator
The orchestrator manages named policies. You create, version, and organize policies into groups. When you want to evaluate data, you reference a policy by name instead of sending the full rule text.
3. Dashboard
A web UI for creating and testing policies visually. It connects to the orchestrator and engine under the hood.
Why Use Policy DSL?
- Business rules change frequently — update a policy without redeploying code
- Stakeholder transparency — non-developers can read and verify the rules
- Audit trail — policies are versioned and traceable
- Separation of concerns — logic lives outside your application code
- Testable — every rule can be tested independently with sample data
How Rules Work
A policy rule has this structure:
A **Selector** outcome if condition [and/or condition]... .- Selector — the JSON object being evaluated (e.g.,
**Person**) - Outcome — what happens if all conditions pass (e.g.,
gets approved) - Conditions — checks against properties of the data
- Period — every rule ends with
.
The engine walks each condition, evaluates it against the data, and returns true (pass) or false (fail).