DEV Community

Cover image for SponsorLedger: Taming Post-Event Financial Chaos with Gemma, MongoDB Atlas, and Deterministic Python Audits
Diptodeep Biswas
Diptodeep Biswas

Posted on AI-assisted

SponsorLedger: Taming Post-Event Financial Chaos with Gemma, MongoDB Atlas, and Deterministic Python Audits

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission πŸ’Έ

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle


Running a hackathon, student conference, or community meetup is exhilaratingβ€”until Monday morning.

The energy fades, and organizers face a financial hangover:

  • A crumpled pile of thermal paper receipts paid out of personal accounts.
  • Unstructured WhatsApp messages and emails from vendors demanding bank transfers.
  • Sponsor commitments scattered across chats, with nobody sure whose wire actually cleared.
  • Deliverables (stage mentions, logo placements, booth slots) promised in a rush and forgotten.
  • The nagging question: Did we break even, or are we paying for this out of our own pockets?

Enterprise accounting software like QuickBooks or Expensify costs $30–$80/month, requires tedious chart-of-accounts setup, and doesn't fit the scrappy, fast-moving reality of event operations.

I built SponsorLedger to solve this.


What I Built

SponsorLedger is an evidence-linked financial auditing and sponsorship reconciliation workspace for event leads and student communities.

It replaces spreadsheet chaos with three core systems:

  1. Gemma AI Irregular Text-to-CSV Ingestion: Event leads rarely get clean bank CSVs. They get informal WhatsApp notes ("Print House delivered banners on 2026-09-01 for 4,500 INR, ref RCPT-001"). Using Google's open-weight Gemma 4 26B, SponsorLedger extracts dates, vendors, categories, amounts, and receipt IDs into verified tabular rows in seconds.
  2. Deterministic Invariant Audit Engine: AI never does the math. All monetary calculations use base integer units in pure Python, evaluating 7 deterministic rules (budget overruns, unpaid sponsor balances, deliverable deadlines, duplicate expenses, missing receipts).
  3. Evidence-Linked Audit Trail & Gemma Closeout Dossier: Every discrepancy links directly to the underlying expense or sponsor record via a slide-over modal. When books close, Gemma synthesizes verified numbers into an executive summary and closing checklist.

Who Pays and Why?

  • Target Audience: Hackathon organizers, college club leads, independent conference producers, and freelance event operations managers.
  • The Value: A single missed $1,000 sponsor collection or an accidental $400 duplicate catering payment can wipe out a community event's entire reserve.
  • Commercial Model: A permissive open-source core (GNU AGPLv3) paired with a $19 per-event hosted pass (or $149/year community license). Paying $19 to protect thousands in sponsor receivables and hand university deans a clean audit dossier is an easy decision.

Demo

Try It in 60 Seconds (No Sign-Up Needed)

  1. Open https://sponsorledger.onrender.com and click Launch App / Continue via Guest Mode.
  2. You get an Anonymous Cloned Sandbox in MongoDB. Multiple visitors can test simultaneously without data cross-contamination.
  3. Switch display currencies in the header (USD, EUR, INR, GBP, JPY) to see live FX recalculations across all dashboard charts.
  4. Go to Expenses (/expenses), click "Try Sample Irregular .txt", and watch Gemma transform raw notes into structured rows.
  5. Go to Audit (/audit) to inspect duplicate receipts or unpaid pledges, and click any badge (RCPT-001) to inspect evidence.
  6. Open Report (/report) to generate an executive briefing synthesized by Gemma.

Code

git clone https://github.com/diptodeepb/SponsorLedger.git
cd SponsorLedger
python3 start.py
Enter fullscreen mode Exit fullscreen mode

How I Built It

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               React 19 + Vite Frontend                 β”‚
β”‚   (Tailwind CSS, Lucide Icons, Sentry Browser Tracing) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚ REST / JSON (FastAPI)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FastAPI Backend                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Pure Python Audit β”‚        β”‚ Live FX Service     β”‚  β”‚
β”‚  β”‚ (Exact Base Math) β”‚        β”‚ (forex-python)      β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚            β”‚                             β”‚             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ MongoDB Atlas     β”‚        β”‚ Gemma 4 (26B)       β”‚  β”‚
β”‚  β”‚ (48h TTL Sandbox, β”‚        β”‚ (Text2CSV + Report, β”‚  β”‚
β”‚  β”‚  DateCodec, M0)   β”‚        β”‚  Strict JSON Schema)β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

1. Invariant: "AI Does Not Do Math"

LLMs hallucinate arithmetic and drop numbers when summing ledger rows. In SponsorLedger:

  • Exact Base Integer Math: All monetary amounts are stored in base integer subunits (paise / cents), eliminating floating-point rounding errors.
  • 7 Deterministic Audit Rules:
