AWS Builder Center
Building JalRakshak AI: AWS Strands, Cedar & OpenSearch for Urban Floods and Extreme Heat

Building JalRakshak AI: AWS Strands, Cedar & OpenSearch for Urban Floods and Extreme Heat

How we engineered an autonomous, protocol-grounded disaster decision platform using the AWS Strands Agents SDK, Cedar RBAC, OpenSearch 2.x, and SAM CLI to cut municipal flood response latency from 4 hours down to 18 minutes — running 100% locally with zero cloud bills.

Building JalRakshak AI: AWS Strands & Cedar for Floods and Heat (and What Fought Back)

Track: Heat and Water (Track 02) | Route: Build It (100% Local, Zero Cloud Credentials Required) Team: Team SheBuilds Author: Riyanshi Verma (Lead Developer & Systems Architect) & Team LinkedIn:  https://www.linkedin.com/in/riyanshi-verma-ba363a2b2  Repository:  https://github.com/RiyanshiVerma-11/JalRakshak-AI  Hackathon: WeMakeDevs × AWS "Environmental Hacks" Tags: AWS, serverless, agents, disaster-management, sustainability, climate, open-source



The Crisis: Urban Disaster Decision Latency

Every year, Indian metropolises face a brutal dual climate cycle: in July, an intense 118 mm/hr cloudburst inundates low-lying municipal wards within 40 minutes, submerging hospital ICUs, tripping electrical substations, and turning arterial roadways into canals. Nine months later, May brings lethal 48.6°C wet-bulb heatwaves, water pipeline ruptures, and parched municipal reservoirs.
When examining municipal emergency control rooms during these disasters, there is a striking paradox: the bottleneck is never a lack of sensors. Modern command centers receive gigabytes of IoT rain gauge feeds, Doppler radar telemetry, SCADA pipeline pressure waveforms, and ambient thermal sensors every second.
The breakdown occurs in operational decision latency:
  1. During a flash flood or severe heatwave, control rooms receive over 1,200 panicked citizen calls in under 30 minutes.
  1. Correlating environmental telemetry against infrastructure capacities, hospital registries, and emergency resource fleets (1,000 GPM dewatering pumps or mobile cooling vans) requires 3 to 4 hours of manual cross-departmental coordination.
  1. In civic governance, an ungrounded, probabilistic AI cannot legally dispatch emergency equipment, isolate power grids, or issue statutory evacuation sirens under the Disaster Management Act 2005.
Our core design question: Most civic dashboards tell administrators what is happening. Can we build an autonomous, protocol-grounded system that determines what statutory action to authorize next within 18 minutes — for both flash floods and extreme heatwaves — running completely offline without cloud dependencies?
This led Team SheBuilds to engineer JalRakshak AI (Water & Climate Guardian) for the WeMakeDevs × AWS Environmental Hacks (Track 02: Heat and Water — Build It Route).




1. Architecture Overview: The AWS Open-Source Stack

To qualify for the hackathon's Build It route, our architectural mandate was absolute: the entire platform must run 100% locally on a developer laptop, without requiring judges to create an AWS account, configure API keys, enter credit cards, or incur cloud bills.
JalRakshak AI is built squarely on five open-source foundations from the AWS ecosystem:
  • AWS Strands Agents SDK: Drives our deterministic 5-agent DAG workflow, tool wrapper system, and rate-limit circuit-breaker hook.
  • AWS Cedar Policy Engine: Powers statutory RBAC policy compilation and mathematical authorization decisions via official cedarpy bindings.
  • AWS OpenSearch 2.x: Ingests Kurla Outfall SCADA hydrological telemetry, sensor deltas, citizen emergency reports, and executes Query DSL anomaly detection.
  • AWS SAM CLI: Validates serverless templates ( sam validate ) and packages portable Lambda container images ( sam build ).
  • LocalStack: Provides zero-cost offline emulation for EventBridge, DynamoDB, SNS, and S3 in  docker-compose.local.yml .
