Rayyan is an intelligent agricultural advisory system that combines IoT sensors, machine learning, and AI agents to provide data-driven recommendations for irrigation, fertigation, pest management, and crop health monitoring.
- π€ AI Agricultural Advisor: LangGraph-based conversational agent with specialized agricultural tools
- π§ Smart Irrigation: Automated irrigation scheduling based on soil moisture, weather, and crop needs
- π§ͺ Fertigation Optimization: NPK ratio recommendations tailored to crop type and growth stage
- π Pest Detection: Early pest activity detection with confidence scoring
- π± Soil & Water Analysis: Real-time monitoring of soil conditions and water quality
- π€οΈ Weather Integration: Forecast-aware decision making for farm operations
- π Real-time Dashboard: Next.js frontend with live sensor data and agent chat
- π Edge Computing: Lightweight ONNX/TFLite inference on IoT devices
βββ backend/ # FastAPI API server with LangGraph agent
βββ frontend/ # Next.js 15 + React 19 web application
βββ edge/ # Edge computing module for IoT devices
βββ ml/ # Machine learning models and training
βββ infra/ # Infrastructure and deployment configs
- Backend: FastAPI, SQLAlchemy, Supabase (PostgreSQL), LangChain/LangGraph
- Frontend: Next.js 15.5, React 19, Tailwind CSS v4, TypeScript
- AI/LLM: OpenAI, Anthropic, LangGraph agents
- Database: Supabase (PostgreSQL with real-time, auth, storage)
- Edge: Python, ONNX Runtime, TFLite, MQTT
- ML: PyTorch, TensorFlow, scikit-learn
# 1. Clone the repository
git clone https://github.com/a-belard/rayyan.git
cd rayyan
# 2. Set up environment variables
cp backend/.env.example backend/.env
cp frontend/.env.local.example frontend/.env.local
# Edit .env files with your Supabase and API keys
# 3. Start all services
docker-compose up -d
# 4. Access the application
# Frontend: http://localhost:3000
# Backend API: http://localhost:8000
# API Docs: http://localhost:8000/docsEach folder has its own docker-compose.yml for independent deployment:
# Backend only
cd backend && docker-compose up -d
# Frontend only
cd frontend && docker-compose up -d
# Edge only
cd edge && docker-compose up -d
# ML environment only
cd ml && docker-compose up -dSee DOCKER_COMPOSE_INDIVIDUAL.md for detailed guide.
cd backend
cp .env.example .env
# Edit .env with your credentials
uv pip install -e .
python main.pycd frontend
cp .env.local.example .env.local
pnpm install
pnpm devcd edge
pip install -r requirements.txt
python main.pycd ml
pip install -r requirements.txt
jupyter labSee detailed setup instructions in SETUP_SUPABASE.md and DOCKER.md.
- SETUP_SUPABASE.md - Supabase backend setup guide
- DOCKER.md - Complete Docker deployment guide
- DOCKER_COMPOSE_INDIVIDUAL.md - Individual service deployment
- AGENT_IMPLEMENTATION.md - AI agent architecture
- AGENT_SUMMARY.md - Quick reference for agent system
- CONTRIBUTING.md - Contribution guidelines
- docs/docker-compose-individual.md - Detailed individual service guide
- docs/docker-compose-quick-reference.md - Quick command reference
- docs/ - Additional technical documentation
The Rayyan AgriAdvisor provides expert agricultural guidance through natural conversation:
# Example queries:
"Check soil conditions in Zone 1"
"What's the weather forecast for the next 3 days?"
"Calculate irrigation schedule for tomatoes in vegetative stage"
"Recommend fertigation for corn in flowering stage"
"Are there any pest threats detected?"
"Analyze water quality from Well 2"- Weather Forecast - Rainfall, temperature, evapotranspiration
- Soil Analysis - Moisture %, EC (salinity), pH, nutrients
- Water Quality - EC, pH, RO blending recommendations
- Pest Detection - Species identification, severity, confidence
- Irrigation Scheduling - Timing, duration, volume calculations
- Fertigation Recommendations - NPK ratios, mixing instructions
# Backend
docker build -t rayyan-backend ./backend
# Frontend
docker build -t rayyan-frontend ./frontend
# Edge
docker build -t rayyan-edge ./edge
# ML
docker build -t rayyan-ml ./ml# Production stack (backend + frontend + edge)
docker-compose up -d
# With ML environment for training
docker-compose --profile ml up -d
# View logs
docker-compose logs -f backend
# Stop all services
docker-compose downSee DOCKER.md for comprehensive Docker guide.
cd backend
uv pip install -e .
python main.py # Runs with auto-reloadcd frontend
pnpm install
pnpm dev # Uses Turbopack for fast HMR# Backend (Python)
black backend/ --line-length=88
isort backend/ --profile=black
# Frontend (TypeScript)
cd frontend
pnpm lint# Backend tests
cd backend
pytest
# Frontend tests
cd frontend
pnpm testThe platform includes modules for:
- Weather Forecasting: Time-series prediction models
- Soil-Water Modeling: Moisture dynamics and irrigation needs
- Pest Detection: Computer vision models (YOLOv8/CNNs)
- NLU: Natural language understanding for agent queries
- Fertigation Optimization: NPK recommendation engine
Models are exported as ONNX/TFLite for edge deployment.
GET /threads- List all conversation threadsPOST /threads- Create new threadGET /threads/{id}- Get thread detailsPATCH /threads/{id}- Update threadDELETE /threads/{id}- Delete thread
POST /agent/threads/{id}/run- Execute agent (SSE streaming)
See full API documentation at http://localhost:8000/docs when running.
DATABASE_URL=postgresql+asyncpg://...
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_KEY=your-anon-key
OPENAI_API_KEY=sk-xxx
ANTHROPIC_API_KEY=sk-ant-xxx
DEFAULT_LLM_PROVIDER=openai
DEFAULT_LLM_MODEL=gpt-4o-mini
LLM_TEMPERATURE=0.7
CHAT_HISTORY_MAX_MESSAGES=50NEXT_PUBLIC_API_URL=http://localhost:8000We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain/LangGraph for agent framework
- Supabase for backend infrastructure
- Next.js and Vercel for frontend framework
- OpenAI and Anthropic for LLM APIs
For questions or support, please open an issue on GitHub.
Built with β€οΈ for sustainable agriculture