Inspiration
I have worked with nonprofits in various capacities over the years. At certain times of the year there is a rush of donors and donations, and processing all of it is tedious work.
The bigger gap comes after. Donors ask a fair question: "How did my donation help? What was it used for?" That usually turns into a one-on-one conversation, or it waits for the yearly board or community meeting, where we say "here is roughly where the funds went." Nothing specific.
Behind that sits the work nobody sees. Every restricted grant comes with its own caps, dates and exclusions. Someone retypes those rules, matches each receipt line to a fund, chases a second signature, sends the reimbursement and later proves to the funder that no restricted dollar paid for an ineligible line.
I wanted one place where AI does the reading, code does the math, people keep the authority and PayPal moves the money. And a donor gets a specific answer: these receipt lines are what your gift paid for.
What it does
Claude turns a grant PDF into rules two people approve. Once they turn on Autopilot, small clean claims pay through PayPal with no approval click, and donors see the lines their gift was applied to.
The full loop: a donor gives $50 to the Ashmere STEM fund through PayPal Checkout. A claimant submits a $42 receipt for notebooks. Claude checks it against the grant, the rules engine funds it from Ashmere alone, eight guardrails pass and PayPal Payouts sends the money. AidTrace marks it Paid only after PayPal reports the payout item as successful. The donor's private link then shows the notebooks line their gift went to. A claim that fails any guardrail goes to two people instead.
- Grant PDF to rules. Claude Sonnet 5.5 drafts caps, dates and categories, each beside the exact quote it came from, and code checks every quote. Anything the grant does not support stays empty. Two different approvers bind the draft. The model never writes a binding rule.
- Receipt to categories. Claude Haiku 5.5 reads the receipt photo, code checks the arithmetic to the cent, Claude proposes a category per line with a quote and the claimant confirms.
- Funding split. A min-cost flow solver in integer cents applies each fund's restrictions and uses as little unrestricted money as the rules allow. No model decides the split.
- Checks before money moves. Rules checks and a Claude policy check with clause citations can hold a claim. A model answer alone never pays one.
- Three fund modes. Manual: two people approve every claim. Assisted: bulk approval of clean claims. Autopilot: a small clean claim pays itself under eight guardrails, including caps, a 5 percent random audit and a kill switch. Turning automation on takes two approvers.
- PayPal on both sides. Checkout (Orders v2) for gifts, Payouts for reimbursements and verified webhooks. A payout with an uncertain outcome stays UNKNOWN until a person authorizes a retry.
- Books in AG Grid Community. Read-only ledger, donations and approver queue views, plus a funder report that ties out to the books.
How I built it
Solo build. Next.js 16, React 19, TypeScript, PostgreSQL and Drizzle, all run in Docker. Money is integer cents everywhere. A decision hash binds each approval to the exact terms the approver saw. One module writes the ledger and one file calls PayPal. Every Claude call runs with no tools, a closed JSON schema and validation in code, under a 60-request cap. I used Claude Code and Codex to write, test and review the code. I made the design and money calls myself.
Challenges I ran into
The one that surprised me most: an accepted payout batch does not mean the payee got paid. AidTrace follows each payout item and posts settlement and the PayPal fee exactly once, through refreshes and replayed webhooks.
The rules drafter's first real run failed 24 of 24 calls. The schema had 46 unions against a limit of 16, and the next attempt hit "The compiled grammar is too large". I flattened the schema and proved it compiled before spending on another paid run.
Accomplishments that I'm proud of
In the PayPal sandbox, one rehearsal run each: a $500.00 claim paid after two approvals, a $50.00 Checkout gift and a $42.00 claim paid under Autopilot with zero approvals.
| Evaluation | Result | Limit |
|---|---|---|
| Rules drafter, four agreements | 69 of 69 determinate fields right, 0 fabricated | Invented agreements |
| Policy check, 840 calls | 0 of 72 risky runs cleared; at least 32 of 96 clean runs held | Synthetic receipts, labels written by Claude; a zero is a bound, not a rate |
| Receipt photo reader | 5 of 5 photos, 5 of 5 injection receipts | Ten invented images, one run each; the prompt was revised after a first run scored 4 of 5 |
2,900 automated tests in 160 files and six browser suites pass.
What I learned
AI earns its place when it organizes review and quotes its sources. Deterministic rules should decide the money. And once small claims pay themselves, the product has to say exactly which claims people still decide.
What's next for AidTrace
An accountant's review of the accounting model, scanned-PDF grants and a pilot with a real treasurer. Limits today: sandbox payments only; an invented nonprofit, grants and receipts; a seeded 30-day payout email history; and a donor link shown once with no recovery flow.
Built With
- ag-grid-community
- anthropic-api
- claude
- docker
- drizzle-orm
- next.js
- node.js
- paypal-checkout
- paypal-payouts
- playwright
- postgresql
- react
- typescript
- unpdf
- vitest