Hacki
All BUIDLs

About the project

About the project

TraceOn is an on-device, zero-cloud cold-chain compliance and release auditor for agro-industrial exports. It combines a local 3B Small Language Model (SLM) via QVAC with deterministic Python tools and a SHA-256 cryptographic hash-chain ledger to audit batches in under 2 seconds with 100% data privacy.

---

The problem

Agro-export packing plants (e.g., avocados, blueberries, grapes) lose millions due to manual, slow (20–40 min/batch) release verification. Cloud-based LLMs cannot be used due to spotty packing plant connectivity, high recurring API costs, and strict compliance confidentiality concerns.

---

Our resolution

A 100% on-device AI agent architecture. The SLM handles natural language and document extraction with autonomous self-healing Pydantic retries, while deterministic Python tools calculate thermal physics (MKT, degree-minutes) and seal an immutable audit ledger—guaranteeing 0 KB of external network traffic.

---

What we built

  • Local Agentic Pipeline: Ingests shipping guides, COAs, and datalogger CSV/JSON files, extracting specs and evaluating compliance deterministically.
  • Self-Healing Extraction: Pydantic schema validation loop that feeds schema errors back to the SLM (RETRY_SUFFIX) for on-device autocorrection.
  • Tamper-Evident Ledger: SHA-256 hash-chain storing every audit step and instantly detecting database tampering.
  • Industrial Terminal UI: High-density dashboard with real-time SSE event streaming, telemetry graphs, and exportable PDF certificates.

---

How it Works

  1. Ingest: Dispatch guides (PDF/images) and dataloggers (CSV/JSON) are uploaded.
  2. Extract: Local SLM parses contract limits (temperature, expiry, lot) via structured few-shot prompts.
  3. Analyze: Python computes Haynes Kinetic Temperature (MKT), degree-minutes, and detects excursions.
  4. Decide & Seal: Compliance rules issue a deterministic verdict (APPROVED, QUARANTINE, REJECTED), sealed into the hash-chain ledger.

---

Where the inference happens (permalinks)

ComponentDescriptionPermalink
Local Client InvariantStrict local loopback validation (127.0.0.1 only)https://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/qvac/client.py#L39-L55
Structured SLM CompletionDual-mode SDK/HTTP JSON extraction with latency trackinghttps://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/qvac/client.py#L56-L141
Prompts & Anti-AdversarialFew-shot prompts, null-safety rules & injection defensehttps://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/qvac/prompts.py#L16-L72
Self-Healing Retry LoopPydantic error reinjection and auto-correction loophttps://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/agent/orchestrator.py#L59-L98
Deterministic Thermal EngineHaynes MKT, degree-minutes & excursion math in Pythonhttps://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/tools/telemetry.py#L1-L150
Cryptographic Hash-ChainTamper-evident SHA-256 ledger block sealinghttps://github.com/AlemEsv/TraceOn/blob/main/backend/src/traceon/ledger/chain.py#L1-L60

---

Models and hardware

ComponentSpecification
Primary SLMQwen/Qwen2.5-3B-Instruct
QuantizationQ4_K_M (4-bit integer weights, ~2.5 GB disk footprint)
OCR Pipelineqvac-ocr local vision pipeline (Base64 multimodal)
Alternative Drop-insLlama-3.2-3B-Instruct (Q4), Phi-3.5-mini-instruct (Q4)
Host HardwareDesktop PC · Intel Core i5-11400F (6C/12T @ 2.60 GHz – 4.40 GHz)
GPU / GraphicsAMD Radeon RX 7600 (8 GB GDDR6)
Memory (RAM)16 GB DDR4 RAM (TraceOn peak usage: ~2.8 GB RAM)
Inference LatencyTTFT: ~120 ms | Extraction (P50): 1,602 ms
Network Footprint0 KB internet traffic (strict 127.0.0.1 loopback invariant)

---

Limitations

  • Document OCR quality drops significantly on extremely crumpled or physical carbon-copy pages below 150 DPI.
  • A 3B SLM struggles when numbers are written entirely in verbose natural language without digits (e.g., "dos punto cinco a siete punto ocho").
  • The system processes one document batch at a time to stay within low-resource consumer RAM constraints.

---

How to run it

# 1. Initial setup
cd backend && make setup
cd ../frontend && pnpm install

# 2. Run backend
cd backend && make dev

# 3. Run frontend
cd frontend && pnpm dev