Production Security Model

AI Assistance. Human Authority.

Financial disputes carry legal and financial obligations. ResolveAI is designed with strict boundaries: AI assists with investigation, but humans hold sole authority to execute.

Security Boundary Architecture

How requests and dispute data flow safely across untrusted web, cognitive AI, and verified PayPal APIs:

1. Ingress Security
PayPal Webhooks

HMAC signature verification against PayPal certs + event-ID deduplication.

2. Tenant Isolation
JWT & RBAC

Strict merchantId scoping on all Prisma queries. Role permissions enforced.

3. Cognitive Guardrail
Zod & Citations

AI outputs validated via Zod. Every claim requires source record citations.

4. Egress Barrier
Human Sign-Off

Backend blocks submission unless explicit merchant approval is signed.

HMAC-SHA256

Cryptographic Webhook Signature Verification

Every incoming PayPal webhook is validated against PayPal’s verification endpoint using transmission ID, transmission signature, cert URL, and auth algorithm headers. Unverified or forged payloads are rejected at the edge before DB write.

Database Constraint

Idempotency & Event Deduplication

PayPal event IDs are tracked in the webhook_events table with a unique PostgreSQL index. Duplicate webhook deliveries receive an immediate HTTP 200 acknowledgment without re-triggering analysis or state transitions.

Hard Design Rule

Backend-Enforced Human Approval Gate

AI is architecturally forbidden from submitting evidence autonomously. The backend explicitly verifies dispute.approvalStatus === "APPROVED" in database transactions before calling PayPal APIs. Direct submission calls without approval fail with HTTP 400.

Type Safety

Zod Runtime Schema Validation

LLMs can generate malformed JSON. Every AI inference response is parsed and validated at runtime using strict Zod schemas (ClassificationSchema, CompletenessScoreSchema, ResponseDraftSchema). Invalid outputs are caught before persisting.

Zero Fabrication

Anti-Hallucination Citation Grounding

Draft contestation sections require an array of explicit source citations binding claims to verified transaction IDs or carrier tracking numbers. If proof is missing, the system flags it as a case weakness rather than inventing records.

Tenant Isolation

Merchant-Scoped Authorization & RBAC

All dispute, transaction, and evidence queries strictly enforce WHERE merchant_id = :authenticatedMerchantId. RBAC middleware segregates MERCHANT, REVIEWER, and ADMIN permissions, blocking horizontal privilege escalation.

Audit Trail

Immutable Compliance Audit Ledger

Every mutation (webhook receipt, AI analysis completion, evidence attachment, merchant approval, and PayPal submission) writes an append-only row into the audit_logs table capturing actor, action, timestamp, and metadata.

Secret Isolation

Zero Secrets in Frontend Bundles

PayPal client secrets, webhook IDs, and Google Gemini API keys exist strictly on the backend Express environment. Frontend code only communicates with our typed API client, never exposing gateway credentials.

Review our architecture & open source code