Inspiration
Expense reports are a small chore that costs companies a lot. Employees retype receipts, finance teams chase missing information, and policy violations and duplicate claims often get through because nobody has time to check every line. We wanted to see how much of that work AI could do while keeping a person in charge of every financial decision. We also wanted it to run locally, with no cloud database and no paid AI API.
What it does
SpendPilot AI takes an expense from receipt to reimbursement.
An employee uploads a receipt, and the system reads the merchant, date, amount, currency and category. The employee can correct any of it. It checks the expense against company policy, e.g. a $350 hotel against a $200 limit gives a $150 excess, with a written explanation. It flags duplicate receipts and unusual spending as risk indicators for review, never as accusations. It recommends a decision, but a manager and a finance administrator must both approve before any reimbursement. Finance can send payouts through PayPal Sandbox. An expense is marked paid only after PayPal’s API confirms it. Role-based dashboards show budgets, forecasts and alerts. Users can also ask plain-English questions like “Which department has the highest spending?”
How we built it
We built it as a multi-agent system in Python and Flask, with SQLite as the only database. One central orchestrator coordinates six agents over a shared workflow state: Expense Intelligence, Policy Compliance, Fraud Detection, Approval Intelligence, Financial Intelligence and Payment.
Receipts: Tesseract OCR reads images, and spaCy with custom EntityRuler patterns and regular expressions extracts the fields. Policy: deterministic Python checks use exact decimal maths. Fraud: file hashes, duplicate-transaction checks, a robust statistical score and a scikit-learn Isolation Forest. Questions: spaCy maps each question to a fixed set of parameterised queries, so user-written SQL never runs. Interface: Bootstrap, Chart.js and Lucide icons, bundled locally so the app works offline.
We built it in phases and wrote tests at each step. It ended with 83 automated tests covering agents, approvals, payments and every page for every role.
Challenges we ran into
Receipt extraction: spaCy’s general model doesn’t reliably find amounts on receipts. Receipts also have subtotal, tax, tip and change lines, so picking the real total needed custom patterns and rules. Date ambiguity: 09/11/2026 can mean two dates. We read it as day/month, matching the spec, and ask the employee to confirm. Keeping AI from approving anything: we made it impossible in code. Approved and authorised statuses can only be set by a human, and every status change goes through one checked path. Honest payments: with no PayPal credentials the app needed a demo mode that never claims a payment happened. We also had to handle timeouts, where we can’t tell whether PayPal received the request. Demo data: seeded history couldn’t be marked as paid, because no real payment occurred. Accomplishments that we’re proud of The $350 hotel receipt runs end to end through the real pipeline: extraction, $150 excess, duplicate check, risk score, explanation, manager and finance approvals, and an audit trail. Human approval is enforced in the code and covered by tests, so no agent can approve or pay anything. Real OCR works on an image receipt, not just text files. The app starts with one command and loads a full demo company with realistic scenarios. The interface looks like a finance product rather than a class project.
What we learned
The safest way to add AI to a financial workflow is to make it advisory and enforce the limits in code, not in prompts. Deterministic rules suit money calculations; machine learning suits spotting unusual patterns. Systems that handle money should fail safe. An error should send an expense to human review and never approve it. Honest limits make a demo more credible than a simulated success.
What’s next for SpendPilot AI
Test the PayPal integration against live Sandbox servers with real credentials, and add webhook-based payment confirmation. Support multi-currency policies with live exchange rates. Improve OCR for crumpled or low-quality photos, and add layout-aware extraction. Add email or Slack notifications for pending approvals. Add mobile receipt capture. Learn from approval history to improve recommendations and reduce false alerts. Add production deployment with a WSGI server, HTTPS, persistent login protection and a PostgreSQL option for larger teams.