Rule Code Severity Description Evidence Traced
BUDGET_OVERRUN High Total expenses exceed budget ceiling Total expenses vs budget
SPONSOR_BALANCE_DUE High / Med Outstanding pledged amount past event date Pledge vs received records
SPONSOR_OVERPAYMENT Medium Received funds exceed agreed commitment tier Sponsor ledger entry
DELIVERABLE_OVERDUE High Sponsor deliverable past agreed deadline Deliverable due date
POSSIBLE_DUPLICATE Medium Matching vendor and amount within nearby dates, or identical receipt ref Correlated expense records
MISSING_RECEIPT_REF Low Expense recorded without receipt voucher Expense row
MISSING_CATEGORY Low Expense has no category or marked Unknown Expense row

2. Dual Gemma Pipelines (gemma-4-26b-a4b-it)

Google's open-weight Gemma 4 26B runs two structured tasks:

  • Irregular Text-to-CSV: Parses messy WhatsApp messages and unformatted notes into standard CSV schema (date,vendor,category,amount_inr,receipt_ref,notes). It normalizes informal dates ("yesterday", "14 Oct") and categorizes spending.
  • Executive Closeout Briefing: Receives verified ledger totals and open audit findings to draft an executive narrative, priority action items, and a closing checklist using strict Pydantic schemas. Post-processing cleans any accidental internal subunit terms.

3. MongoDB Atlas Isolated Guest Sandboxes

To let judges and visitors test live without stepping on each other:

  • The frontend assigns an ephemeral X-Guest-Session token in localStorage.
  • The backend clones an isolated sandbox dataset (event, sponsors, deliverables, expenses) tagged with that session.
  • Automated 48-Hour TTL Indexing: MongoDB Atlas purges sandbox collections automatically after 48 hours using expireAfterSeconds=172800 on created_at. No cron scripts needed.
  • Three one-click controls: Reset to Demo Data, Clear All Data ($0 clean slate), and New Guest Session.

4. Hard Bugs & Engineering Gotchas

  1. BSON Date Serialization: PyMongo rejects raw Python datetime.date objects. Instead of manual string casting across every endpoint, we registered a custom BSON DateCodec TypeRegistry that transparently serializes dates to ISO strings.
  2. Empty Ledger Guardrail: Generating reports on an empty sandbox ($0 budget, 0 expenses) caused the model to hallucinate placeholder sponsors. We locked report generation with a hard guardrail requiring at least one transaction.
  3. Sentry Tunneling (/api/tunnel): Privacy browsers (Brave Shields, uBlock) blocked Sentry envelope requests. We built a reverse proxy endpoint in FastAPI (/api/tunnel) to route telemetry cleanly without third-party tracking flags.

Why Does Open Innovation Matter?

Metric Closed SaaS (QuickBooks / Expensify + AI) SponsorLedger (Open-Weight Gemma + Open Source)
Cost per Event $30–$80/month ongoing subscription $0 to $0.002 compute cost
Data Privacy Sensitive contracts uploaded to proprietary LLM APIs 100% auditable code; data stays in your MongoDB
Vendor Lock-in Subject to API price hikes and deprecated tiers AGPLv3 code; runs locally or self-hosted forever
Offline Resilience Zero functionality without internet Deterministic audit engine works completely offline

Open weights make modern financial tooling accessible to student clubs and non-profit hackathons that cannot justify enterprise SaaS subscriptions.


Prize Categories

🌟 Best Use of Gemma (Featured Category)

Google's open-weight Gemma 4 26B (gemma-4-26b-a4b-it) powers irregular text-to-CSV ingestion and structured executive closeout report generation, wrapped in deterministic guardrails and Pydantic validation.

πŸš€ Best Use of Render (Featured Category)

Orchestrated via a production render.yaml blueprint:

  • sponsorledger-backend: FastAPI Python 3.12 Web Service in Singapore with automated health checks.
  • sponsorledger: React 19 + Vite Static Site on Render's Global CDN with SPA rewrites (/* -> /index.html).

πŸƒ Best Use of MongoDB Atlas (Partner Category)

MongoDB Atlas M0 cluster provides isolated multi-user guest sandboxes, automated 48-hour TTL cleanup indexing, and custom BSON DateCodec serialization.

πŸ›‘οΈ Best Use of Sentry Agent Tracing (Partner Category)

Full-stack Sentry telemetry across FastAPI and React 19, featuring an internal /api/tunnel proxy endpoint to bypass client-side ad-blockers.

πŸ™ Best Use of GitHub Copilot (Partner Category)

Automated with GitHub Actions CI workflows running on every push and pull request across main, master, and dev:

  • Backend Automated Testing: Python 3.12 CI job with pip dependency caching executing the complete 65-test pytest suite for exact integer math and audit invariants.
  • Frontend Build Verification: Node.js 22 CI job with npm caching validating strict production Vite asset compilation.

Appreciate everyone reading thus far! Test the live sandbox at sponsorledger.onrender.com or view the source on GitHub.*

Top comments (0)