Project Name

Panenin: A WhatsApp-Based AI Assistant and OpenClaw as a Smart Solution for the Food Supply Chain Between Farmers and SMEs

Inspiration

Panenin was inspired by a price gap that we often see between what farmers receive for their harvest and what buyers eventually pay. One of the reasons behind this gap is the role of intermediaries, or tengkulak, who often become the bridge between farmers and harvest buyers.

Intermediaries can be useful in the supply chain, but when farmers and buyers have no direct way to communicate, important information becomes fragmented. Farmers may not know who needs their produce, how much they need, or what price they are willing to pay. Buyers, on the other hand, may struggle to find reliable produce directly from its source.

This creates a deeper distribution problem. A harvest can be available in one place while demand exists somewhere else, but there is no transparent system connecting both sides. As a result, farmers may receive a lower selling price, buyers may pay a higher final price, and large amounts of fresh produce can remain unsold until they deteriorate and become waste.

We wanted to build a system that directly connects farmers with the people and businesses who need their harvest. That idea became Panenin: a mobile-first marketplace where farmers can publish their available produce, buyers can communicate their needs, and both sides can discover suitable matches based on commodity, quantity, price, quality, and availability.

We also wanted Panenin to fit naturally into the way users already communicate. That is why we added a WhatsApp companion alongside the mobile application. Farmers and buyers can access important account information and interact with Panenin through a familiar channel, instead of being forced to learn an entirely new communication system.

Our vision is to make the agricultural supply chain more transparent, efficient, and mutually beneficial helping farmers receive fairer opportunities, helping buyers find more reliable supplies, and reducing the amount of harvest that goes unsold and eventually goes to waste.

What it does

Panenin is a two-sided agricultural marketplace prototype with a working backend core and a Flutter application for farmers and buyers.

For farmers, the current application and backend support:

  • Creating high feasability for farmers especially their are from old age and lack of technology use, based on the research their behaviour about technology is "tidak mau ribet" to solve this, we invent our idea to make an assistant for the farmers to sell, manage, and control their sellings in easiest way.
  • Based on the data, we conclude that most of old man (majority of farmers) use handphone, and the most used apps is whatsapp, so we make an AI Assistant based on RAG Groq API for their consultation partner, and to assist them in easiest way by making a assistant to manage their selling by integrating OpenClaw API for daily assist and communication. Users still can use the application in normal way, but we make it easier by making WhatsApp room chat to be their remote controll to selling their harvest to people out there. They can do such as :
  • Creating and updating harvest inventory batches.
  • Recording commodity, quantity, unit, harvest date, availability date, grade, and minimum price.
  • Viewing inventory and remaining quantities.
  • Using a Quick Sell flow that captures a harvest photo and then opens the stock form.
  • Viewing buyer demand cards and active order information on the farmer dashboard.
  • Connecting a Panenin account to WhatsApp through a short-lived linking code.

For buyers and food businesses, Panenin currently provides:

  • A buyer home screen that loads available listings from the Panenin API.
  • Commodity categories and product discovery.
  • Search and marketplace interaction entry points.
  • Typed prototype screens for product details, price negotiation, recurring supply, messages, and buyer order tracking.
  • Backend endpoints for creating and listing demands, searching catalog listings, viewing matches, and reading orders.

Some buyer-facing marketplace screens are intentionally implemented as UX prototypes using typed fixtures while their corresponding production endpoints are being integrated. The working backend already contains the underlying domain models and services for listings, demands, matching, inventory, and orders.

Deterministic matching

Panenin does not rely on an opaque AI recommendation for marketplace matching.

The backend filters and ranks compatible listings and demands based on:

  • Exact commodity compatibility.
  • Exact unit compatibility.
  • Maximum buyer price.
  • Available quantity.
  • Required or available date.
  • Grade tolerance.
  • Quantity coverage.

Each match is persisted with a score and structured reasons so that the result can be inspected and explained.

WhatsApp companion

Panenin also includes a separate TypeScript WhatsApp service connected through Fonnte webhooks.

The current WhatsApp flow supports:

  • HUBUNGKAN <kode> for secure account linking.
  • STATUS AKUN for checking whether a WhatsApp channel is linked.
  • RINGKASAN for reading a redacted account summary.
  • MENU, BANTUAN, and BATAL commands.
  • TANYA: knowledge queries answered through retrieval-augmented generation.
  • Optional OpenClaw-based conversational routing.

The core backend also exposes an internal agent API for identity resolution, inventory context, catalog search, action previews, confirmation, cancellation, and transactional action handlers. This API is designed to keep language interpretation separate from business-rule execution. The current WhatsApp integration focuses on account and knowledge flows, while the transaction orchestration layer is prepared for further integration.

How we built it

The frontend was built with Flutter and Dart. It contains separate flows for authentication, role selection, farmer dashboards, inventory, quick selling, buyer discovery, orders, profiles, and WhatsApp linking.

