Project Details: Sentinel Flood-Watch

Project Story

What Inspired Me

Perennial flooding in Accra, Ghana, has taken a devastating toll on human lives, local communities, and the regional economy. According to data from the United Nations Development Programme (UNDP), flooding and related disaster events cost Ghana over GHS 300 million annually, with the Greater Accra region alone bearing over GHS 200 million of these losses.

A major driver of this ecological crisis is the rapid, unregulated encroachment, infilling, and construction in protected Ramsar sites, alongside illegal waste dumping in critical drainage channels. While municipal bodies like the Accra Metropolitan Assembly (AMA) and the National Disaster Management Organisation (NADMO) have the mandate to enforce zoning laws, they lack a cost-effective, proactive monitoring infrastructure. Environmental degradation often occurs silently over weeks or months, and by the time authorities detect the encroachment, the damage is done and drainage channels are permanently blocked.

I built Sentinel Flood-Watch to bridge this enforcement gap. By combining remote sensing imagery, autonomous agent orchestration, and real-time database logging, the system provides environmental protection agencies and disaster management authorities with a cost-effective, automated, and continuous sentinel to watch over Accra's high-risk ecological zones.


Project Features and Functionality

Sentinel Flood-Watch is a responsive, glassmorphic monitoring dashboard and agentic AI system that provides the following capabilities:

  • Visual Evidence Slider: An interactive, side-by-side split screen comparison of baseline (historical) and current imagery. It includes date-annotated labels showing the exact Sentinel-2 image acquisition dates for verified temporal comparison.
  • Dynamic remote sensing analysis: Compute Normalized Difference Vegetation Index (NDVI) and Modified Normalized Difference Water Index (MNDWI) in real-time. Changes are computed algorithmically to detect vegetation clearing and water channel narrowing.
  • Accra Ecological Buffers: Predefined high-risk zones built with 800-meter monitoring buffers:
    • Korle Lagoon / Odaw Mouth
    • Odaw River Basin
    • Sakumono Ramsar Site
    • Densu Delta Ramsar Site
  • Stateful Agent Chat: A conversational ReAct agent stream interface showing the agent's real-time reasoning, tool executions, and analytical outputs.
  • Live Analytics Dashboard: Live tracking widgets displaying scans processed, active alerts, and system success rates.
  • Grounded Geocoding Search: Preventing coordinate hallucinations by integrating OpenStreetMap Nominatim and DuckDuckGo API to dynamically resolve arbitrary Accra landmarks (e.g. Weija Dam) to precise latitude/longitude coordinates.
  • Interactive Legend Overlay: A floating legend panel explaining NDVI, MNDWI, and RGB band outputs in non-technical terms.
  • Automated Scheduled Monitoring: A hybrid scheduling architecture supporting secure token-authorized cloud webhooks (POST /api/v1/jobs/scan) for production cron jobs (Cloud Scheduler) and local lifespan background loops (ENABLE_LOCAL_SCHEDULER) for developer verification. Scans run asynchronously in FastAPI's BackgroundTasks queue to prevent connection timeouts.
  • IP-Based Server Salt Hashing: Generates deterministic unique user_id values based on client IP addresses salted and hashed with SHA-256 to support session management without requiring a friction-heavy email login.

How I Built It

Sentinel Flood-Watch is built using a modern, decoupled cloud architecture:

  • AI Agent Orchestration: Built with the Google ADK (Agent Development Kit) to coordinate LLM reasoning, session persistence, and tool execution.
  • Reasoning Brain: Powered by Gemini 3.5 Flash (gemini-3.5-flash) on Vertex AI.
  • Remote Sensing Pipeline: Integrated Google Earth Engine (GEE) utilizing the Sentinel-2 Harmonized Surface Reflectance collection (COPERNICUS/S2_SR_HARMONIZED).
  • Database & Alert Log: Integrated the official MongoDB Model Context Protocol (MCP) server (mongodb-mcp-server) via Google ADK's McpToolset to execute namespaced database operations (mongodb_find and mongodb_insert-many) on MongoDB Atlas.
  • Observability & Telemetry: Configured OpenTelemetry spans using the Arize Otel SDK (arize-otel) to stream execution traces (LLM calls, tool runs, latencies) to the Arize Phoenix Cloud platform.
  • Security & Guardrails: Utilized Google Cloud Model Armor (google-cloud-modelarmor) safety templates to filter jailbreaks and prompt-injections, backed by custom ADK safety callbacks to enforce standard refusal behaviors.
  • Frontend Dashboard: A responsive dark-themed dashboard written in vanilla HTML5, CSS3, and JavaScript, using Leaflet.js for mapping.
  • Containerization & Deployment: Local container orchestration using Docker and Docker Compose, deployed to Google Cloud Run using GitHub Actions with Workload Identity Federation (WIF).

