SmartFarm AI is a startup-level, full-stack Precision Agriculture Platform. It leverages AI, Machine Learning, Computer Vision, and Generative AI (Google Gemini) to deliver actionable agricultural decision intelligence for farmers and agronomists.
- Live Frontend Web App: https://smartfarm-ai.vercel.app
- Live Backend API: https://smartfarm-backend.onrender.com
- Framework: FastAPI 0.111.0 (Python 3.10+)
- Application Server: Uvicorn (ASGI)
- Database & ORM: PostgreSQL (Production) / SQLite (Development) with SQLAlchemy 2.0 & Alembic
- Caching & Throttling: Redis 7.0 (Optional / Fallback to In-Memory)
- Machine Learning & CV: Scikit-Learn, ONNX Runtime, OpenCV, XGBoost, Pandas, NumPy
- Authentication: JWT (HS256) with Single-Use Refresh Token Rotation & Google OAuth 2.0
- Framework: React 18.3 + Vite 5
- Language: TypeScript 5.2
- Styling & UI: TailwindCSS 3.4, Glassmorphism, Lucide React Icons
- State & HTTP: React Context API, Axios with automatic 401 token refresh interceptors
- Build Tooling: Vite with custom vendor chunk splitting
- Fork/Connect Repository: Connect your GitHub repository to Render.com.
- New Blueprint: Click New + -> Blueprint in the Render Dashboard and point to
render.yaml. - Configure Environment Variables: Set the following variables in the Render Dashboard under smartfarm-backend:
| Environment Variable | Required | Description | Example / Default |
|---|---|---|---|
DATABASE_URL |
Yes | PostgreSQL connection string | postgresql://user:pass@host/db |
JWT_SECRET |
Yes | Secret key for signing JWT tokens | Auto-generated by Render |
SECRET_KEY |
Yes | App secret key | Auto-generated by Render |
FRONTEND_URL |
Yes | Production URL of Vercel frontend | https://smartfarm-ai.vercel.app |
BACKEND_CORS_ORIGINS |
Yes | Allowed origins for CORS | ["https://smartfarm-ai.vercel.app"] |
GOOGLE_CLIENT_ID |
Optional | Google OAuth 2.0 Client ID | *.apps.googleusercontent.com |
GOOGLE_CLIENT_SECRET |
Optional | Google OAuth 2.0 Client Secret | GOCSPX-... |
GOOGLE_CALLBACK_URL |
Optional | OAuth Redirect URI | https://smartfarm-backend.onrender.com/api/auth/google/callback |
GEMINI_API_KEY |
Optional | Google Gemini API Key | AIzaSy... |
OPENWEATHERMAP_API_KEY |
Optional | OpenWeatherMap API Key | 3a9b... |
SENTRY_DSN |
Optional | Sentry Error Monitoring DSN | https://...@sentry.io/... |
- Connect Repository: Import the
smartfarm-airepository into Vercel. - Framework Preset: Select Vite.
- Root Directory: Set Root Directory to
frontend. - Environment Variables:
Add
VITE_API_URLpointing to your deployed Render backend:VITE_API_URL=https://smartfarm-backend.onrender.com
- Deploy: Click Deploy. Vercel will automatically compile the SPA and configure SPA rewrite routes via
vercel.json.
cd backend
python -m venv venv
# Windows PowerShell:
.\venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000API Documentation will be available at: http://localhost:8000/docs.
cd frontend
npm install
npm run devOpen browser at: http://localhost:5173.
Run the full backend test suite with Pytest:
pytest tests/ -vRun the production frontend build check:
cd frontend
npm run build- Render Cold Starts: On Render's Free Instance Plan, the backend service automatically spins down after 15 minutes of inactivity. The initial request after inactivity may take 30 to 50 seconds to complete while the instance wakes up.
- Ephemeral File System on Free Tier: Render free web services do not persist local file system writes across restarts. For production photo uploads and PDF generation, configure external S3/Cloudinary storage or persistent disk attachments.
- Google Gemini Free API Rate Limits: The Google Gemini 1.5 Flash API free tier is limited to 15 Requests Per Minute (RPM) and 1,000,000 Tokens Per Minute (TPM). SmartFarm AI includes built-in exponential backoff and rule-based decision fallback to ensure zero downtime when rate limits are reached.
Distributed under the MIT License. See LICENSE for details.