Skip to main content
Credit Risk

Loan Risk Automation

An end-to-end credit risk monitoring pipeline that pulls active loans from Supabase, calculates maturity dates, runs an LLM risk assessment, and dispatches tiered email alerts.

LiveAutomationSupabasen8nNext.jsOpenAIGmail
Type
Automation concept · credit risk monitoring
Role
Solo builder: schema, workflow, frontend, deployment
Timeline
2026
Client context
Vanguard Financial Holdings · corporate lending
Architecture
Supabase + n8n + LLM + Next.js dashboard
“The goal was not another spreadsheet to track loans. It was to move the alerting from manual memory to an automated pipeline that never misses a maturity date.”

The problem

The Credit Risk team tracked active loans in static spreadsheets. Maturity dates approached without reliable alerts, so Relationship Managers and clients were not consistently notified. Missed collections, delayed intervention on past-due loans, and no real-time visibility for executives were the predictable result.

Before the automation

Loan obligations were maintained in spreadsheets with manual date checks. Alerts were ad hoc, if they happened at all. The team had no single place to see what was coming due, what was overdue, and what risk level each loan carried.

What I built

Webhook-triggered n8n pipeline: pull active loans from Supabase, calculate days to maturity, run an LLM risk assessment, and route alerts by risk band.

The system centers on a single source of truth in Supabase, a webhook-triggered n8n workflow, and a Next.js dashboard for the audit team. Loans are pulled automatically, maturity logic is calculated in code, and an LLM generates a structured risk score and email draft for each loan that hits a threshold.

  • Typed Supabase schema. A loan_obligations table with constraints on customer type, loan type, interest type, and loan status.
  • Maturity calculation. An n8n Code node calculates days to maturity and filters for exactly 14 days out, 7 days out, or 1 day overdue.
  • LLM risk assessment. A Basic LLM Chain produces a numeric risk_score and a formatted email_draft for each qualifying loan.
  • Risk-band routing. A Switch node routes low, medium, and high-risk loans to different email recipients, with high-risk loans copied to the Relationship Manager.
  • Next.js dashboard. A read-only risk monitoring interface where the audit team can view loans and trigger the daily audit manually.

The outcome

Built as a portfolio-ready full-stack automation, the system demonstrates how a centralized data layer plus an automation engine can replace spreadsheet tracking for loan maturity and risk alerting. The intended outcome is consistent, timely alerts and a single view of portfolio risk.

Stack

Supabasen8nNext.jsOpenAIGmail

Next improvements

  • Scheduled execution. Replace the manual dashboard trigger with a daily cron schedule.
  • Risk model refinement. Add more features to the risk score, such as payment history and collateral value.
  • Executive reporting. Generate a weekly portfolio summary with trend charts and exception lists.

Automation flow snapshot

Loan risk automation flow

The n8n workflow canvas showing webhook trigger, Supabase retrieval, maturity calculation, LLM risk scoring, and email routing by risk band, plus example HTML email outputs.