AWS Builder Center

Building FarmMitra with AWS: From idea to Deployment

Learn how we built FarmMitra—a serverless agricultural marketplace powered by Amazon Cognito, DynamoDB, AWS Lambda, API Gateway, Amazon SNS, and CloudWatch—to eliminate monopsony pricing and connect Indian farmers directly with verified commercial buyers.

  1. Introduction & Problem Statement In India's agricultural sector, smallholder farmers often face a major structural challenge: limited visibility into market prices outside their local mandis (regional trading yards). Relying on single local traders or intermediaries leads to severe information asymmetry, forced price acceptance, and reduced profit margins.
FarmMitra was built to solve this exact problem:
"Connect farmers with multiple commercial buyers (wholesalers, retailers, food processors, supermarkets) and allow transparent crop offer comparison so farmers can make better-informed selling decisions."
Rather than building a complex, bloated app, FarmMitra focuses on one core marketplace loop: FARMER LISTS CROP ➔ BUYER DISCOVERS CROP ➔ BUYER MAKES OFFER ➔ FARMER COMPARES OFFERS ➔ FARMER ACCEPTS ➔ DIRECT DEAL
  1. AWS Serverless Architecture To ensure zero infrastructure maintenance, high scalability, and sub-second response times, we built FarmMitra using a cloud-native serverless architecture on AWS:
text
┌────────────────────────────────────────────────────────────────────────────────┐ │ React SPA (Vite + Tailwind CSS) │ │ [ Ronas IT Mobile-First UX / Bottom Navigation Bar / PWA ] │ └──────┬───────────────────────────┬─────────────────────────────┬───────────────┘ │ Auth (JWT/Tokens) │ REST APIs / Gateway │ Image Assets ▼ ▼ ▼ ┌──────────────┐ ┌───────────────────┐ ┌───────────────────┐ │ Amazon │ │ Amazon API │ │ Amazon S3 │ │ Cognito │ │ Gateway │ │ Bucket │ └──────────────┘ └────────┬──────────┘ └───────────────────┘ │ ▼ ┌───────────────────┐ │ AWS Lambda │ │ (State Engine) │ └────────┬──────────┘ ├──────────────────────────────┐ ▼ ▼ ┌───────────────────┐ ┌───────────────────┐ │ Amazon │ │ Amazon SNS │ │ DynamoDB │ │ (Notifications) │ └────────┬──────────┘ └───────────────────┘ │ ▼ ┌───────────────────┐ │ Amazon │ │ CloudWatch │ └───────────────────┘ 3. Technical Deep-Dive: AWS Services Used 🔑 1. Identity & Role Security with Amazon Cognito We used Amazon Cognito User Pools and the AWS Amplify JavaScript SDK (aws-amplify) to handle authentication and session management.
User accounts are assigned one of three role claims:
FARMER: Access to produce listing creation (SELL MY CROP), side-by-side offer comparison, and deal closure. BUYER: Access to produce discovery grid (FIND CROPS), multi-parameter filters, and direct offer submission. ADMIN: Access to commercial buyer verification, account moderation, and CloudWatch metrics monitoring. Cognito custom attributes persist buyer business verification statuses (PENDING, VERIFIED, REJECTED, DISABLED), allowing verified buyers to display a ✓ Verified Buyer badge across the platform.
⚡ 2. Low-Latency NoSQL Persistence with Amazon DynamoDB All core marketplace records are persisted in Amazon DynamoDB:
Users Table: Stores user profiles, contact information, role groups, and verification states. CropListings Table: Stores produce details (cropName, quantity, unit, expectedPrice, location, availabilityDate, imageUrl, status). Offers Table: Stores buyer price bids (offerPrice, quantity, message, status). Deals Table: Stores binding confirmed agreements (agreedPrice, totalValue, createdAt). DynamoDB's single-digit millisecond latency ensures instantaneous produce search results and listing updates.
⚙️ 3. Offer Processing & Deal Generation with AWS Lambda We used AWS Lambda as a serverless state machine controller for executing transaction logic:
javascript
// AWS Lambda State Controller: Accepting an Offer & Generating a Binding Deal const acceptOffer = async (offerId, farmerId, listingDetails) => { // 1. Validate farmer ownership of listing const targetOffer = await db.getOffer(offerId); if (targetOffer.farmerId !== farmerId) throw new Error("Unauthorized"); // 2. Transition offer status to ACCEPTED await db.updateOfferStatus(offerId, "ACCEPTED"); // 3. Generate binding Deal record const newDeal = { dealId:  dl_${Math.random().toString(36).substring(2, 9)} , listingId: targetOffer.listingId, farmerId: targetOffer.farmerId, buyerId: targetOffer.buyerId, agreedPrice: targetOffer.offerPrice, quantity: targetOffer.quantity, totalValue: targetOffer.offerPrice * targetOffer.quantity, status: "CONFIRMED", createdAt: new Date().toISOString() }; await db.saveDeal(newDeal); return { success: true, deal: newDeal }; }; 🔔 4. Event-Driven Alerts with Amazon SNS When key marketplace events occur, backend controllers publish topic messages to Amazon SNS (Simple Notification Service):
Event 1 (Buyer sends offer) ➔ Amazon SNS notifies Farmer: "New offer received! Wholesale Agro Traders offered ₹19/kg for your Tomato (500 kg)." Event 2 (Farmer accepts offer) ➔ Amazon SNS notifies Buyer: "Your offer of ₹21/kg for Tomato has been ACCEPTED! Direct deal confirmed." Event 3 (Farmer rejects offer) ➔ Amazon SNS notifies Buyer: "Your offer of ₹19/kg for Tomato was rejected by the farmer." The frontend NotificationBell component subscribes to these event streams, displaying real-time unread badges (🔔 2) and notification popover drawers.
📊 5. Real-Time Observability with Amazon CloudWatch We configured an Amazon CloudWatch log stream (/aws/lambda/FarmMitraBackendHandler) and custom metric namespace (FarmMitra/Marketplace) to log operational health metrics:
Active registered farmers & verified commercial buyers count Active crop harvest listings & total volume (kg) Total buyer offers created vs. accepted API Gateway HTTP latency & Lambda execution error rates These metrics are rendered live on an embedded CloudWatch Telemetry Widget inside the Admin console.
  1. Mobile-First Ronas IT UI Design Because Indian farmers primary access device is a smartphone, the frontend was built using Vite + React + Tailwind CSS with strict mobile-first design principles:
