Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmartFarm AI 🌾

FastAPI React TypeScript Google Gemini API TailwindCSS Render Vercel

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 Production Deployments


🛠️ Technology Stack

Backend Infrastructure

  • 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

Frontend Web Application

  • 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

🚀 Week 9 Production Deployment Guide

Option 1: Render Blueprint Deployment (Recommended for Backend)

  1. Fork/Connect Repository: Connect your GitHub repository to Render.com.
  2. New Blueprint: Click New + -> Blueprint in the Render Dashboard and point to render.yaml.
  3. 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/...

Option 2: Vercel Deployment (Recommended for Frontend)

  1. Connect Repository: Import the smartfarm-ai repository into Vercel.
  2. Framework Preset: Select Vite.
  3. Root Directory: Set Root Directory to frontend.
  4. Environment Variables: Add VITE_API_URL pointing to your deployed Render backend:
    VITE_API_URL=https://smartfarm-backend.onrender.com
  5. Deploy: Click Deploy. Vercel will automatically compile the SPA and configure SPA rewrite routes via vercel.json.

🏃 Running Locally for Development

1. Backend Server Setup:

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 8000

API Documentation will be available at: http://localhost:8000/docs.

2. Frontend SPA Setup:

cd frontend
npm install
npm run dev

Open browser at: http://localhost:5173.


🧪 Verification & Automated Testing

Run the full backend test suite with Pytest:

pytest tests/ -v

Run the production frontend build check:

cd frontend
npm run build

⚠️ Known Free Tier Limitations

  1. 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.
  2. 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.
  3. 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.

📜 License

Distributed under the MIT License. See LICENSE for details.

About

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages