Inspiration

Agro-export is one of Peru's most important economic engines — but it's also an industry where trust is fragile. Buyers and certifiers rely on paper trails and self-reported records to verify that a shipment meets sustainability standards. Those records can be altered, backdated, or fabricated, and by the time anyone notices, the produce is already on a container ship halfway across the ocean.

We started AlerTrace as an IoT monitoring platform for agro-export supply chains, and through that work — including a pilot conversation with CITEagroindustrial Moquegua — we kept running into the same problem: sensors can tell you the truth about a shipment's conditions, but nothing was verifying that the documents describing that shipment hadn't been tampered with afterward. TraceOn was born from that gap: instead of just collecting data, it verifies it.

What it does

TraceOn is an AI-powered traceability verifier for agro-export supply chains. It runs a local, on-device AI agent that reads traceability documents — certificates, shipment logs, condition reports — and flags inconsistencies that would indicate tampering, duplication, or fraud.

Every verified record is sealed using a local SHA-256 hash-chain stored in SQLite, creating an append-only, tamper-evident ledger. If someone alters a past record, the chain breaks and the inconsistency is immediately visible — no central authority or blockchain network required.

Because the AI agent runs on-device (Qwen 2.5 3B, 4-bit quantized via Tether QVAC), verification can happen without sending sensitive supply chain data to the cloud, which matters for exporters who don't want proprietary shipment data leaving their infrastructure.

How we built it

  • AI verification layer: Qwen 2.5 3B (quantized Q4_K_M, ~2.5GB footprint), running fully on-device through Tether QVAC — zero cloud calls, zero network traffic. A Pydantic-enforced retry loop catches and self-corrects schema validation failures in real time.
  • Deterministic tools layer: all numeric computation (thermal degradation metrics, hash generation) runs in pure Python, never inside the model — the LLM only extracts and reasons, never calculates.
  • Integrity layer: a SHA-256 hash-chain sealing every event (payload_hash + previous chain_hash), persisted in SQLite, so any tampering is immediately detectable and localized to the exact corrupted record.
  • Backend: FastAPI (Python 3.11+), exposing a REST API plus a Server-Sent Events stream so the frontend can show the agent's reasoning, tool calls, and retries live as they happen.
  • Frontend: React 19 + TypeScript + TailwindCSS dashboard — document and telemetry ingestion, a live agent console, a hash-chain explorer, and certificate export.
  • Origins in AlerTrace: TraceOn grew out of AlerTrace, our IoT traceability platform incubated at Despega 3G Hub Tecnológico with backing from ProInnóvate/PRODUCE, refocused specifically on document and data integrity verification.

Challenges we ran into

Getting a 3B-parameter model to reliably produce structured, schema-valid output on the first try was harder than expected. Small models are prone to malformed JSON and inconsistent field extraction, especially on noisy or low-quality scans. We addressed this by building a validation-and-retry loop: when Pydantic schema validation fails, the exact error is fed back into the prompt and the model retries — visible in real time via Server-Sent Events.

To prove this approach actually works rather than just assuming it, we built a 42-case empirical benchmark suite across four categories: clean documents, noisy/low-quality scans, fraud cases (tampered specs, mismatched lot codes), and adversarial cases (prompt injection attempts, malformed JSON). On consumer laptop hardware, the system achieves 80.4–98.4% field extraction accuracy, with 57.1% of cases passing schema validation on the first attempt and the retry loop recovering another 42.9%. Median extraction latency is 1,602 ms, fully on-device with zero network calls.

What we learned

We learned that reliability for small on-device models comes less from the model itself and more from the system wrapped around it: deterministic Python tools for anything numeric (so the LLM never does arithmetic), explicit uncertainty handling (allowing null instead of forcing a guess on unreadable fields), and a visible self-correction loop instead of a silent black box. That combination — a 3B model plus disciplined engineering constraints — let us hit accuracy levels we didn't expect from a model that fits in under 3GB of RAM.

We also learned the value of designing for adversarial inputs from day one: including prompt-injection attempts in our own benchmark suite forced us to harden the system against manipulation, not just against messy real-world documents.

What's next for TraceOn

  • Expand document types the AI agent can verify (customs forms, cold-chain logs, phytosanitary certificates)
  • Pilot with a real agro-export partner to validate detection accuracy on real fraud patterns
  • Explore a lightweight public verification portal so buyers/certifiers can check a shipment's hash-chain without needing platform access

Built With

Share this project:

Updates

Submission history