Challenges I Ran Into

  1. MongoDB MCP Server Startup Timeouts in Serverless Container Environments:
    • Problem: During container cold starts on Cloud Run, the backend crashed because the MongoDB MCP server took time to download, spin up the Node.js subprocess, and establish a TLS connection to MongoDB Atlas. By default, Google ADK's McpToolset uses StdioConnectionParams which enforces a strict 5.0-second initialization timeout.
    • Solution: Increased the initialization timeout to 90.0 seconds, allowing the Node.js subprocess and MongoDB Atlas connection handshake sufficient time to complete, which stabilized container startup.
  2. Telemetry API Key Handshakes (arize-phoenix-otel vs. arize-otel):
    • Problem: Traces sent to Arize Cloud returned persistent HTTP 401 Unauthorized errors in production logs.
    • Root Cause: The backend initially utilized the Phoenix OSS SDK (arize-phoenix-otel), which is meant for self-hosted instances and does not inject space_id and api_key headers into OTLP exports.
    • Solution: Switched to the official arize-otel SDK and updated the initialization to arize.otel.register(), which correctly formats the headers for Arize Cloud authentication.
  3. Vertex AI Model Regional Availability & Decoupling:
    • Problem: Setting GOOGLE_CLOUD_LOCATION=europe-west1 caused Vertex AI Agent Engine calls to fail with 404 errors as the Reasoning Engine could not allocate the Gemini model.
    • Solution: Decoupled the Agent Engine location from the model location. Set the model API calls to target the eu multi-region where model generation is fully supported, while keeping the Agent Engine resources executing in europe-west1.
  4. Vertex AI Agent Engine Session Naming Constraints:
    • Problem: Webhook scheduled scans crashed with 400 INVALID_ARGUMENT: Invalid Session resource name.
    • Root Cause: Vertex AI Session Service session IDs are validated against a strict GCP resource name regex (^[a-z0-9-]+$). The scheduled task generated session IDs containing underscores (e.g. scheduled_run_2026-06-11_abcde).
    • Solution: Replaced underscores with dashes (scheduled-run-2026-06-11-abcde), satisfying the naming schema and restoring successful background executions.

What I Learned

  • Remote Sensing Calculations: Learned how to compute NDVI and MNDWI indices dynamically over rolling satellite date windows to monitor urban waterways.
  • Agent Orchestration and MCP: Learned to use Google ADK and Model Context Protocol (MCP) to safely delegate database tasks to Namespaced MongoDB servers.
  • Enterprise Observability: Gained experience instrumenting OpenTelemetry tracing and streaming traces to Arize Phoenix Cloud to evaluate agent accuracy and latency.
  • Serverless Scaling State Management: Learned how to manage session and memory persistence across serverless container restarts using VertexAiSessionService.

What I'm Proud Of

For a sophisticated system such as Sentinel Flood-Watch, I am incredibly proud of the end-to-end operationalization of the system in a live production environment. The agent is able to reliably and consistently invoke the available tools to complete its complex monitoring and reporting workflows while staying grounded in real-world satellite data, which has led to a significant reduction in hallucinations.


What's Next

The following extensions and enhancements are planned for Sentinel Flood-Watch:

  • Expanded Coverage: Extend monitoring beyond Greater Accra to cover other high-risk ecological and wetland sites across the country.
  • Self-Healing Layer: Integrate a self-healing layer utilizing Phoenix MCP that monitors the agent's runtime execution, automatically flags performance regressions, and implements updates or hotfixes dynamically.
  • Mobile Optimization: Optimize the web dashboard UI for mobile devices to allow local disaster management inspectors and environmental officers to perform on-the-go monitoring.
  • Production SMS Alerts: Integrate a dedicated production-level SMS dispatcher service (such as Twilio) to deliver instant flood risk alerts directly to authorities.

Tech Stack

  • Languages:
    • Backend: Python
    • Frontend: JavaScript, HTML5, CSS3, Leaflet.js
  • Frameworks:
    • Google ADK (Agent Development Kit)
    • FastAPI
  • Platforms:
    • Google Cloud Platform (GCP)
    • GitHub Actions
  • Cloud Services:
    • Google Earth Engine (GEE)
    • Cloud Run
    • Vertex AI Agent Engine
    • Google Cloud Model Armor
    • Arize Phoenix
  • Databases:
    • MongoDB Atlas (with local file-based JSON fallbacks)
  • APIs:
    • OpenStreetMap Nominatim Geocoding API

Built With

  • arizephoenix
  • cloudrun
  • css3
  • fastapi
  • githubactions
  • googleadk
  • googlecloudmodelarmor
  • googlecloudplatform
  • googleearthengine
  • html5
  • javascript
  • leaflet.js
  • mongodbatlas
  • openstreetmapnominatimgeocodingapi
  • python
  • vertexaiagentengine
Share this project:

Updates