Smart Shamba: Bridging the Digital Divide with AI & USSD
Inspiration
The inspiration for Smart Shamba was born from a striking paradox in Kenya's agricultural landscape. Agriculture contributes 33% to our GDP and employs over 40% of the population, yet the smallholder farmers who form the backbone of this sector remain trapped in a cycle of poverty and vulnerability.
We realized that while high-fidelity agronomic data exists—satellites capture terabytes of imagery daily, and research institutions have advanced predictive models—this intelligence never reaches the rural farmer. They operate in an "Information Desert," relying on intuition in an era of erratic climate change.
We saw that most "AgTech" solutions fail because they are built for the wrong user: they require smartphones and high-speed internet, excluding the 53% of rural farmers who rely on basic feature phones. We wanted to build a bridge across this digital divide, decoupling high-tech intelligence from high-tech delivery.
What it does
Smart Shamba is a Satellite-to-Shamba decision support system that democratizes access to precision agriculture. It synthesizes complex data from satellites, IoT sensors, and AI models into simple, actionable insights delivered via USSD (basic mobile menus) and SMS.
Key features include:
- Precision Advisory: Farmers receive hyper-local advice (e.g., "Yield Risk: High. Irrigate now.") based on real-time soil data and satellite imagery.
- Flora AI Assistant: A localized chatbot powered by Gemini 3 Pro that farmers can query via SMS in Swahili/English to diagnose pests or get agronomic advice.
- Early Warning System: Proactive SMS alerts for extreme weather or pest outbreaks predicted by our PyTorch models.
- Digital Agrimart: A USSD-based marketplace where farmers can buy certified inputs and sell produce directly to buyers, bypassing predatory brokers.
⚙️ How we built it
We architected a "Satellite-to-Shamba" pipeline that ingests massive datasets at the top and distills them into 160-character messages at the bottom.
The "Brain" (Hybrid AI Engine):
- Predictive Analytics: We used PyTorch to build LSTM models that analyze time-series data (rainfall, soil moisture, NDVI) to forecast yield and drought risk.
- Generative AI: We integrated Google's Gemini 3 Pro via Google AI Studio into a RAG (Retrieval-Augmented Generation) pipeline. This allows our "Flora AI" to answer farmer queries using verified agricultural manuals stored as vector embeddings in pgvector.
- Computer Vision: We deployed EfficientNet models (trained with TorchVision) to detect pests and diseases from uploaded images.
The "Factory" (Infrastructure):
- Backend: Built with FastAPI for high-performance async processing, deployed on Render.
- Database: We used PostgreSQL with TimescaleDB extensions for handling billions of IoT sensor readings and pgvector for semantic search.
- Data Ingestion: A robust pipeline using MQTT (EMQX broker) for IoT data and Celery/RabbitMQ for batch processing of Google Earth Engine satellite imagery.
The "Last Mile" (Connectivity):
- Africa's Talking API: Bridges our cloud backend to the GSM network, enabling USSD menus (384...) and SMS delivery to any mobile phone.
Challenges we ran into
- The "Valet Key" Pattern: Sending images from rural areas via limited bandwidth was a major bottleneck. We solved this by implementing a "Valet Key" pattern, where devices upload directly to MinIO object storage via pre-signed URLs, bypassing our application servers entirely.
- Hallucination in AI: Early versions of our chatbot would invent agronomic advice. We fixed this by implementing a strict RAG architecture, grounding Gemini's responses in a curated knowledge base of KALRO datasheets and enforcing a "scientific constraints" system prompt.
- WSL2 Networking: Developing a complex microservices architecture involving IoT simulators and localized databases on Windows/WSL2 presented significant networking challenges, which we overcame by containerizing our environment.
Accomplishments that we're proud of
- True Accessibility: Successfully executing a full AI pipeline that results in a simple SMS. Seeing a complex LSTM prediction turn into a text message on a "mulika mwizi" (dumbphone) was a magical moment.
- Polyglot Persistence: effectively managing a database that handles relational transactions, time-series telemetry, and vector embeddings all within a single PostgreSQL instance.
- Frugal Innovation: Building a system that brings the power of Google's Gemini Pro and Earth Engine to users who may not even have an internet connection.
What's next for Smart Shamba
- Voice Integration: Integrating voice-to-text models to allow illiterate farmers to interact with Flora AI via voice notes.
- Hyper-local Weather: Deploying more low-cost ESP32 weather stations to refine our micro-climate models.
- Financial Inclusion: Using our yield prediction models to generate "credit scores" for farmers, unlocking access to micro-loans and crop insurance.
Built With
- antigravity
- fastapi
- gemini
- nextjs
- tailwindcss
Log in or sign up for Devpost to join the conversation.