Large Touch Targets (>48px): Simple, high-contrast CTA buttons ([ SELL MY CROP ] and [ FIND CROPS ]). 📍 Auto-Location Detection: Integrates browser navigator.geolocation and reverse-geocoding so farmers can detect their District & State in one tap. Exact Produce Photo Matcher: Automatically matches crop names (e.g. Soyabean, Cotton, Tomato, Sugarcane) to verified produce photography. Mobile Bottom Navigation Bar: Floating active pill navigation designed following Ronas IT design patterns. 5. Benchmark Demonstration Scenario The completed MVP successfully demonstrates the core value proposition:
text
FARMER (Ramesh Kumar, Bidar, Karnataka) Crop: Tomato (1,000 kg @ ₹18/kg expected) │ ▼ PUBLISHED │ ├──────────────────────────────────────┐ ▼ ▼ BUYER A (Wholesale Agro Traders) BUYER B (FreshSupermarket Ltd) Offer: ₹19/kg for 500 kg Offer: ₹21/kg for 800 kg │ │ └──────────────────┬───────────────────┘ ▼ FARMER COMPARES OFFERS (Side-by-side comparison displays +₹3 delta) │ ▼ FARMER ACCEPTS BUYER B │ ▼ DIRECT DEAL CONFIRMED Total Value: ₹16,800 (800 kg @ ₹21/kg) 6. Key Takeaways & Conclusion Building FarmMitra on the AWS Serverless stack demonstrated how cloud-native tools allow a small engineering team to ship a secure, highly scalable, and real-world impactful marketplace application in record time.
By combining Amazon Cognito for trust, DynamoDB for sub-second speed, AWS Lambda for business logic, Amazon SNS for notifications, and AWS Amplify Hosting for CI/CD, FarmMitra gives Indian farmers the transparent pricing power they deserve.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article