Inspiration
Walking through agricultural regions in Uganda, I've witnessed firsthand how pest outbreaks can devastate entire farming communities overnight. A farmer might wake up to find weeks of work destroyed not because solutions don't exist, but because detection came too late.
The statistics are staggering: $220 billion in annual crop losses globally, with 20% of all crops destroyed by pests. Climate change is accelerating pest migration into new regions, creating outbreak patterns we've never seen before. Yet most farmers still rely on visual inspection essentially hoping they spot the problem before it spreads.
I asked myself: What if farms could see the future?
The convergence of real-time streaming technology (Confluent) and advanced AI (Google Gemini) presented the perfect opportunity to build something that could genuinely save livelihoods and feed millions more people.
What it does
AgriStream AI is a real-time pest outbreak prediction platform that transforms reactive farming into predictive agriculture.
Core Capabilities:
- Real-time Monitoring Streams sensor data (temperature, humidity, soil moisture) from farms every few seconds
- Instant Anomaly Detection Flink SQL continuously analyzes patterns that precede pest outbreaks
- AI-Powered Prediction Google Gemini analyzes conditions and predicts specific pest threats with natural language recommendations
- Immediate Alerts Farmers receive actionable warnings in seconds, not days
- Futuristic Dashboard Inspired command center visualizing all data streams in real-time
Example Flow:
- Sensors detect temperature rising + humidity dropping
- Flink SQL calculates risk score: 89% outbreak probability
- Gemini AI identifies: "Spider Mite infestation likely within 48-72 hours"
- Farmer receives alert: "Increase irrigation, apply preventive miticide, inspect northeast quadrant"
All of this happens in under 3 seconds.
How I built it
Architecture:
Python Simulator → Confluent Kafka → Flink SQL → Gemini AI → React Dashboard
↓
(Generates realistic farm sensor data for demonstration)
Data Simulation Layer (Python)
Since this is a hackathon prototype, I built a Python-based IoT sensor simulator instead of using physical hardware. This is standard practice for demonstrating IoT architectures the simulator generates realistic agricultural data that mimics what real sensors would produce.
Simulator Features (producers/sensor_simulator.py):
- Simulates 3 farms with 6 sensors total across California's Central Valley
- Generates realistic readings every few seconds:
- Temperature: 15-40°C with realistic daily fluctuation patterns
- Humidity: 30-90% (inversely correlated with temperature, as in nature)
- Soil Moisture: 20-80% with gradual changes
- Includes farm metadata: location coordinates, crop types (almonds, grapes, tomatoes)
- Supports multiple scenario modes:
normal— Baseline healthy farm conditionspre_outbreak— Gradual deterioration indicating incoming pest threatoutbreak— Critical conditions triggering high-risk alertspost_treatment— Recovery after intervention
Why Simulation Instead of Real Hardware:
- Time constraints limited hackathon doesn't allow for hardware procurement and setup
- Cost Real IoT sensors cost hundreds of dollars
- Focus The innovation is in the streaming AI pipeline, not the sensors themselves
- Demo control Can trigger outbreak scenarios on demand for presentation
Production-Ready Design: The architecture is designed so that swapping the simulator for real IoT sensors requires zero code changes to the streaming pipeline. Real sensors would simply publish to the same Kafka topics in the same JSON format. The Flink SQL, Gemini integration, and dashboard would work identically.
Streaming Layer (Confluent Cloud)
Kafka Topics:
sensor-readingsRaw data from simulator (or real sensors in production)pest-imagesFor future image-based pest detectionweather-dataExternal weather API integrationoutbreak-predictionsFlink SQL output with risk scoresfarmer-alertsFinal actionable alerts for farmers
Flink SQL Processing:
- Real-time stream processing with windowed aggregations
- Anomaly detection rules:
IF temperature > 30°C AND humidity < 45% THEN high_risk - Risk score calculation (0-100) based on multiple factors
- Automatic alert generation when thresholds exceeded
AI Layer (Google Gemini)
- Gemini 1.5 Flash via Google AI Studio API
- Analyzes sensor patterns and predicts specific pest types
- Generates natural language recommendations farmers can understand
- Context-aware responses based on crop type, location, and season
Backend (Python/FastAPI)
- Kafka consumers reading from prediction topics
- Server-Sent Events (SSE) for real-time frontend updates
- Gemini API integration service
- RESTful endpoints for dashboard data
Frontend (React/TypeScript)
- Futuristic 2035-inspired design with glassmorphic UI elements
- Real-time updating charts and gauges
- Live alert feed with severity indicators
- "EXECUTE PROTOCOL" button to trigger outbreak simulation for demos
- Fully responsive dark theme
Infrastructure
- Confluent Cloud Managed Kafka cluster (Basic tier, GCP us-central1)
- Google AI Studio Gemini API access
- Local development Production-ready architecture that can deploy to any cloud
Challenges I ran into
1. Google Cloud Billing - A Complete Roadblock
This was by far the most frustrating challenge of the entire hackathon. My original architecture planned for Vertex AI integration directly from Google Cloud Console. What followed was a multi-day battle with billing systems.
The Journey:
Attempt 1 - Old Account Chaos:
- Opened Google Cloud Console and landed in a project "Gemini API"
- This was an old account cluttered with legacy projects
- Couldn't create new projects due to quota limits
- Attempted to delete old projects to make room, deleted projects initially take 30 days to effectively delete
- Decided a fresh start would be faster
Attempt 2 Fresh Email, Fresh Hope:
- Created a completely new Google account specifically for this hackathon
- Successfully created project
agristream-hackathon(Project ID:agristream-hackathon) - Everything looked promising clean console, correct project name
- Navigated to enable Vertex AI API...
Attempt 3 Billing Verification Wall:
- Google required billing to be enabled before using Vertex AI
- Attempted to set up billing with my debit card
- Error
OR_BACR2_44"This action couldn't be completed" - Tried different browsers, incognito mode, cleared cookies same error
- Google requires $11 verification hold to activate the $300 free trial
- At that moment I didn't have the $11 available in my account major blocker
Attempt 4 Reopen Billing Account:
- Navigated to Billing → Account Management
- Found the billing account was now "Closed"
- Red banner: "This billing account is closed. Reopen it to continue using linked projects."
- Clicked "Reopen billing account"
- Blocked again: "You can't reopen this billing account because this account is not in good standing."
- Complete dead end
Attempt 5 — Vertex AI Studio Directly:
- Accessed Vertex AI Studio within Google Cloud Console
- Could see Gemini 3 Flash and other models available
- Prompt interface was visible and functional
- But every action requiring API access showed: "Enable billing to get access to increased quota limit, prompt management and more."
- Vertex AI was effectively locked without billing
The Pivot - Google AI Studio:
With the hackathon deadline approaching and no way to resolve billing in time, I pivoted to Google AI Studio (aistudio.google.com):
- Completely separate from Google Cloud billing
- Free API key generation - no credit card required
- Same Gemini 1.5 Flash model I planned to use
- Generous free tier (15 requests/minute, 1 million tokens/month)
- API key generated in under 1 minute
Lesson Learned:
Google's AI capabilities are accessible through multiple paths. For hackathons and rapid prototyping, Google AI Studio is the friction-free choice. The models are identical only the access method differs. This experience actually strengthened the project: real-world development involves obstacles, and successful engineers find alternative paths.
2. No Physical IoT Hardware - Solved with Simulation
Building an IoT project without actual IoT devices might seem like a limitation, but I turned it into an advantage:
- Built a sophisticated Python simulator that generates realistic agricultural data patterns
- Implemented multiple scenarios (normal, pre-outbreak, outbreak, recovery) for compelling demos
- Designed the data format to match real sensor specifications
- Result: The architecture is production-ready - swapping simulator for real sensors requires zero pipeline changes
3. Real-time Data Synchronization
Ensuring the React dashboard updated smoothly with streaming Kafka data required careful implementation. I solved this with:
- FastAPI backend with Server-Sent Events (SSE)
- Kafka consumers that bridge topics to frontend streams
- Proper connection handling and reconnection logic
4. Flink SQL Learning Curve
Writing streaming SQL that properly handles windowing, watermarks, and stateful processing was new territory. Confluent's documentation and iterative testing in the SQL workspace were essential.
5. Schema Alignment
As I iterated on data structures, keeping Kafka topics, Flink tables, and Python consumers aligned required discipline. Consistent JSON schemas became my source of truth.
6. Designing for the Future
Creating a UI that looks like "2035" while remaining functional and readable pushed my design thinking. The balance between futuristic aesthetics and UX clarity took several iterations.
Accomplishments that I'm proud of
End-to-End Streaming Pipeline - Data flows from simulator to AI predictions to user alerts in under 3 seconds
Realistic IoT Simulation - Python simulator generates believable agricultural sensor patterns with multiple scenario modes
Production-Ready Architecture - Swapping simulator for real sensors requires zero code changes to the pipeline
AI That Actually Helps - Gemini provides specific, actionable recommendations — not generic warnings
Award-Worthy Design - A dashboard that makes judges say "this looks like it's from the future"
Overcame Billing Obstacles - Pivoted from Vertex AI to AI Studio under time pressure without compromising functionality
Solo Build - Entire project built by one developer in 6 days, proving what's possible with modern tools and AI-assisted development
Real Impact Potential - This isn't a novelty; pest prediction could genuinely save billions in crops and improve food security
What I learned
Technical:
- IoT simulation is a valid prototyping strategy - Focus on the pipeline, not the hardware
- Confluent's Flink SQL is incredibly powerful for real-time analytics
- Server-Sent Events (SSE) are simpler than WebSockets for one-way real-time updates
- Google's Gemini API is remarkably capable at domain-specific analysis with proper prompting
- Google AI Studio is a lifesaver - Same models as Vertex AI, zero billing friction
Design:
- Futuristic UI requires restraint - too many effects becomes distracting
- Dark themes with strategic accent colors create premium feel
- Micro-animations make data feel "alive"
Process:
- AI-assisted development (Claude Code) dramatically accelerates solo building
- Pivoting quickly is a superpower When Vertex AI billing failed multiple times, switching to AI Studio saved the project
- Always have a backup plan for cloud services
What's next for AgriStream AI
Immediate Enhancements:
- Real IoT Integration - Connect actual sensors (the pipeline is ready)
- Pest Image Analysis - Upload photos for instant AI identification
- Weather API Integration - Correlate predictions with forecast data
- Mobile App - Farmer-friendly alerts via SMS and push notifications
- Vertex AI Migration - Once billing is resolved, access enterprise features
Scale & Deploy:
- Partner with agricultural cooperatives for pilot programs in Uganda
- Integrate with real IoT sensor networks
- Expand pest database for region-specific predictions
Advanced AI:
- Multi-modal analysis combining sensor data + satellite imagery + weather
- Predictive models trained on historical outbreak data
- Autonomous drone deployment for targeted treatment
Vision: AgriStream AI is a foundation for intelligent agriculture infrastructure. The same streaming + AI pattern could monitor soil health, optimize irrigation, predict harvest timing, and more.
My goal: Every farmer, everywhere, has access to AI-powered prediction that protects their livelihood.
Log in or sign up for Devpost to join the conversation.