Inspiration
In Bogor, Indonesia—famously known as the 'City of Rain'—intense rainfall is a recurring reality. This heavy precipitation is one of the primary contributors to severe flooding in Jakarta, the nation’s capital. As an engineer, I observe that traditional early warning systems remain largely reactive, issuing alerts only after critical thresholds have been breached, leaving communities with minimal time to prepare. We were inspired by a simple yet powerful question: What if we could move from reaction to prediction? The theme of this hackathon, "Forge Agentic AI for Real-World Impact," resonated deeply, pushing us to build not just another data dashboard, but a truly autonomous, intelligent agent that could anticipate a crisis before it happens, giving communities the one thing they need most: time.
What it does
FloodCast is an autonomous AI ecosystem that proactively predicts flood risks. It functions as a complete, end-to-end solution:
- It Continuously Monitors & Predicts: The core AI agent runs 24/7, analyzing real-time sensor data from TiDB and external weather forecasts to predict if a dangerous situation will occur in the near future.
- It Analyzes Community Reports: Through a public-facing Flutter app, citizens can submit visual reports (images) of local conditions. The agent uses multi-modal AI (Gemini 2.5 Pro) to analyze these images, fusing this visual data with sensor trends for superior accuracy.
- It Acts Autonomously: When the agent predicts a high risk, it automatically sends push notifications via FCM to all registered mobile devices, providing an early warning.
- It Provides Human Supervision: A professional web dashboard (built with SvelteKit) allows human operators to monitor the AI's decisions, view its reasoning, and provide crucial feedback.
- It Learns from Feedback: The agent features a self-correction loop. When an operator flags a prediction as a "False Alarm" on the dashboard, the agent uses this feedback as context to make smarter, more nuanced decisions in the future.
How we built it
We adopted a professional, service-oriented architecture to ensure our system is scalable, maintainable, and robust.
- Backend: A modular Python backend built with FastAPI, running as two separate processes: a Uvicorn server for the API and a standalone process for the autonomous agent worker.
- Database: We leveraged TiDB Serverless as the central nervous system of our application. We used it as a time-series database for sensor readings, a relational database for reports and device tokens, and as an audit log for the AI's structured JSON outputs.
- AI Core: We used Google's Gemini 2.5 Pro model via Vertex AI. Advanced prompt engineering instructs the model to perform a chain-of-thought analysis and return structured JSON output, which our agent then parses to take action.
- Frontend (Web Dashboard): A modern command center built with SvelteKit, providing operators with real-time data visualization and interactive feedback tools.
- Frontend (Mobile): A cross-platform public application built with Flutter, following a clean, BLoC architecture for state management.
Challenges we ran into
Our biggest challenge was a classic full-stack data integrity issue: the massive BIGINT IDs generated by TiDB were being rounded by JavaScript on the frontend, breaking our feedback loop. We solved this by re-architecting our API to treat all database IDs as strings from end-to-end, a robust solution born from real-world experience. We also navigated complex cloud configuration issues, including IAM permissions for our Service Account and ensuring the correct regional availability for the AI models.
Accomplishments that we're proud of
We are incredibly proud of building a system that demonstrates three advanced AI concepts in a single, cohesive workflow:
- True Autonomy: We successfully built an agent that operates end-to-end without human intervention—from data analysis to direct public notification.
- Sophisticated Data Fusion: Our agent makes decisions not based on a single data source, but by fusing three distinct types of data: quantitative time-series (sensors), textual (weather), and visual (citizen images).
- A Learning System: The self-correction feedback loop is our proudest accomplishment. It elevates FloodCast from a simple predictive tool to an intelligent agent that can adapt and improve over time, demonstrating a practical application of human-in-the-loop machine learning.
What we learned
This project was a masterclass in building a truly "agentic" system. We learned that an agent's intelligence isn't just about its core model, but about the ecosystem of data and feedback it lives in. Implementing the self-correction loop via in-context learning was an "aha" moment, showing how a simple feedback mechanism can drastically improve an AI's wisdom. Debugging issues across the full stack reinforced the importance of a holistic engineering perspective.
What's next for FloodCast
This hackathon project is a robust foundation. We envision FloodCast evolving into a comprehensive environmental resilience platform with the following roadmap:
Hyper-Local Causal Analysis: Integrating more diverse data points beyond rainfall and sensor levels, such as waste management reports and drainage blockage data from citizen reports, to understand and predict the root causes of flooding in specific micro-locations.
Crisis Communication & Resource Hub: Evolving the Flutter app into a critical public utility. During a crisis, it will provide real-time disaster progression updates, safe evacuation routes calculated by the agent, and a map of critical resources like public kitchens, shelters, and medical posts.
Proactive Public Education: Adding an educational module to the app that provides actionable information on flood prevention, such as tutorials on proper waste disposal, community preparedness checklists, and contact information for local authorities.
Advanced Root Cause Analysis with Vector Search: Utilizing TiDB's Vector Search to find historical events with similar multi-modal patterns (sensor data + images). This will provide officials on the dashboard with deeper, data-driven insights into why a specific prediction was made by comparing it to past incidents.
Summary of Data Flow and Integrations
Our FloodCast project operates on a complete, end-to-end data flow, integrating multiple services to create an autonomous, learning AI agent.
A. Data Ingestion: The system ingests data from two primary sources:
Simulated IoT Sensors: A Python script continuously sends time-series water level data to our backend.
Community Reports: A Flutter mobile app allows citizens to upload visual reports (images) and notes. Both data streams are received by dedicated endpoints on our FastAPI Backend API.
B. Persistence & Indexing: All incoming data is immediately persisted in our TiDB Serverless database. Sensor data is stored in a time-series optimized table (sensor_readings), while citizen reports are stored in a relational reports table.
C. Autonomous Analysis & Enrichment: Our standalone Python Agent Worker runs a continuous loop to:
Query TiDB Serverless for recent sensor history, new visual reports, and past operator feedback.
Invoke an external tool, the OpenWeatherMap API, to enrich the data with real-time weather forecasts.
D. AI-Powered Prediction: The agent fuses all collected data (sensor trends, weather, images, notes, and past feedback) into a sophisticated, multi-modal prompt. This prompt is sent to the Google Vertex AI platform to be analyzed by the Gemini 2.5 Pro model.
E. Action & Learning Loop:
The agent parses the structured JSON response from the AI.
If a threat is predicted, the agent invokes another external service, Firebase Cloud Messaging (FCM), to dispatch push notifications to all registered devices.
The AI's decision, reasoning, and confidence score are logged back into the alerts table in TiDB Serverless, creating an audit trail.
This log is then displayed on the SvelteKit Web Dashboard, where operators can provide feedback, completing the data loop and enabling the agent to learn for future predictions.
Built With
- fastapi
- firebase-cloud-messaging
- gemini-2.5-pro
- google-cloud-vertex-ai
- javascript
- openweathermap-api
- python
- sveltekit
- tidb-serverless
Log in or sign up for Devpost to join the conversation.