Cropia is an intelligent agricultural platform designed to bridge the gap between farmers and administrative bodies. It empowers farmers with real-time, offline-first disease detection and decision support, while providing government officials and NGOs with a "God View" of regional crop health to prevent outbreaks.
Built as a high-performance monorepo using Turborepo, Bun, and Hono, Cropia leverages Google's Gemini 2.5 Flash Lite for speed and accuracy in low-resource environments.
- Landing Page: https://cropia-phi.vercel.app/
- Admin Dashboard (Government/NGO): https://cropia-admin.vercel.app
- Farmer App: https://cropia-farmer.vercel.app
-
AI Crop Scanner ("The Gatekeeper"):
-
Instantly validates if an image is a crop (filtering out selfies/documents).
-
Detects diseases, pests, and nutrient deficiencies in real-time.
-
Provides a "Confidence Score" and "Visual Severity" rating (Healthy vs. Warning vs. Critical).
-
Decision Support Dashboard:
-
Smart Spray Planner: A 12-hour timeline analyzing Wind Speed (<15km/h) and Rain Probability (<30%) to recommend safe spraying windows.
-
Root Health X-Ray: Visualizes soil moisture at two depths (Surface 0-10cm vs. Deep 10-30cm) to detect "false dryness" and prevent over-irrigation.
-
Water Balance Calculator: Tracks net water deficit (
Rain - Evapotranspiration) over the last 3 days. -
Cropia Assistant: A conversational AI chatbot that can answer questions about recent scans, weather forecasts, and agronomy advice.
-
The God View (Live Map):
-
Interactive geospatial map visualizing every crop scan in the jurisdiction.
-
Color-coded markers (Green=Healthy, Red=Critical) for spotting regional outbreaks.
-
Regional Analysis Agent:
-
Aggregates data from thousands of scans to generate "News Headlines" (e.g., "Sugarcane Rust cases up 40% in Kolhapur").
-
Provides statistical breakdowns of disease distribution per district/taluka.
-
Jurisdiction Control: Granular RBAC allowing officials to view data specifically for their State, District, or Taluka.
Core Infrastructure
- Monorepo: Turborepo
- Runtime/Manager: Bun (v1.2.20)
- Dependency Management:
- Catalog: Centralized versions in root
package.json. - Peer Dependencies: Preventing React duplication in shared UI packages.
- Catalog: Centralized versions in root
- Language: TypeScript (v5.9)
Frontend (Web & PWA)
- Framework: React (Vite)
- Marketing Site: Astro (Static/Zero-JS)
- Styling: Tailwind CSS + Shadcn UI (
@repo/ui) - State/Routing: TanStack Query + TanStack Router
- Maps: Mapbox / Leaflet (via React)
Why Astro for Landing Page? We chose Astro over Next.js/React for the public site to ensure maximum performance:
- Zero JS Runtime: Ships pure HTML/CSS by default.
- No Overhead: Avoids the ~30kb React hydration cost for static pages.
- Islands Architecture: Interactive components (React) are only loaded when needed.
To validate our choice, the Cropia landing page achieves a perfect score on Google PageSpeed Insights (Desktop).
Tip
View the Live Report: PageSpeed Insights - Cropia
Backend (API & Edge)
- Framework: Hono (Lightweight, Edge-ready)
- Communication: Hono RPC (Type-safe client-server contract)
- Database: MongoDB (via Prisma ORM)
- Auth: BetterAuth (Multi-tenant Organization support)
Artificial Intelligence
- Vision Model: Google Gemini 2.5 Flash Lite (Optimized for low latency).
- Framework: Vercel AI SDK (
@ai-sdk/google). - Agents:
- Gatekeeper Agent: Validates image integrity and diagnoses specific crop issues.
- Analysis Agent: Summarizes regional data into actionable natural language insights.
The project follows a modern monorepo structure:
.
├── apps
│ ├── farmer # The Farmer PWA (Vite + React)
│ ├── admin # The Government Dashboard (Vite + React)
│ ├── landing-page # Marketing Website (Astro)
│ └── api # Hono Backend (Business Logic + AI Agents)
├── packages
│ ├── db # Prisma Schema & MongoDB Client
│ ├── ui # Shared Shadcn UI Components
│ ├── config # Shared TS/Eslint Configs
│ └── scripts # Utility scripts
└── turbo.json # Build pipeline configuration
graph TD
subgraph Apps
F[Farmer App]
A[Admin Dashboard]
L[Landing Page]
S[API Server]
end
subgraph Packages
UI["@repo/ui"]
DB["@repo/db"]
API["@repo/api"]
TS["@repo/typescript-config"]
end
F --> UI
A --> UI
L --> UI
F --> API
A --> API
S --> API
API --> DB
%% Shared Configs
UI -.-> TS
DB -.-> TS
API -.-> TS
Cropia uses a Conditional Agentic Workflow:
- Input: Image uploaded by farmer.
- Gatekeeper (Gemini 2.5 Flash Lite):
- Check: Is this a plant? (Reject if false).
- Analyze: Identify Crop -> Detect Issue -> Assess Severity.
- Label: Generate semantic filename (e.g.,
sugarcane_rust_timestamp).
- Persistence: Data stored in MongoDB with a "Location Snapshot" (State/District/Village frozen at upload time) for fast geospatial queries.
- Async Analysis: The "Analysis Agent" runs periodically to aggregate these snapshots into regional reports for the Admin.
- User/Auth: Uses
BetterAuthwithOrganizationandMembertables for managing Co-ops and Government hierarchies. - Scan Model: Stores the
imageUrl,aiMetadata(diagnosis, confidence), and a Location Snapshot (state,district,taluka) to avoid expensive joins during analytics. - Jurisdiction Type: A custom composite type defining an admin's scope (e.g.,
{ state: "Maharashtra", district: "Kolhapur" }).
- Bun (v1.0+)
- MongoDB (Local or Atlas URL)
- Cloudinary Account (for image storage)
- Google Gemini API Key
- Clone the repository:
git clone https://github.com/your-username/cropia.git
cd cropia
- Install dependencies:
bun install
- Environment Setup:
Create a
.envfile in the root (see.env.example):
DATABASE_URL="mongodb+srv://..."
GOOGLE_GENERATIVE_AI_API_KEY="AIzaSy..."
CLOUDINARY_CLOUD_NAME="..."
BETTER_AUTH_SECRET="..."
- Database Push:
bun run db:push
- Run Development Server:
bun run dev
- Landing Page:
http://localhost:4321 - Farmer App:
http://localhost:5173 - Admin App:
http://localhost:5174 - Backend API:
http://localhost:3000
- Fork the repo.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
