SaaS Architecture & AI

FixDoc

Document checks for mortgage loan files, built for brokers who have to show their work.

FixDoc reads the pay stubs, W-2s, 1099s and bank statements in a loan file, checks them against each other and against the borrower, and turns every mismatch into a finding a reviewer decides and documents.

Release candidatev1.0.0-rc.1

155

API route handlers

56

Database migrations

3,700+

Unit tests

9

Roles, server-enforced

The challenge

Mortgage brokers review loan files by hand. When a lender or examiner later asks why a file went through, the answer lives in inboxes and memory. They needed one place where every document is checked the same way, every decision has a note, and the record can be handed over as proof.

What we built

We designed and built FixDoc as a multi-tenant SaaS from day one: organization isolation in the database, a role model that matches real loan teams, checks that combine exact rules with AI where reading documents needs it, and an Evidence Pack per file that a lender can read without logging in.

Features

Document checks

  • Income, deposit, name, employer and date checks across every document in the file
  • Tampering checks with no AI: statements that don't reconcile, pay stubs that don't add up, year-to-date pay that doesn't follow
  • W-2 and 1099 checks: payroll tax math against the SSA wage base, EIN format, W-2 against the final pay stub
  • Scanned PDFs and phone photos read by OCR on our own servers, redacted before any AI sees them

Review workflow

  • Findings decided as Explained, Not an issue or On hold, with a required note and append-only history
  • Check what we read: values shown before checks run, corrections kept beside the original
  • Review queue with claim, assign, due dates, board and calendar views
  • AI assistant on each loan file with a private conversation history

Proof for lenders

  • Evidence Pack PDF per file: documents with SHA-256, checks, findings and decisions
  • Quarterly quality report and audit log export
  • Portfolio patterns across files (shared phone, identical pay stubs, repeated employers)
  • Read-only public API with scoped, hashed keys and Standard Webhooks events

Platform & billing

  • Nine roles from owner to applicant, each limited to what its job needs
  • Two-step verification (TOTP) on every plan
  • Stripe Checkout, customer portal and signed webhooks across four plans
  • In-app and email notifications with digests and quiet hours

Architecture

Every request is scoped to one organization. Route handlers check the caller's role and filter every query by organization, including server-side queries, on top of row level security.

  1. Callers

    Brokers & reviewers

    Browser session with two-step verification

    Lender systems

    Scoped, hashed API keys

    Vercel Cron

    Digests, webhook retry, auto-archive

  2. Next.js 16 application on Vercel

    Middleware gates every request

    App Router pages

    Dashboard, loan files, findings, reviews, portfolio, settings

    API routes /api/v1

    Role, tenant and plan checks, Zod validation, JSON errors

    Domain services

    Checks engine, findings, Evidence Pack PDFs, assistant, webhooks

  3. Supabase

    PostgreSQL

    Row level security by organization, audit trail

    Auth

    Email, Google sign-in, TOTP two-step

    Storage

    Private buckets, 5-minute signed links

    Realtime

    In-app notifications

  4. External services

    OpenAI

    GPT-4o document parsing and assistant

    Stripe

    Subscriptions, portal, invoices

    Resend

    Transactional email and digests

    Customer endpoints

    Signed Standard Webhooks

Engineering highlights

Tenant isolation, twice

Row level security in PostgreSQL, plus an organization filter in code on every query, including the ones that run with the service role. One layer failing doesn't leak another firm's files.

Rules where it must be exact, AI where it helps

Arithmetic, tax math and PDF history are checked deterministically. AI reads unstructured documents, with identifiers redacted first and the document treated as data, never instructions.

Honest by construction

Findings are inconsistencies to review, never verdicts. A unit test blocks overclaiming language on every reader-facing screen.

Tested like production

Vitest unit, integration and load suites, live-test scripts that drive the real API, Playwright browser journeys, and GitHub Actions CI on every pull request.

Tech stack

Application
Next.js 16 (App Router), React 19, TypeScript 5 strict
UI
Tailwind CSS 4, light and dark mode
Database
PostgreSQL on Supabase with row level security
Auth
Supabase Auth, Google sign-in, TOTP two-step
AI
OpenAI GPT-4o
Payments
Stripe Checkout, Customer Portal, webhooks
Email
Resend
Testing & CI
Vitest, Playwright, GitHub Actions

Building something similar?

Tell us what you need. We'll come back with a plan and a realistic estimate.