plaintext
┌──────────────────────────────────────────────┐
│ Real-Time Environmental Stream │
│ (SCADA Hydrology, Thermal Grids, PWA) │
└───────────────────────┬──────────────────────┘
│
┌─────────────────▼─────────────────┐
│ AWS SAM CLI Infrastructure │
│ (EventBridge + Lambda Handlers)│
└─────────────────┬─────────────────┘
│
┌────────────────────────▼────────────────────────┐
│ AWS Strands Agents SDK (5-Agent DAG) │
│ Risk ──► Impact ──► Resource ──► Comms ──► SOP│
└──────────────┬───────────────────┬──────────────┘
│ │
┌────────────────────────▼─────────┐ ┌─────▼──────────────────────────────────┐
│ AWS Cedar Policy Engine (Rust) │ │ Amazon Bedrock / Local Fallback │
│ Statutory Commander Sign-off │ │ TF-IDF SOP RAG (NDMA 2024 / NHAP) │
└──────────────────────────────────┘ └────────────────────────────────────────┘



2. Build It Route: What Actually Runs on a Laptop

In accordance with the Build It route specifications, anyone can clone and run JalRakshak AI locally with zero cloud dependencies:
Bash
# Three-command quickstart (Zero config, no .env required)
git clone https://github.com/RiyanshiVerma-11/JalRakshak-AI.git
pip install -r requirements.txt
python run_app.py

The Architectural Truth Table: Real vs. Simulated

Component
What Runs For Real on Your Laptop
What is Honestly Simulated
AWS Strands Agents SDK
Genuine strands Agent loop, tool invocation cycles, and StrandsCircuitBreakerHook lifecycle
In OFFLINE mode, LLM inference is fulfilled locally by LocalDeterministicModel; real Bedrock calls run when AWS_EXECUTION_MODE=LIVE.
AWS Cedar Policy Engine
Real Rust-backed Cedar policy evaluations via cedarpy against incident_policy.cedar
None. Every permit/forbid decision is computed live by the Cedar engine.
AWS OpenSearch 2.x
Real query DSL telemetry indexing & SCADA anomaly thresholds
In-memory fallback if Docker OpenSearch container is inactive.
AWS SAM CLI
Real SAM template validation ( sam validate ) and artifact build ( sam build )
Direct handlers are tested via pytest; Docker container emulation is optional.
Incident State & Storage
Real in-memory state store with thread locking, query indexing, and JSON serialization
DynamoDB network calls are skipped in offline mode ( simulated: true ), connecting live when credentials exist.
Emergency Notifications
Real alert generation in 3 languages (English, Hindi, Marathi) with SMS/WhatsApp payloads
Real SNS network publishing requires AWS credentials; offline mode queues payloads with  simulated: true .
Multimodal Vision
Real computer vision feature extraction on actual uploaded image bytes via Pillow/NumPy
AWS Rekognition API call is bypassed offline in favor of local computer vision feature analysis.









3. Multi-Agent Orchestration with AWS Strands Agents SDK

Instead of relying on a fragile prompt chain, our workflow is powered by the AWS Strands Agents SDK. Each agent is an independent Agent instance equipped with tool functions:
Python
@tool
def evaluate_risk_tool(category: str, ward_info: dict, telemetry: dict) -> dict:
"""
Strands Tool: Evaluates hydrological and meteorological hazard risk
from real-time sensor streams and drainage capacities.
"""
return risk_agent.evaluate(category, ward_info, telemetry)
risk_detection_agent = Agent(
agent_id="strands-agent-risk-01",
name="Risk Detection Agent",
description="Evaluates sensor deltas, hydrological saturation, and calculates mathematical explainability scores.",
system_prompt="You are Strands Risk Detection Agent for JalRakshak AI. You evaluate real-time sensor streams and determine hazard severity.",
tools=[evaluate_risk_tool],
hooks=[circuit_breaker_hook],
model=get_strands_model("Risk Detection Agent")
)
The 5 agents collaborate sequentially in a directed acyclic graph:
  1. Risk Detection Agent: Evaluates sensor deltas against hydrological saturation thresholds.
  1. Impact Assessment Agent: Correlates GIS perimeters with demographic registries and hospital ICUs.
  1. Resource & Response Agent: Optimizes municipal asset allocation (1,000 GPM pumps, misting bowsers, tankers).
  1. Multilingual Communication Agent: Synthesizes localized warnings in English, Hindi, and Marathi.
  1. Coordinator Agent: Queries statutory NDMA / CPHEEO SOP knowledge base to formulate the actionable incident plan.







