About
## Challenges we ran into
1. **Ollama Model Loading Timeouts (The 502 Bad Gateway Cascade)** We initially tried to load the heavy `gemma3:4b` model dynamically for document extraction. However, the laptop's hardware took more than 30 seconds to load it into memory. The backend had a hardcoded 30-second timeout, which would trigger a "fallback" to `gemma:2b`. Because Ollama processes one model at a time, this queued a *second* cold-load behind the first one, guaranteeing a complete timeout cascade and a 502 Bad Gateway error on every single file upload from the Flutter app. We fixed this by prioritizing `gemma:2b`, removing the silent fallback, and bumping the FastAPI timeouts.
2. **Container vs. Host Clock Skew (The 401 Unauthorized)** The Flutter app was correctly generating Firebase Auth tokens to submit the final application. However, because the Docker container running the backend had an internal clock that was exactly 1 second behind the host laptop/phone, the Firebase Admin SDK rejected the token for being "used in the future" (`Token used too early`). We resolved this by explicitly adding a 60-second clock skew tolerance to the token verification logic.
3. **Data Contract Mismatches (The `KeyError`)** The Flutter frontend serialized the document type in the JSON payload as `"document_type"`, but the backend's deterministic Stage 2 layer (the Entity Consistency Check) was strictly expecting `"doc_type"`. This caused the backend to instantly crash right as it tried to evaluate the documents. We patched the backend to safely accept the correct key.
4. **LLM Hallucinations Crashing Deterministic Code (The 500 Error)** Because Gemma was extracting data directly from messy, unstructured images (like GST filings), it occasionally hallucinated invalid dates (like `2023-09-31`). When our strict Python signal layer tried to convert those strings into native `datetime` objects to calculate transaction velocity bursts, it threw a `ValueError` (day out of range), crashing the entire scoring pipeline. We made the code resilient by wrapping the date parsers in `try/except` blocks to gracefully skip unparseable dates.
5. **Silent Database Failures**
The backend was designed to save scored cases to Firebase Firestore. However, because the cloud credentials weren't fully configured yet for local testing, the backend silently threw the scored cases away after processing them. This resulted in the mobile app showing "Pending", but the Next.js Officer Dashboard showing an empty queue. We solved this by building a resilient local in-memory fallback store so the pipeline could function flawlessly without cloud infrastructure.
## The problem it solves
**AuditGemma** solves the problem of slow, manual, and error-prone financial compliance reviews.
Traditionally, when a Small or Medium Enterprise (SME) applies for a loan or undergoes an audit, a human compliance officer has to manually read through unstructured images and PDFs (KYC documents, bank statements, invoices), manually cross-reference data across those files to catch discrepancies, and hunt for subtle fraud patterns like money laundering via rapid transaction bursts.
AuditGemma automates this entire bottleneck. It uses Gemma's native vision capabilities to instantly extract structured data from messy images, runs deterministic code to catch exact-match discrepancies (e.g., mismatched tax IDs) and transaction velocity fraud, and then uses Gemma's reasoning to generate a final risk score and a human-readable narrative. This turns hours of manual auditing into a near-instant, AI-assisted workflow, allowing human officers to simply review the final narrative and make the final "Approve" or "Escalate" decision.
Team
From the public Devfolio project page. Votes, swipes and the judge score are hackfeed's own.






