Design a KYC Verification System

Medium
Real World SystemsDocument VerificationState MachineWorkflowComplianceIdentity

Problem Statement

Design a Know Your Customer (KYC) verification system used in fintech/banking applications to verify user identity through document submission, automated checks, and manual review workflows.

Requirements

Functional Requirements

  • Customer submits KYC application: personal details (name, DOB, address, nationality)
  • Document upload: ID proof (passport, national ID, driver's license) + address proof
  • Automated checks: document format validation, OCR data extraction, face match with selfie
  • Risk scoring: assign risk level (LOW, MEDIUM, HIGH) based on checks
  • Manual review queue: HIGH risk cases sent to compliance officer for review
  • Application states: SUBMITTED → DOCUMENTS_VERIFIED → AUTO_CHECKED → PENDING_REVIEW (if HIGH risk) → APPROVED / REJECTED
  • Rejection reasons: document expired, mismatch, face mismatch, blacklisted
  • Re-submission: customer can re-submit after rejection with new documents
  • Audit trail: every state change logged with timestamp and actor

Non-Functional Requirements

  • Async document verification pipeline
  • Thread-safe status updates
  • Singleton KYCService

Key Entities

  • KYCApplication: id, customerId, status, documents, riskScore, checks, auditLog
  • Document: id, type (ID_PROOF/ADDRESS_PROOF), fileUrl, status, extractedData
  • AutomatedCheck: type (OCR/FACE_MATCH/EXPIRY_CHECK/BLACKLIST), result, details
  • ComplianceOfficer: id, name, queue (List<KYCApplication>)
  • KYCService: Singleton; orchestrates the pipeline

Constraints

  • Documents must not be expired (verified against submission date)
  • Face match confidence must be >= 85% to pass
  • HIGH risk applications always require manual review
  • Re-submission allowed max 3 times before permanent rejection

!Constraints

- Document expiry validated at submission time - Face match confidence threshold: 85% - HIGH risk mandates manual review — cannot auto-approve - Maximum 3 resubmission attempts before permanent rejection - All state transitions logged to audit trail
Output

Run or submit your code to see output here.