Skip to content

Veritas

Serverless identity verification for Bangladesh-first products

Hover to spread the screens, click one to look closer, orSwipe through the screens, tap one to look closer, or flip through all 9.

KYC as a link: an applicant photographs their ID and takes a selfie, and the customer gets a decision and a webhook in under two minutes. Rebuilt on a fully scale-to-zero Google Cloud stack with OCR, face match, liveness and document-tamper detection.

In numbers

typical cost per verification, every line traced to code
~$0.009
hard worst-case ceiling, bounded by attempt caps
$0.33
standing cost per month: everything scales to zero
~$1
countries' national IDs added to the document registry
19

The problem

Identity checks decide whether someone can open an account, get a loan or receive a payout. Most KYC vendors are priced for Western volumes and struggle with what Bangladeshi applicants actually hold: laminated national IDs with ten-year-old portraits, photographed on budget phones.

Veritas had to be cheap enough to run per user, accurate on those documents, and fair to old photos: a weak match should go to a human reviewer, never become a silent decline.

How it works

step through it · each step is a note

The extraction ladder: cheapest tier first

noyespassfailagreedisagreeCapturesigned URL → GCSQuality + typeright document?Retakebefore any spendTier 1 · OCRDocument AI + MRZ · $0.003Tier 2 · Geminischema-locked · ~$0.004Tier 3 · ID processorfinal arbiter · $0.10Checks pass?Tiers agree?Confirmed fieldsapplicant confirms

  1. 01The applicant photographs their ID. Bytes go straight to Cloud Storage through a signed URL; the API never proxies images.
  2. 02Quality and document type are checked first, so a blurry photo or the wrong document fails before any paid call.
  3. 03Tier 1: Document AI OCR plus deterministic MRZ checksums, about $0.003 a document.
  4. 04When the checks pass, the ladder stops. Most verifications end here.
  5. 05Hard cases go to Gemini with a locked schema and an injection guard.
  6. 06If the tiers disagree, Google's identity processor decides. Attempt caps bound the worst case at about $0.33.

My part

Built by a five-engineer team at Ledgercross.

  • Led the team through a 13-milestone parity program, with each milestone owned by one engineer and scoped to separate files so work never collided.
  • Built document-tamper detection: copy-move and splicing regions, metadata and recompression signals, fused with noisy-OR into a tamper probability with a hard-reject gate, plus a labelled eval set to measure precision and recall.
  • Added a document classifier behind a swappable interface, an image-quality gate that asks for a retake before any OCR is paid for, and a data-driven registry covering national IDs from 19 countries.
  • Shipped the operator dashboard's review tooling: case assignment, note threads, SLA timers, a level-config builder with versioned rollback, analytics, team management and white-label theming.
  • Built the Android SDK's CameraX document capture with a server-set quality gate, and its selfie burst with the active-liveness challenge loop.
  • Fixed the deploy pipeline so migrations run on every release.

Decisions

A cost ladder, cheapest tier first

Document AI OCR plus deterministic MRZ checksums handles most documents for $0.003. Gemini takes only the hard ones, and the $0.10 identity processor is the arbiter only when tiers disagree. Wrong documents fail before any spend.

Liveness before likeness

Selfie frames are scored for presentation attacks first, and only frames that pass may supply the match score. Borderline results get one randomized turn challenge instead of a hard no.

Fair to old photos

Decision bands are age-aware, so a ten-year-old national ID portrait that matches weakly goes to human review rather than an automatic decline.

Python on Cloud Run, not Go on Kubernetes

The spec asked for Go microservices on GKE. The latency lives in OCR and face inference, not the runtime, and the ML half has to stay Python, so one language on Cloud Run kept a small team fast and the idle bill near zero. The trade-off is documented in the repo.

Face match with liveness

borderlinere-scoreID photofrom the ladderRectifyperspective cornersPortrait cropArcFace embeddingcomputed once, cachedSelfie burst8 framesLivenessPAD score per frameLive frames onlyCosine matchTurn challengeonly if borderlineDecision bandsage-awareApprove · Review · Declinewebhook via Cloud Tasks

  1. 01The portrait is cut from a perspective-rectified ID, using corners from the browser or server-side detection.
  2. 02It's embedded once with ArcFace and cached for every later comparison.
  3. 03The selfie burst is scored for presentation attacks first.
  4. 04Only frames that pass liveness are allowed to supply the match score.
  5. 05Decision bands account for portrait age, so an old national ID photo goes to review instead of a silent decline.
  6. 06Borderline? One randomized turn challenge, then score again.
  7. 07The decision goes to the customer as a signed webhook delivered by Cloud Tasks.

Stack

  • ServicesFastAPI on Cloud Run, InsightFace ArcFace, MiniFASNet liveness, OpenCV
  • Google CloudDocument AI, Gemini, Cloud SQL Postgres, Cloud Storage, Cloud Tasks, Firebase Hosting
  • ClientsReact + Vite, Android (CameraX), iOS, React Native, Web SDK
  • OpsTerraform, Cloud Build, GitHub Actions, Identity Platform