4. Statutory Governance with AWS Cedar

Under the Indian Disaster Management Act 2005, an AI cannot legally dispatch municipal machinery or isolate transformers without statutory authorization. We enforce this through declarative policies evaluated by the official Rust-backed AWS Cedar engine ( cedarpy ):
cedar
// 1. Municipal Incident Commander (Tier 1 Apex Command)
permit(
principal in JalRakshak::Role::"incident_commander",
action in [
JalRakshak::Action::"read_incidents",
JalRakshak::Action::"approve_action",
JalRakshak::Action::"dispatch_resource",
JalRakshak::Action::"broadcast_sns",
JalRakshak::Action::"simulate_scenario"
],
resource
);
// 2. Explicit Denial of Sensitive Command Actions to Citizens
forbid(
principal in JalRakshak::Role::"citizen",
action in [
JalRakshak::Action::"approve_action",
JalRakshak::Action::"dispatch_resource",
JalRakshak::Action::"broadcast_sns"
],
resource
);
During evaluation, cryptographic JWT claims are extracted and validated directly by Cedar:
Python
try:
result = cedarpy.is_authorized(request, _CACHED_POLICY, entities)
allowed = (result.decision == cedarpy.Decision.Allow)
logger.info(f"[CEDAR AUTH] Engine: {engine} | Decision: {'ALLOW' if allowed else 'DENY'} | Action: {action}")
return {"allowed": allowed, "engine": engine, "decision": str(result.decision)}
except Exception as exc:
logger.error(f"[CEDAR AUTH] Error during cedarpy evaluation: {exc}")
return {"allowed": False, "engine": engine, "error": str(exc)}




5. What Fought Back: Four Engineering Battles

Battle 1: LLM Latency & Rate Throttling During Live Crises

During concurrent rainfall spikes, cloud LLM APIs risk HTTP 429 throttling or multi-second latency spikes. We built  StrandsCircuitBreakerHook  subclassing  strands.hooks.HookProvider . By listening to  AfterToolCallEvent  and  AfterInvocationEvent , the hook detects rate throttling and immediately engages deterministic statutory NDMA Chapter 4 fallbacks without crashing the user session.

Battle 2: The "Zero-Config" Honest Execution Dilemma

Many hackathon submissions fake external cloud calls with deceptive mock IDs. We implemented explicit runtime transparency: in offline Build It mode, payloads clearly declare  simulated: true  and  mode: "OFFLINE" . Real boto3 client creation occurs only when valid credentials matching  ^(AKIA|ASIA)[A-Z0-9]{16}$  are present.

Battle 3: Mathematical Explainability vs. Black-Box Scoring

Municipal disaster controllers reject ungrounded AI scores because standard LLMs cannot mathematically justify why an emergency is 87% vs 65%. We anchored the Risk Agent's scoring in a physical explainability equation combining rainfall/thermal spike deltas (+38%), drainage saturation (+25%), verified citizen photo reports (+21%), and hospital proximity (+16%), bounded deterministically between 0.0 and 1.0.

Battle 4: SAM Packaging & Monorepo CodeUri

Running  sam build  in a monorepo caused SAM CLI to try packaging the entire frontend bundle into the Lambda package. We refactored  aws_infra/template.yaml  using strict  .samignore  rules and localized anchors with explicit handlers ( lambda_handlers.strands_agent_orchestrator_handler  and  lambda_handlers.citizen_ingest_handler ).



6. Operational Results & Quantified Benchmarks

Reproducible Performance Benchmarks (Empirical Data)

  • Command Executed:  python tests/benchmark_strands.py 100 
  • Test Machine: AMD64 (12 logical cores), 7.3 GB RAM, Windows 10, Python 3.11.3
