Inspiration
Indonesia is one of the world's largest fresh-produce economies, yet an estimated 30-40% of harvested fruits and vegetables are lost before they ever reach a consumer. A major driver isn't logistics alone: it's the information gap between the farm and the city. Smallholder farmers like Amara have no standardized way to prove the quality of their harvest, so they're forced to sell through chains of quality-and-trust brokers, each adding a markup. Meanwhile, buyers like Chef Rosa in Jakarta can only guess at freshness and grade until the crate arrives.
We asked ourselves: what if a single smartphone photo could replace the quality broker? What if verified grading data, transparent pricing, and a safe escrow payment could all happen in one direct flow, from farm to buyer, with no middleman markup?
That question became YieldGrid: a direct farm-to-buyer marketplace where AI grades the produce, blockchain secures the payment, and shelf-life-aware matching ensures nothing goes to waste.
What it does
YieldGrid replaces the two core jobs of a quality broker, grading and trust, with technology:
AI-Powered Visual Grading. A farmer photographs their crate. The backend submits the image to a Vision Language Model (currently Gemma 4 26B via OpenRouter) with a crop-specific prompt mapped to Codex Alimentarius standards (CXS 293-2008 for tomatoes, CXS 205-1997 for bananas). The model returns a structured grade distribution (A / B / Reject percentages), observed defects, estimated weight, shelf-life band, and a suggested unit price, all from a single photo.
IPFS-Anchored Proof. The photo and signed grading metadata are pinned to IPFS via Pinata, creating a tamper-proof, publicly verifiable quality certificate.
Direct Marketplace. Graded listings appear in real-time on the buyer dashboard via WebSocket. Buyers can filter by demand segment (retail kitchen, wholesale, processing) and see the exact grade mix, Codex standard reference, shelf-life, and direct farm price before purchasing.
Stellar Escrow Settlement. When a buyer clicks "Buy Direct", funds are locked into a Soroban smart contract on Stellar testnet. The contract supports three operations:
create_order: buyer funds the escrowconfirm_delivery: happy path, releases full amount to farmersettle_with_discount: breach path (e.g. cold-chain violation), applies a parametric discount in basis points and refunds the remainder to the buyer
Shelf-Life-Aware Matching. Short shelf-life or Grade B batches aren't wasted; they're routed to wholesalers and processors who actually need them, turning potential waste into a buyer segment.
Farmer PWA. A mobile-first, single-action-per-screen interface optimized for one-handed outdoor use with high contrast and large touch targets.
How we built it
YieldGrid is a monorepo with four distinct service layers:
| Layer | Stack | Responsibility |
|---|---|---|
| Frontend | Next.js (React), TypeScript, Framer Motion, PWA | Farmer scan PWA, buyer marketplace dashboard, order tracking, settlement receipt, demo console |
| Backend | Spring Boot (Java), PostgreSQL, Supabase Auth | REST API, WebSocket hub, AI grading service (OpenRouter), IPFS pinning (Pinata), settlement orchestration |
| Escrow Contract | Rust / Soroban (Stellar) | Three-function on-chain escrow: create_order, confirm_delivery, settle_with_discount |
| Settlement Sidecar | Node.js / TypeScript, Stellar SDK | Off-chain bridge: wallet provisioning, YGIDR token minting, escrow invocation, cryptographic signing |
Key architectural decisions:
- Separation of concerns: The backend is the sole chain-caller; the frontend never touches private keys. The settlement sidecar handles all Stellar interactions behind a shared-secret bearer token.
- YGIDR token: A custom Stellar asset pegged to IDR (Indonesian Rupiah) with 7 decimal places, issued via a Stellar Asset Contract (SAC) for escrow denomination.
- Graceful degradation: When no OpenRouter API key is available, the grading service transparently falls back to a rehearsal cache, and this fallback is explicitly labeled in the UI ("REHEARSAL GRADING CACHE · disclosed fallback"). We never pretend.
- Structured AI output: The VLM request uses
temperature: 0, strict JSON Schema enforcement, a 60-second timeout, and crop-specific prompts limited to visually assessable criteria only.
Challenges we ran into
Making AI grading honest. It was tempting to have the VLM assess everything. Instead, we constrained prompts to visual-only criteria from Codex standards (color, surface defects, shape uniformity) and explicitly excluded anything requiring physical inspection (firmness, sugar content). Every grading result states "visual subset only".
Soroban contract design. The escrow needed to handle both the happy path (full release to farmer) and breach path (parametric discount). Getting the basis-point arithmetic right in
i128without floating point, while keeping the contract minimal (#![no_std]), required careful testing.Bridging Web2 and Web3 UX. Users see "Funds secured" and "Farmer paid"; they don't see "Soroban invocation". Making blockchain invisible while keeping it verifiable (transaction hashes, testnet explorer links) was a constant design tension.
Real-time state synchronization. The farmer's listing appears live on the buyer's dashboard via WebSocket. Escrow confirmation, transit simulation, and settlement events all need to propagate across multiple surfaces without page refresh. Coordinating this state machine across frontend demo context, backend WebSocket events, and sidecar callbacks was complex.
Cold-chain simulation boundaries. We needed to show how temperature breaches trigger parametric discounts, but real IoT telemetry was out of scope. We chose to simulate transit and persistently label every simulated element in the UI, never hiding the prototype boundary.
Accomplishments that we're proud of
End-to-end vertical slice: From a single crate photo to AI grade to IPFS proof to live marketplace listing to Stellar escrow lock to delivery verification to on-chain settlement to farmer payout notification, the entire flow works with real API calls and real testnet transactions.
Honest boundaries: Every simulated element (transit, cold-chain telemetry) is visibly labeled. The rehearsal grading cache is disclosed. We drew a clear line between "real path" and "simulated path" and made it part of the design, not something hidden.
Production-grade escrow contract: The Soroban contract is minimal (127 lines of Rust), fully tested, and handles edge cases: duplicate orders, zero amounts, double settlement, and invalid discounts all return proper errors.
Premium UX on a hackathon timeline: The farmer PWA feels like a real product, with haptic feedback on payout (
navigator.vibrate), animated grading spinner, live grade distribution bars, and a mobile shell with status bar. The buyer marketplace has real-time card injection, segment filtering, and a polished escrow confirmation modal.Bilingual design intent: The landing page and copy naturally mix Indonesian and English, reflecting how the actual users (Indonesian farmers and urban buyers) would interact with the product.
What we learned
Constrained AI is better AI. Limiting the VLM to visual-only Codex criteria produced more reliable, defensible grading results than asking it to assess everything. Less scope = more trust.
Blockchain is best when invisible. Users don't care about Soroban. They care about "is my money safe?" and "did the farmer get paid?". The best blockchain UX is one where the user never thinks about blockchain.
Honest prototyping builds credibility. Labeling simulated elements explicitly made our demo more convincing, not less. Judges and users trust a team that shows boundaries.
Monorepo discipline matters. Having
frontend/,backend/,contract/, andsettlement-sidecar/as clearly separated concerns with well-defined interfaces made parallel development possible even on a tight hackathon schedule.Codex Alimentarius is surprisingly accessible. International food standards like CXS 293-2008 (tomatoes) and CXS 205-1997 (bananas) define visual grading criteria that map naturally to what a camera can see. This was the foundation that made AI grading defensible.
What's next for YieldGrid
Real cold-chain IoT integration. Replace simulated telemetry with actual Bluetooth temperature loggers, enabling true parametric insurance / discount triggers based on real cold-chain data.
On-device grading. Move the VLM inference to on-device (e.g., MediaPipe or a quantized model) so farmers in areas with poor connectivity can still grade offline and sync when connected.
Multi-crop expansion. Extend the Codex-based grading rubric beyond tomatoes and bananas to cover more Indonesian staple crops (chili, mango, rice).
Mainnet migration. Move from Stellar testnet to mainnet with a real YGIDR stablecoin issuance, KYC integration, and regulatory compliance for payments.
Farmer reputation system. Build a verifiable on-chain reputation score based on historical grade accuracy, delivery success rate, and buyer feedback.
Cooperative aggregation. Enable farmer cooperatives to pool listings, aggregate supply, and negotiate better prices with large wholesale buyers as a group.
Built With
- alimentarius
- boot
- codex
- css
- framer
- gradle
- ipfs
- java
- motion
- next.js
- node.js
- pinata
- postgresql
- pwa
- react
- rust
- sdk
- soroban
- spring
- stellar
- supabase
- typescript
- websocket
Log in or sign up for Devpost to join the conversation.