BetaLenzon is in beta — the Free tier is 100% free while we're in beta (bring your own Anthropic key, public repos).See plans →
Lenzon

horizontwo/policyflow — PolicyFlow: Payment Orchestration for Insurance TPAs

horizontwo/policyflow ·

Loading…

Transcript

QuickFacts

Welcome! Today we're exploring PolicyFlow, a payment orchestration platform built for insurance third-party administrators. It sits between claims systems and payment gateways, managing multiple carrier accounts and executing vendor payments with complete financial accountability.

PlainEnglish

So what does PolicyFlow do? It's a payment control tower for insurance TPAs. It manages carrier accounts and reserves for individual claims, orchestrates money movement through payment gateways, and keeps a complete audit trail using double-entry bookkeeping. Everything is multi-tenant, so carrier funds stay completely separate.

PlainEnglish

Here's a clever security pattern. Instead of storing vendor bank account numbers, PolicyFlow asks Snapsheet for them just-in-time when making a payment, uses them immediately, then discards them. It's like a restaurant that never writes down your credit card — they ask the processor for it only when charging, then immediately forget it. Zero stored account numbers means a much smaller compliance surface.

QuickFacts

Let's look at the stack. The application layer is Next.js fifteen point five with TypeScript and magic link authentication. Data access goes through Prisma with a custom tenant-scoping extension that automatically filters queries by customer ID. External services include Masspay for payments, Snapsheet for claims data, and Claude for AI-powered document ingestion. All credentials live in AWS Secrets Manager and are loaded at runtime.

Architecture

The architecture follows a clean layered pattern. User requests hit the Next.js app router, which hands off to API route handlers. Those validate input with Zod and delegate to the service layer — that's where all the business logic lives. Services talk to the database through Prisma, which automatically scopes queries by tenant. External integrations with Masspay and Snapsheet happen through dedicated client modules, with credentials loaded from AWS Secrets Manager at runtime.

Architecture

Here's how the codebase is organized. The app directory holds all the Next.js routes — both UI pages and API endpoints. Under lib, you'll find the service layer with all the business logic, plus integration clients for external systems. The database module sets up Prisma with tenant scoping. Components are organized by feature area — accounts, payments, ingestion. It's a vertical slice architecture where each domain has its own service, routes, and UI.

Architecture

Let's trace a payment execution. The user submits a payment request with a reserve ID, payee, and amount. The API route validates it and calls the payment service. The service reserves funds from the reserve balance, calculates fees, and auto-approves the payment. It then submits the payout to Masspay, receives a transaction token, and updates the database with status SENT and ledger entries. The whole flow is synchronous and atomic — either it all succeeds or nothing changes.

PlainEnglish

At the heart of PolicyFlow is a double-entry ledger system. Every financial transaction creates two entries — a debit and a credit. When thirty-two hundred dollars leaves a reserve, one entry records minus thirty-two hundred, and another records plus thirty-two hundred going to the payee. The system enforces conservation of money mathematically — if you sum all ledger entries, they must equal zero. It's the same accounting method banks have used for centuries.

Architecture

One of the coolest features is AI-powered ingestion. A user can paste a semi-structured email or upload a PDF with claim data. Claude extracts all the claim numbers, amounts, and descriptions into a structured table. The user reviews it, makes any corrections, and submits. The system looks up each claim in Snapsheet to enrich the data, then follows the standard cover request flow. What used to take an hour of manual data entry now happens in minutes.

Community

Looking at the community health, this is an active private repository with very recent commits — last activity was just yesterday. It's maintained by a single developer, Rick Gonzalez, working in a tight-knit team environment. With two branches and ongoing development, this looks like a focused internal tool being actively built and refined. No public releases yet, which makes sense for a payment platform handling sensitive financial operations.

PlainEnglish

So that's PolicyFlow! A payment control tower sitting between Snapsheet and Masspay, managing multi-tenant carrier accounts with complete financial accountability. The architecture is clean and well-organized, security is baked in through just-in-time data fetching, and the double-entry ledger provides bulletproof audit trails. Modern conveniences like AI ingestion make it practical for day-to-day operations. It's a focused, well-executed internal tool solving a real coordination problem in insurance payment processing.

How this was made

Lenzon read horizontwo/policyflow and generated this walkthrough automatically. The narration above is the transcript of what it says.

Explain a pull request from your own repo

Point Lenzon at a repo or a pull request and get a narrated walkthrough like this one.

Try it