AWS Builder Center
PayProof AI: Building an Evidence-First Pre-Payment Verification System on AWS

PayProof AI: Building an Evidence-First Pre-Payment Verification System on AWS

PayProof AI is a pre-payment verification system for finance and accounts-payable workflows. It combines deterministic payment controls, human review, private evidence handling, and advisory AI with an AWS-ready architecture using ECS Fargate, Aurora PostgreSQL, Amazon S3, Cognito, Amazon Verified Permissions, Amazon SQS, and SageMaker.

PayProof AI: Building an Evidence-First Pre-Payment Verification System on AWS

Before money moves, evidence should.
A payment can look completely normal and still contain one risky change: a new beneficiary account, a lookalike sender domain, a duplicate invoice, a purchase-order mismatch, or missing verification evidence.
That is the problem I wanted to address with PayProof AI.
PayProof is not a payment processor, and it does not execute payments. It is a pre-payment verification system designed to help finance and accounts-payable teams review evidence before a payment moves further through the approval process.
The core principle is simple:
Deterministic controls first. AI for interpretation. Humans remain in control.



What PayProof checks

A PayProof case can bring together evidence such as invoices, emails, purchase orders, vendor information, beneficiary details, previous payment history, and verification records.
The application preserves deterministic rules for checks including:
  • new beneficiary accounts;
  • unrecognized sender domains;
  • lookalike domains;
  • duplicate invoices;
  • purchase-order mismatches;
  • unusual payment amounts;
  • missing baseline evidence;
  • missing independent verification.
The important point is that these checks do not depend on an LLM.
For example, determining whether an invoice reference already exists or whether bank details changed from a trusted baseline should be handled deterministically.
AI is used only as an advisory layer for interpreting unstructured information and producing reviewer-facing analysis.
It cannot directly:
  • release a payment;
  • modify trusted vendor bank details;
  • override a hold;
  • assign a user role;
  • change authorization policy.



One codebase, local and AWS modes

PayProof uses one repository with two explicit deployment modes.
Capability
Local mode
AWS mode
Database
SQLite
Aurora PostgreSQL Serverless v2
Evidence
Local filesystem
Private Amazon S3
Authentication
Local/demo identities
Amazon Cognito
Authorization
Local role adapter
Amazon Verified Permissions
AI inference
NVIDIA hosted API or disabled
SageMaker endpoint
Analysis
In-process
Amazon SQS + ECS worker
Compute
Local Uvicorn
ECS Fargate
Entry point
Local browser
CloudFront + internal ALB
Runtime configuration is centralized in:
src/payproof/config.py
AWS mode is designed to fail closed. If critical cloud configuration is missing, the application does not silently fall back to SQLite, demo identities, local authorization, or a different inference provider.



AWS architecture

The AWS path is designed around:
Internet
|
v
Amazon CloudFront
|
v
CloudFront VPC Origin
|
v
Internal Application Load Balancer
|
v
ECS Fargate Web Service
|
+--> Amazon Cognito
+--> Amazon Verified Permissions
+--> Aurora PostgreSQL Serverless v2
+--> Private Amazon S3
+--> Amazon SQS
|
v
ECS Fargate Worker
|
v
SageMaker AI Endpoint
Supporting services include Amazon ECR, AWS Secrets Manager, CloudWatch, IAM, and VPC networking.
I chose ECS Fargate because PayProof is already a FastAPI application. Rewriting the system around another compute model simply to make it “more cloud-native” would have added complexity without improving the core workflow.



Why analysis is asynchronous

Model inference can take longer than a normal browser request, so AWS mode separates request handling from analysis execution.
When a user requests analysis:
  1. the request is authorized;
  1. an analysis job is stored;
  1. a small message containing identifiers is sent to Amazon SQS;
  1. the API returns  HTTP 202 ;
  1. an ECS worker claims and processes the job;
  1. findings and decision state are persisted.
The worker is designed to handle duplicate SQS delivery, retryable failures, visibility-timeout extension, and DLQ-compatible terminal failures.
If repeated failures exhaust the configured retry limit, the case moves to  ANALYSIS_PARTIAL  rather than remaining stuck in an analyzing state.



Evidence integrity and private storage

Evidence stored in AWS mode goes into a private S3 bucket using a namespaced structure such as:
cases/{case_id}/evidence/{evidence_id}/{sanitized_filename}
The application stores the S3 key, byte count, and SHA-256 digest in the database.
When evidence is retrieved, PayProof authorizes the case access and revalidates the returned object against the stored size and digest.
This does not make the storage legally immutable or prove identity. It provides an application-level integrity check and a clearer evidence trail.



Authentication and authorization are separate

PayProof separates three different security questions:
Amazon Cognito Who is the application user?
Amazon Verified Permissions May this authenticated user perform this PayProof action?
AWS IAM Which AWS APIs may this workload call?
The application recognizes four PayProof roles:
Analyst
Approver
Auditor
Admin
A user must resolve to exactly one PayProof role. Zero or multiple matching roles are denied.
Verified Permissions uses version-controlled Cedar schema and policies, and authorization failures are handled fail-closed in AWS mode.



Deployment and engineering safeguards

The repository also includes:
  • SQLAlchemy for SQLite/PostgreSQL access;
  • Alembic database migrations;
  • Docker packaging with a non-root runtime;
  • CSRF protection for cloud mutating requests;
  • versioned hash-linked audit events;
  • GitHub Actions CI;
  • a real PostgreSQL CI service;
  • GitHub OIDC-based AWS deployment;
  • immutable Git-SHA container tags;
  • a one-off database migration task;
  • ECS service stabilization checks;
  • CloudFront health checks;
  • task-definition rollback logic;
  • release checks that reject packaged  .env , local databases, private keys, AWS access-key patterns, and NVIDIA token patterns.
The final local verification snapshot reported:
46 passed, 1 skipped
The skipped test is the PostgreSQL integration test when PostgreSQL is unavailable locally; CI is configured to run it against a PostgreSQL service.



What PayProof does not claim

There are a few boundaries I intentionally keep explicit.
PayProof does not claim to:
  • automatically detect every fraud attempt;
  • make a legally binding fraud determination;
  • autonomously update vendor master data;
  • execute payments;
  • replace independent verification;
  • prove production-scale AWS reliability before live deployment testing.
The AWS integration path is implemented in the codebase, but account-specific behavior for Aurora, S3, Cognito, Verified Permissions, SQS, SageMaker, ECS, ALB, CloudFront, IAM, quotas, and CloudWatch still needs to be validated in the actual AWS environment.
That distinction matters.
A clean codebase and passing tests are evidence of engineering quality. They are not the same thing as production validation.



Final thought

PayProof started from a simple question:
What evidence should exist before a payment moves forward?
The answer was not “use more AI.”
It was to combine deterministic controls, private evidence handling, explicit authorization, asynchronous cloud execution, advisory AI, and human review in one workflow.
That is the direction I want PayProof to continue following: better evidence, clearer decisions, and fewer hidden assumptions before money moves.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article