# 🌾 AgriSmart AI - AI-Powered Agriculture Crop Advisory SaaS Platform
A production-ready AI-powered Crop Advisory Assistant built with **React**, **TypeScript**, **Vite**, **Tailwind CSS**, **Node.js**, **Express**, **Supabase PostgreSQL**, and Google's **Gemini AI (`@google/genai`)**.
---
## 🌟 Key Features
- **User Authentication**: Supabase Auth & JWT session protection with 1-click Demo login capability.
- **Farm Management**: Create, edit, and manage farm profiles (Soil Type, Farming Season, Land Size in Acres, Irrigation Infrastructure).
- **Gemini AI Crop Advisory**: Powered by `@google/genai` (Gemini 2.5 Flash) with strictly validated structured JSON output providing top crop recommendations, NPK fertilizer dosing, irrigation schedules, pest management, and expected harvest yields.
- **Advisory History**: Searchable, filterable history log stored in Supabase with printable PDF report export.
- **Resilient Fallback Mode**: Functions out of the box with intelligent agronomic engine fallbacks even before external database or API keys are added.
- **Row-Level Security (RLS)**: Enforces complete user isolation for all farm profiles and advisories.
---
## 🚀 Technology Stack
### Frontend
- React.js 18 + Vite + TypeScript
- Tailwind CSS (Custom Agricultural Green/Earth design system)
- Lucide React Icons & Radix-inspired glassmorphism
### Backend
- Node.js + Express.js (TypeScript)
- Zod Request & AI Response Schema Validation
- Rate Limiting & Security Middlewares
### Database & AI
- Supabase PostgreSQL with RLS Policies (`schema.sql`)
- Google Gemini API via official `@google/genai` SDK
---
## 🛠️ Quick Start & Installation
### 1. Install Dependencies
Run from the root directory to install all monorepo dependencies:
```bash
npm run install:all
```
### 2. Configure Environment Variables
Create a `.env` file in the root directory (see `.env.example`):
```env
PORT=5000
SUPABASE_URL=
your-project.supabase.co
SUPABASE_ANON_KEY=your-supabase-anon-key
S …