Zero-Deploy Logic
Store rules as standard JSON in PostgreSQL, MongoDB, or Redis. Update business logic live without rebuilding or redeploying code.
{
"where": "cart.total",
"gte": 100
}Stored in Postgres, Mongo, or Redis. Updated at runtime without redeploying servers.
eval()High-throughput tree traversal with monotonic nanosecond execution.
One rule definition powers memory checks, DB queries, and natural-language triage.
Hardcoded if/else chains tie business rule updates to software release cycles. A routine change to discount tiers, fraud score thresholds, or access policies requires a code commit, pull request review, and server redeployment.
Qarar treats business rules as portable, technology-agnostic JSON trees. Store rules in PostgreSQL, MongoDB, or Redis, and evaluate them dynamically at runtime:
WHERE clause or MongoDB query filter.Every Qarar rule is a portable JSON AST that you can store in any database (PostgreSQL jsonb, MongoDB, Redis) and evaluate anywhere — or build in TypeScript with rule():
{ "id": "loyalty-discount-v1", "name": "Loyalty Checkout Discount", "version": "1", "root": { "type": "and", "conditions": [ { "type": "in", "left": { "type": "field", "path": "user.tier" }, "right": { "type": "array", "values": [ { "type": "string", "value": "gold" }, { "type": "string", "value": "vip" } ] } }, { "type": "gte", "left": { "type": "field", "path": "cart.total" }, "right": { "type": "number", "value": 100 } } ] }}import { rule } from "@qarar/sdk";
const loyaltyDiscount = rule("Loyalty Checkout Discount") .id("loyalty-discount-v1") .where("user.tier").in(["gold", "vip"]) .and("cart.total").gte(100) .build();Load the JSON rule from your database (or pass the built rule) and evaluate it against incoming data:
import { checkRule } from "@qarar/sdk";
// Load JSON rule from DB / API / cache, then evaluateconst { result, reasons } = checkRule(loyaltyDiscount, { user: { tier: "bronze" }, cart: { total: 150 }});
console.log(result); // falseconsole.log(reasons); // ['user.tier: "bronze" is not in [gold, vip]']Zero-Deploy Logic
Store rules as standard JSON in PostgreSQL, MongoDB, or Redis. Update business logic live without rebuilding or redeploying code.
Database Pushdown
Compile the same rule AST into parameterized SQL WHERE clauses or MongoDB filter objects to filter data directly in the database.
Audit Explanations
Generate human-readable failure explanations automatically. Know exactly why an order was flagged or a user was denied without log grepping.
Sandboxed Evaluation
Safe evaluation with zero eval() and guarded field lookups that prevent prototype pollution. Guaranteed deterministic termination.