The core backend was built with Python, FastAPI, asynchronous SQLAlchemy, and Pydantic. Its modules cover:

  • Authentication and user access.
  • Organizations and farmer/buyer profiles.
  • Inventory batches and stock movements.
  • Listings and catalog access.
  • Buyer demands.
  • Deterministic matching.
  • Orders, reservations, and status transitions.
  • WhatsApp identity linking.
  • Internal agent actions.

Supabase provides authentication and PostgreSQL infrastructure. Database migrations define the domain schema, row-level security policies, inventory reservations, order history, audit logs, WhatsApp channel records, bot actions, and knowledge tables. The project also includes pgvector support for semantic knowledge retrieval and migration support for real-time updates on selected domain tables.

The WhatsApp service was built with Node.js and TypeScript. It normalizes Fonnte webhook payloads, rejects invalid webhook requests, deduplicates incoming messages, stores sanitized message records, routes commands, and sends responses back through Fonnte.

For AI and knowledge retrieval, the project uses:

  • Groq for text generation.
  • Google Gemini embeddings for semantic search.
  • PostgreSQL and pgvector for vector retrieval.
  • OpenClaw as an optional conversational gateway.
  • A read-only local RAG tool for knowledge lookup.

The architecture intentionally keeps FastAPI as the only component allowed to apply Panenin business rules or mutate the core public schema. The Flutter application and WhatsApp service communicate with the backend through APIs instead of directly changing business data.

Challenges we ran into

Designing one domain for multiple interfaces

Panenin has both a Flutter application and a WhatsApp service. We needed both interfaces to use the same definitions for users, organizations, inventory, demands, listings, matches, and orders.

We solved this by making FastAPI the single business authority. The clients are responsible for presentation and communication, while the backend owns validation, authorization, transactions, and state changes.

Separating AI interpretation from transactions

A language model can interpret a user's intent, but it should not directly modify inventory or orders. We designed an internal agent API with preview, confirmation, cancellation, expiration, idempotency, and explicit action handlers.

This allows Panenin to use AI for conversational understanding while keeping sensitive operations deterministic and auditable.

Protecting WhatsApp identity

We needed to link a WhatsApp channel to a Panenin account without spreading raw phone numbers throughout the core system.

Panenin uses an opaque channel subject derived from the sender identity and a separate secret. Account linking uses a short-lived one-time code. The backend stores a protected representation of the code and consumes it after successful linking.

Handling inventory concurrency

Orders can compete for the same available harvest. The backend therefore uses database transactions, row locks, inventory reservations, server-side total calculations, idempotency keys, and explicit order status transitions.

This makes it possible to reserve stock when an order is created, release it when an order is rejected or cancelled, and consume the reservation only when the order is completed.

Keeping knowledge answers grounded

The assistant should not invent agricultural information or platform rules. The RAG pipeline chunks knowledge documents, generates embeddings, retrieves relevant passages, and instructs the model to answer only from retrieved context.

The WhatsApp service also includes timeouts, retries, fallback responses, and fallback AI models so the system can degrade safely when an external provider is unavailable.

Accomplishments that we're proud of

We are proud to have built a structured agricultural marketplace foundation instead of only creating static screens.

The project includes:

  • A Flutter application with separate farmer and buyer experiences.
  • A working FastAPI core for inventory, listings, demands, matching, orders, profiles, and WhatsApp linking.
  • Explainable deterministic matching with persisted scores and reasons.
  • Auditable inventory movement records.
  • Transaction-safe order and reservation logic.
  • Privacy-preserving WhatsApp identity linking.
  • An OpenAPI contract for the internal agent API.
  • A grounded RAG knowledge pipeline.
  • Webhook deduplication and safe failure handling.
  • Automated tests covering backend contracts, authentication, security, Flutter components, webhook processing, AI routing, RAG, and OpenClaw integrations.

What we learned

The most important lesson was that AI should make a product easier to use without becoming the authority over critical business data.

Language models are useful for interpreting natural language and answering questions. However, authorization, inventory quantities, order totals, confirmation codes, and state transitions need to remain explicit, deterministic, and testable.

We also learned that building a marketplace requires more than displaying listings. The data model must account for harvest batches, quantities, grades, availability dates, buyer demands, reservations, order states, and audit history.

Finally, we learned that accessibility includes meeting users in channels they already understand. Combining a structured Flutter application with WhatsApp gives Panenin a foundation for serving users with different levels of digital familiarity.

What's next for Panenin

Our next steps are to:

  • Complete production integrations for buyer product details, negotiation, recurring supply, and buyer order flows.
  • Connect WhatsApp conversations to the internal action preview and confirmation API.
  • Add geospatial distance and logistics factors to matching.
  • Expand the verified agricultural knowledge base.
  • Improve Rescue Harvest recommendations using shelf-life information.
  • Add delivery and payment integrations.
  • Strengthen rate limiting and operational monitoring.
  • Test the product with real farmers and food businesses.

Our long-term vision is for Panenin to become a transparent digital bridge between harvest and demand helping farmers reach buyers more directly, helping small businesses find more reliable supplies, and reducing the amount of produce that remains unsold.

Built With

Share this project:

Updates