Welcome to the official documentation for Farmingo, an all-in-one web platform designed to empower farmers with modern technology. This document provides a comprehensive overview of the project's architecture, features, technology stack, and setup instructions. Our goal is to provide a robust, scalable, and intuitive application for the agricultural community.
Farmingo is built with a suite of tools to enhance decision-making, foster community, and streamline commerce in the agricultural sector.
- Dashboard: A central hub for authenticated users to quickly access all the platform's features, with a modern, dark-themed UI and feature search.
- Welcome Page: A sleek, professional landing page for new and unauthenticated users, guiding them to sign up or log in.
- Responsive Design: A fully responsive interface optimized for desktop, tablet, and mobile devices.
- Crop Price Prediction: Leverages AI to forecast market prices for various crops based on region and variety.
- Crop Disease Diagnosis: Instantly diagnose crop diseases. Users select from supported crops (Chilli, Corn, Melon, Onion, Tomato, Wheat, Groundnut) and upload a photo for AI-driven analysis, severity assessment, and treatment recommendations.
- Live Weather Advisory: Fetches real-time weather data from OpenWeatherMap using the user's geolocation. Groq AI analyzes metrics like humidity, wind speed, and rain to provide actionable farming tips and harvesting recommendations.
- Smart Translation: Integrated AI-powered text translation for community posts and comments, supporting major Indian languages.
- Dual Marketplace:
- Verified Market: Certified sellers can list products. Includes a persistent shopping cart and checkout system.
- Indirect Market: A community-driven space where any user can post items for sale, trade, or hire. Features include image cropping, tagging, and location details.
- Content Management: Authors of posts and listings can edit content, delete items, and pin important comments to the top of discussions.
- Community Hub: A social forum for farmers to connect, ask questions, and share knowledge in topic-specific communities (c/community_name).
- User Profiles & Messaging:
- Public Profiles: View user history, followers, and roles (Farmer, User, Moderator).
- Direct Messaging: Real-time conversation threads between users with read receipts.
- Shopping Cart & Checkout: A full-featured e-commerce experience including order history and status tracking.
- Framework: Next.js (App Router)
- Backend & Database: Firebase (Authentication, Firestore)
- Generative AI: Groq Cloud (Llama 3.3/3.2) orchestrated via Genkit
- External APIs: OpenWeatherMap for real-time meteorological data.
- UI Components: ShadCN UI with Tailwind CSS.
- State Management: React Context API for Cart, Search, and User Profile Dialogs.
- Language: TypeScript
/
├── docs/ # Backend schema and documentation
├── messages/ # Localization files (en, hi, mr)
├── public/ # Static assets
├── src/
│ ├── app/ # Next.js routes, pages, and API routes
│ ├── ai/ # Genkit AI flows and Groq configuration
│ ├── components/
│ │ ├── features/ # Feature-specific logic (AI tools, Marketplace)
│ │ ├── layout/ # App structure (Sidebar, Header)
│ │ └── ui/ # Reusable ShadCN components
│ ├── context/ # React context providers (Cart, Search)
│ ├── firebase/ # Client-side SDK initialization and hooks
│ ├── hooks/ # Custom React hooks (useAuthActions, useDebounce)
│ ├── lib/ # Shared utilities and Firestore server actions
├── .env # Environment variables (API Keys)
├── firestore.rules # Firestore security rules (Robust Ownership Model)
└── next.config.ts # Next.js configuration
The source of truth for the database structure. Defines entities like UserProfile, Post, Product, and MarketplacePost.
Implements a robust security model:
- Ownership: Users can only edit/delete their own content.
- Moderation: Post authors can delete or pin comments on their own posts.
- Immutability: Protected fields like
uidandcreatedAtcannot be modified during updates. - Verification: Only users with the
isVerifiedflag can list items in the Verified Market.
- MarketplacePost: Includes
itemName,description,price,quantity,tags, and location metadata. - Conversation: Manages
participants,participantDetails(for fast UI rendering), andlastMessagefor inbox previews.
The AI logic is separated into discrete "flows" in src/ai/flows/:
- Weather Analysis: Uses
fetchWeatherDatatool to get coordinates-based data, then prompts Groq to generate an agricultural advisory. - Crop Diagnosis: Takes a crop name and photo, returning a structured JSON diagnosis with severity and steps.
- Translation: A multi-string translation flow that preserves Markdown formatting while translating agricultural terms.
- Price Prediction: Analyzes market factors to suggest optimal listing prices.
- Node.js (v18 or later)
- OpenWeatherMap API Key
- Groq API Key
- Clone & Install:
npm install - Environment Setup: Create a
.envfile with:GROQ_API_KEYOPENWEATHER_API_KEY- Standard Firebase config variables.
- Run:
npm run dev(Port 9002) - Genkit Inspector:
npm run genkit:watch(Port 4000) for debugging AI prompts.