Logic-to-Decision Engine

Turn complex logicinto clear decisions

Bantai evaluates real-world inputs into deterministic, explainable allow/deny decisions with full TypeScript safety.

Real-world Inputs
User Context
{ role: "editor", age: 25 }
Risk Signals
{ kyc: true, score: 0.9 }
LLM Prompt
{ risk: "low", size: 120 }
Next.jsNode.jsWorkers
BantaiBANTAI
Context (Zod)
Validated
RulesComposable
Policyv1.0.0
StrategyPreemptive
Evaluating...
Explainable Decision
ALLOW
Status: OK
User is of legal age
DENY
Violation: age-verification
CORE_PILLARS

ENGINEERED FOR
DETERMINISM.

TypeScript-First & Zod-Powered

Built with TypeScript and Zod for end-to-end type safety. Define your context schemas and get full autocompletion across your logic.

Policy-Based Evaluation

Bantai isn't just validation. It's a deterministic engine that separates your business rules from your execution flow for clean audits.

Composable Rules & Strategies

Compose modular rules into powerful policies. Use 'preemptive' strategy to fail fast or 'exhaustive' to collect all violations.

Environment Agnostic

Works anywhere JavaScript runs. Deploy in Next.js Middleware, Cloudflare Workers, Node.js servers, or even the browser.

DEVELOPER_WORKFLOW

LOGIC IN FIVE
PHASES.

01

Define Context

Use defineContext(z.object({...})) to establish your schema requirements.

02

Craft Rules

Write individual validation rules that return typed allow() or deny() responses.

03

Compose Policies

Group multiple rules into a single policy with custom evaluation strategies.

04

Execute Eval

Trigger evaluatePolicy() with real-time data to get an instant decision.

05

Handle Results

Utilize decision and violatedRules arrays to power your application's logic.

PHILOSOPHY

POLICY-FIRST
DESIGN.

Bantai treats policies as the single source of truth. By decoupling definitions from implementation, you ensure auditable behavior across all environments.

  • Zero hardcoded limits
  • Auditable request logic
  • Environment parity
  • Predictable scaling
MODE_01

LIBRARY MODE

Fully flexible, code-driven usage. Best for specific request guards inside your existing application logic.

MODE_02

RUNTIME MODE (SOON)

Config-driven, centralized control. Best for platform teams managing multiple services with global policies.

QUICK_START

CLEAN
IMPLEMENTATION.

Bantai sits in the middle of your application and its decisions. Use our declarative API to craft explainable, type-safe logic in minutes.

Zod-Compatible
Strict TypeScript Support
context.ts
import { z } from 'zod';
import { defineContext } from '@bantai-dev/core';

// Define your input schema
export const userContext = defineContext(
  z.object({
    age: z.number().min(0),
    role: z.enum(['admin', 'editor', 'guest']),
    isKycVerified: z.boolean()
  })
);
Read Only
SCENARIOS

VERSATILE BY DESIGN.

USE_CASE_01

Authorization & Access Control

Complex permission trees and multi-tenant logic.

USE_CASE_02

Fintech Risk & Compliance

KYC verification and transaction limit evaluation.

USE_CASE_03

AI / LLM Guardrails

Evaluate prompts for risk scores and confidence thresholds.

USE_CASE_04

Business Rule Engines

Move dynamic logic out of code and into policies.

USE_CASE_05

Feature Flags & Entitlements

Determine user features based on subscription context.

USE_CASE_06

OSS Trust Signals

Evaluate contributor reputation and code quality metrics.

MIT LicenseNPM Version
TRUST_SIGNALS

BUILT IN
THE OPEN.

Bantai is 100% open-source and MIT licensed. We believe critical decision logic should be transparent and auditable by everyone.