← Home

AI Credit Policy Copilot

My first project built with AI: upload a bank's credit-policy PDF and ask questions in plain language, answered from the document's own rules and text.

Built for
My own learning, as my first project built with AI. A practice project, not a product.
Time
2 – 10 Mar 2026 (about one week, 9 commits)
AI tools
Cursor
Stack
Next.js 16, React 19, Tailwind CSS 4, Supabase (Postgres with pgvector, Auth, Storage), OpenAI (text-embedding-3-small, GPT-4o mini), Inngest, Vercel

User stories

  • As a credit analyst, I want to ask a plain-language question about a lending policy, such as the maximum loan-to-value, so that I don't have to search a long PDF.
  • As a loan officer, I want answers to come from the policy's own rules whenever possible, so that I can trust the numbers.
  • As a bank, I want to upload a new policy version and have it processed automatically, so that answers always follow the latest document.
  • As a visitor, I want to try it without signing up, so that I can judge it quickly.

Situation & constraint

This was my first project built with AI, and a learning project rather than a product. I wanted to understand retrieval-augmented generation (RAG) by building one end to end, on a kind of document I know from my fintech work: lending credit policies, which are long PDFs full of numeric rules such as loan-to-value limits, income thresholds, credit-score cutoffs and age limits.

Architecture

  • Upload pipeline: uploading a PDF fires an Inngest event that runs three steps in order. Extract the text, ask the model to pull out structured rules (maximum LTV, minimum income, minimum credit score, maximum FOIR, age limits, occupations), then split the text into 800-character chunks with 150 of overlap and embed them.
  • Embeddings (text-embedding-3-small, 1,536 dimensions) live in Postgres with pgvector, next to a generated full-text search column on the same chunk table.
  • Question answering tries three routes in order: a rule engine over the extracted rules; then hybrid retrieval, where vector search and full-text search are merged and keyword-reranked before GPT-4o mini answers as JSON; and finally the first 20,000 characters of the document as a last resort.
  • Retrieval is scoped to the latest version of each document, so answers follow the newest policy.
  • Data model: organizations, products, policies, documents, then chunks and rules per document. Row-level security is on for every table, and the PDFs sit in a private storage bucket.
  • Guests get three questions per session, tracked in a usage table. There is also an eligibility calculator and a debug page for inspecting retrieval.

Decision & trade-off

Rules first, retrieval second, whole document last. A number such as a maximum loan-to-value is better answered from a rule that was extracted once than from whatever passages a vector search happens to return, so the language model is the second route, not the first.