Metric
Measured Value
Notes & Context
Iterations
100 runs
100 consecutive executions of the full 5-agent DAG
p50 Latency (Median)
62.14 ms
Full local 5-agent loop in ~62 ms p50 on 12-core host
p95 Latency
82.51 ms
High percentile under local background scheduler jitter
Min Latency
57.74 ms
Fastest complete 5-agent traversal
Max Latency
127.34 ms
Peak traversal latency
Automated Test Suite
36/36 Passing
Integration, Cedar RBAC, Build It route, and SAM validation

Quantified Economic ROI & Modelled Assumptions

  • Traditional Escalation: 4 hours manual phone-tree escalation.
  • JalRakshak AI Decision Window: 18 minutes from telemetry trigger to authorized tactical pump deployment.
  • Modelled Economic Savings: Based on a modeled 118 mm/hr cloudburst in Mumbai Ward 17 (Kurla East):
  • Unmitigated Damage Baseline: ₹1.4 Crore (computed from flood ingress into 3 ground-floor hospital wards @ ₹45L, 2 basement distribution transformer failures @ ₹55L, and arterial LBS Marg traffic gridlock loss @ ₹40L).
  • Mitigated Damage with JalRakshak AI: ₹55 Lakhs (early dewatering pump pre-deployment keeps flood depth under 25 cm, preventing hospital ICU ingress and electrical substation submergence).
  • Net Modelled Civic Assets Protected: ₹85 Lakhs (~$100,000) saved per severe event.



7. Who Actually Uses This?

JalRakshak AI separates civic responsibilities across four distinct personas:
  1. Resident Citizen: Submits geo-tagged photo evidence via an offline-ready PWA with instant computer vision flood depth estimation (42 cm) and receives emergency alerts in English, Hindi, and Marathi.
  1. Chief Hydrologist & SCADA Analyst: Monitors real-time pipeline pressure waveforms and drainage outfall saturation telemetry through AWS OpenSearch 2.x Query DSL.
  1. Municipal Incident Commander: Reviews statutory dispatch directives in the Decision Room and signs off on emergency resource mobilizations via AWS Cedar RBAC in one tap.
  1. Tactical Field Responder: Deploys high-capacity pumps and rescue teams with precise GIS routing within 18 minutes of alert generation.



8. What I'd Build with AWS Credits Next

If granted production AWS Cloud Credits, we would scale JalRakshak AI from a laptop-tested architecture to citywide municipal infrastructure:
  1. Physical IoT River Inundation Gateways: Ingesting solar-powered LoRaWAN ultrasonic water-level sensors deployed along the Mithi River directly into the Amazon EventBridge custom bus.
  1. Doppler Radar Nowcasting Ingestion: Streaming IMD Doppler radar spatial grids through AWS Lambda 90 minutes before precipitation hits urban drainage basins.
  1. OpenSearch Serverless Semantic Retrieval: Upgrading the TF-IDF SOP store to Amazon OpenSearch Serverless with multi-vector embeddings for complex multi-jurisdictional disaster manuals.
  1. Cross-Agency AWS Cedar Policy Federation: Federating Cedar policy stores across Municipal Corporations, the National Disaster Response Force (NDRF), and Traffic Police for unified inter-agency sign-offs.



9. Try It Yourself in 60 Seconds

You can clone and run JalRakshak AI on your machine in 60 seconds with zero AWS configuration:
Bash
git clone https://github.com/RiyanshiVerma-11/JalRakshak-AI.git
cd JalRakshak-AI
pip install -r requirements.txt
python run_app.py
Then open  localhost:8004  in your browser to test the emergency command center, simulate cloudbursts, and evaluate the Cedar authorization engine.
To run our automated judge smoke test:
Bash
bash scripts/judge_smoke.sh


Submitted to WeMakeDevs × AWS Environmental Hacks — Heat and Water Track (Build It Route). Project Repository:  https://github.com/RiyanshiVerma-11/JalRakshak-AI  Authors: Team SheBuilds (Riyanshi Verma & Team)
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article