Business rules

Business rules management lets your team instantly update business rules without relying on engineering or redeploying your app.

Problem

Without business rules management, rules are typically hardcoded. This results in several challenges:

  • Compliance, product, and ops teams:

    • Don't have visibility on business rules and so cannot verify their correctness.

    • Can't safely update business rules themselves.

    • Consume engineering resources with requests to update business rules.

  • Updates to business rules are slow as they require code changes and app redeploys.

  • There's no single source of truth for business rules across different codebases.

  • Business rules can't be tuned with experimentation to improve metrics while controlling risk.

Solution

Define business rules in Hypertune flags instead of hardcoding them:

type BusinessRules {
  isApplicantEligibleForLoan(
    creditScore: Int!,
    annualIncomeUsd: Boolean!,
    debtToIncomeRatio: Float!,
    loanAmountRequestedUsd: Int!,
    riskScore: Int!,
    loanToValueRatio: Float!
  ): Boolean!
  
  claimRequiresAdjusterReview(
    claimAmount: Int!,
    policyCoverageLimit: Int!
  ): Boolean!
}

Then reference them in your code:

app/api/submit-loan-application/route.ts
import { waitUntil } from '@vercel/functions'
import { NextResponse } from 'next/server'
import getHypertune from '@/lib/getHypertune'
import submitLoan from '@/lib/submitLoan'

export const runtime = 'edge'

export async function POST(request: Request) {
  const hypertune = await getHypertune({ isRouteHandler: true })

  const {
    applicantId,
    creditScore,
    annualIncomeUsd,
    debtToIncomeRatio,
    loanAmountRequestedUsd,
    riskScore,
    loanToValueRatio,
  } = await request.json()

  const isEligible = hypertune
    .businessRules()
    .isApplicantEligibleForLoan({
      args: {
        creditScore,
        annualIncomeUsd,
        debtToIncomeRatio,
        loanAmountRequestedUsd,
        riskScore,
        loanToValueRatio,
      },
      fallback: false,
    })

  waitUntil(hypertune.flushLogs())

  if (!isEligible) {
    return NextResponse.json(
      {
        error: 'Loan application denied',
        message: `Unfortunately, your loan application does not meet our eligibility criteria at this time. Please contact our support team for more information.`,
      },
      { status: 403 }
    )
  }

  const applicationId = await submitLoan(
    applicantId,
    loanAmountRequestedUsd
  )

  return NextResponse.json({
    success: true,
    message: `Congratulations! Your loan application has been approved. Our team will contact you within 24 hours to complete the process.`,
    applicationId,
  })
}

This empowers compliance, product, and ops to view and instantly update business rules from the Hypertune dashboard without any code changes or redeploys:

Benefits

  • Compliance, product, and ops teams:

    • Have visibility on business rules so can verify their correctness.

    • Can safely update business rules themselves.

    • Don't need to bother engineering with requests to update business rules.

  • Business rules can be updated instantly without any code changes or app redeploys.

  • Business rules are consolidated into a single source of truth across different codebases.

  • Business rules can be tuned with experimentation to improve metrics while controlling risk.

ROI

These benefits help teams:

  • Stay compliant.

  • Control risk.

  • Improve key business metrics.

  • Move faster with the same headcount.

Last updated