Skip to content

juspay/decision-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

394 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust License Docker Release Slack



Decision Engine

Routing control plane for payment decisions

Open-Source • Rust • Rule-Based • Success-Rate Based

Configure routing rules, run gateway decisions, and inspect routing outcomes from APIs or the dashboard.


Quick StartDocumentationArchitectureContributing


What is Decision Engine?

Decision Engine is a Rust service that sits between your orchestrator and your list of payment gateways. When a payment comes in, it picks the best available gateway based on rules you configure — priority ordering, success-rate scoring, volume splits, or debit-network gates — and returns the decision over HTTP.

┌─────────────┐     ┌──────────────────┐     ┌─────────────┐
│  Payment    │────▶│  Decision Engine │────▶│  Best       │
│  Request    │     │  (Fast routing)  │     │  Gateway    │
└─────────────┘     └──────────────────┘     └─────────────┘

It runs as a standalone service — no vendor lock-in, no mandatory orchestrator. Your existing stack calls it over HTTP before dispatching to a gateway, and over time it improves decisions using outcome feedback you push back via the score update API.

What it ships today:

  • Rule-based routing — define priority rules per merchant using Euclid, Juspay's open rule engine
  • Success-rate ordering — gateways ranked dynamically from transaction outcome feedback
  • Volume splits — distribute traffic across gateways by percentage
  • Debit routing gates — per-merchant toggle for debit-network routing
  • Downtime detection — auto-excludes gateways that are failing
  • Analytics — ClickHouse-backed tables for routing outcomes and decision audit
  • Dashboard — React UI for configuring rules and inspecting decisions
  • Multi-DB — MySQL and PostgreSQL support
  • Team management — invite and manage members per merchant account

Quick Start

Docker (Recommended)

git clone https://github.com/juspay/decision-engine.git
cd decision-engine
docker compose --profile postgres-ghcr up -d

API is ready at http://localhost:8080. That's it.

For API + dashboard + docs together:

docker compose --profile dashboard-postgres-ghcr up -d

Open:

  • API: http://localhost:8080
  • Dashboard: http://localhost:8081/dashboard/
  • Docs: http://localhost:8081/introduction
  • API reference: http://localhost:8081/api-overview

For deployed docs or dashboard environments, use the same paths under your deployed host, e.g. https://<docs-host>/api-overview.

From Source

Prerequisites: Rust 1.85+, MySQL or PostgreSQL, Redis, just

git clone https://github.com/juspay/decision-engine.git
cd decision-engine

# Edit config/development.toml with your DB, Redis, and ClickHouse connection details
# (config/development.toml already exists with all required sections)

MySQL (default features):

cargo build --release --features release
diesel migration run   # set DATABASE_URL=mysql://user:pass@host/dbname first
RUSTFLAGS="-Awarnings" cargo run --features release

PostgreSQL:

cargo build --release --no-default-features --features middleware,kms-aws,postgres
just migrate-pg        # sets DATABASE_URL from env or justfile defaults
RUSTFLAGS="-Awarnings" cargo run --no-default-features --features postgres

For the full local dev environment (API + dashboard on port 5173 + docs), run:

./oneclick.sh

This brings up Postgres, Redis, ClickHouse, and Kafka via Docker Compose, runs migrations, and starts the API server and dashboard locally. See Local Setup Guide for full details and options like ONECLICK_KEEP_INFRA=1.

Verify

curl http://localhost:8080/health
# → {"message":"Health is good"}

Documentation

Resource Description
Local Setup Guide CLI, Docker, Compose profiles, and Helm
MySQL Setup Guide MySQL-specific walkthrough
PostgreSQL Setup Guide PostgreSQL-specific walkthrough
API Reference (Swagger) Interactive Swagger UI — browse and try every endpoint against the OpenAPI spec
API Overview Entrypoint to API examples, OpenAPI schema, and route access rules
Configuration Guide All config options explained
Deep Dive Blog How the routing logic works

Architecture

High-Level Flow

Decision Engine Architecture

Integration Pattern

Integration Pattern

Decision Engine fits into an existing payment stack without replacing your orchestrator. The orchestrator calls Decision Engine to get a gateway recommendation, then dispatches to that gateway. Card data stays in your vault — Decision Engine never touches it.


Roadmap

Status Feature Description
Rule-based routing Merchant-defined priority rules via Euclid
Dynamic ordering Success-rate based gateway selection
Downtime detection Automatic health monitoring
Multi-database MySQL & PostgreSQL support
Dashboard Visual rule management and decision audit UI
Team management Invite members to merchant accounts
🔄 Enhanced routing models Better success rate prediction
📋 Multi-tenant analytics Per-tenant routing insights
📋 GraphQL API Alternative query interface

Contributing

Contributions are welcome — bug reports, feature requests, docs, or code.

# Fork & clone
git clone https://github.com/YOUR_USERNAME/decision-engine.git

# Create a branch
git checkout -b feature/your-feature

# Make changes and test
cargo test

# Submit a PR

See CONTRIBUTING.md for guidelines, and check good first issues if you're new to the codebase.


Community

Platform Purpose
Slack Real-time help and discussions
GitHub Discussions Feature requests and ideas
GitHub Issues Bug reports

License

Licensed under GNU AGPL v3.0.


Built by Juspay

Back to Top

About

open-source routing system designed for payment processing

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors