Transforming flood management from reactive crisis response into proactive community resilience.
🌐 Live Application · 🎥 3-Min Video Walkthrough
ℹ️ Architectural Note: This repository contains the Aegis Frontend Client Application. The backend (GRU neural prediction pipelines, Expert Arbitration Network, and alerting gateways) is closed-source and hosted separately. This repository showcases client-side architecture, 3-hour in-memory capability caching, failure boundary isolation, and resilient API consumption.
- What is Aegis?
- Why Was It Built?
- System Architecture
- Frontend Features
- Testing & Quality
- Key Engineering Decisions
- Tech Stack
- Screenshots & Workflows
- Local Development & Setup
- Project Team & Acknowledgments
Aegis is an AI-powered disaster management platform designed to predict riverine and flash floods, issue early warnings, and dynamically guide citizens and rescue teams to safety in Pakistan's flood-vulnerable zones.
Powered by a backend Expert Arbitration Network (EAN) and GRU Super Engine, this frontend acts as the high-availability interface that translates complex hydrological models into intuitive, real-time safety directives for citizens and emergency response teams.
👉 Experience the live deployment: aegis-frontend-8jn6.onrender.com
Pakistan's traditional disaster response infrastructure suffers from a critical "last-mile" communication gap:
- Comprehension Barrier: Warnings often arrive wrapped in technical hydrological jargon that confuses citizens. Aegis translates telemetry into plain-language safety alerts in both English and Urdu.
- Infrastructure Fragility: Cellular towers and internet backbones frequently degrade during active monsoons. Aegis operates as an offline-capable PWA with persistent local caching for shelters and evacuation paths.
- Coordination Silos: NGOs and rescue organizations traditionally rely on fragmented messaging channels. Aegis provides a centralized, spatial map dashboard for real-time dispatch and relief tracking.
The client application integrates with backend services through resilient adapters with strict failure isolation:
graph TD
subgraph "Aegis Frontend Client (This Repository)"
PWA[Citizen PWA Interface<br/>React.js / Vite / Tailwind]
NGO[NGO Tactical Dashboard<br/>React.js / Leaflet]
Cache[3-Hour In-Memory Capability Cache<br/>0ms Retrieval / LocalStorage Fallback]
Assistant[Aegis Assist AI Chatbot<br/>Claude-Style Prose & Markdown RAG]
PWA --> Cache
NGO --> Cache
Assistant --> Cache
end
subgraph "Backend Services (Private API)"
API[FastAPI Gateway]
EAN[Expert Arbitration Network / GRU Engine]
AlertSvc[Hydrological Alert Pipeline]
SOSSvc[Emergency SOS Dispatch Engine]
RouteSvc[Dynamic Evacuation Routing]
ShelterSvc[Shelter Capacity & Proximity Service]
end
subgraph "External Providers"
OM[Open-Meteo Weather API]
OR[OpenRouter Free AI Models]
GQ[Groq Inference Engine]
FB[Firebase Auth & Firestore]
end
PWA <-->|Resilient HTTPS Adapter| API
NGO <-->|Live Firestore Listeners| FB
API --> EAN & AlertSvc & SOSSvc & RouteSvc & ShelterSvc
API --> OM & OR & GQ & FB
- 🗺️ Interactive Risk & Evacuation Map: Built with Leaflet.js and CartoDB tiles, visualizing flood risk polygons, safe travel corridors, and nearest shelters.
- 💬 Aegis Assist AI Chatbot: An intelligent disaster assistant offering real-time flood guidance, shelter availability, and evacuation advice using live dashboard snapshot context and Claude-style conversational prose.
- ⚡ 0ms Instant Cache Hydration: Employs a 3-hour in-memory capability cache ensuring zero redundant network waterfalls when switching between pages.
- 🌐 Bilingual Accessibility: Direct safety instructions offered in both English and Urdu.
- 📴 Offline PWA Support: Built-in Service Worker precaching guarantees critical shelter coordinates remain accessible during connectivity loss.
- 🆘 One-Click SOS Dispatch: Captures live normalized GPS coordinates and transmits them to district rescue responders.
- 📊 NGO Command Hub: Dedicated portal for relief agencies to monitor active flood zones, distress signals, and shelter capacity.
Aegis includes an automated frontend verification suite focused on data handling, service behavior, caching policies, and resilience when third-party dependencies fail.
| Check | Result |
|---|---|
| Automated Frontend Tests | 28 passed, 0 failed |
| Test Suites | 8 suites |
| Production Build | Passed (Vite v5.4.21 bundle verification) |
| CI/CD Pipeline |
Test results above reflect the latest verified baseline. CI status is actively asserted on every commit in GitHub Actions.
The test suite distinctly separates unit behavior from multi-component failure boundaries:
- Unit Tests: Validate individual functions in complete isolation:
- Location Normalization: Coordinate precision clamping (4 decimals), boundary validation, and Haversine distance calculations.
- Cache TTL & Freshness Policy: Validation of
FRESH,STALE, andEXPIREDlifecycles, and relative timestamp generation. - API Client Telemetry: Structured event logging and error mapping without crashing.
- Integration & Resilience Tests: Verify end-to-end component contracts under adverse network conditions:
- Weather Outage Isolation: Verifies that when the weather API provider drops or times out (503), citizen authentication, user profile, flood risk, and shelters remain 100% operational.
- Backend 500 Outage Isolation: Proves that local shelter maps and cached forecasts remain functional even if backend services experience a 500 server crash.
- Zero-Network Navigation: Validates that returning to the dashboard reuses in-memory cached state with zero redundant network calls.
- Auth Resilience: Ensures session identity is preserved without unmounting or infinite loading during backend timeouts.
- Location Utilities: Coordinate normalization, great-circle distance, and location-aware cache keys.
- Caching Engine: 3-hour capability cache, stale-while-revalidate policies, and clean relative timestamps.
- API Client: Timeout policies, abort controllers, status normalization, and telemetry logging.
- Domain Services: Profile hydration, Open-Meteo weather adapters, flood risk evaluators, and shelter proximity sorters.
- Critical Failure Boundaries: Explicit tests confirming unrelated capabilities remain operational when external APIs drop.
From the frontend repository root:
# Install exact dependencies
npm ci
# Run the automated test suite using Node.js native test runner
npm test
# Verify production build compilation
npm run buildTesting Scope: These automated checks validate the frontend code, client-side resilience, and service contracts. They do not by themselves establish complete end-to-end reliability of the private backend or live cellular provider infrastructure.
To eliminate sluggish page-to-page navigation and network thrashing, Aegis caches domain payloads (weather, flood intel, forecast, shelters) in memory for up to 3 hours with silent background synchronization. Navigating away and returning to the dashboard executes in < 15ms without displaying loading spinners.
External APIs (weather endpoints, backend microservices, geolocation reverse lookups) are isolated behind resilience wrappers. If an optional third-party service times out, Aegis degrades gracefully to cached or baseline telemetry rather than crashing the interface or locking the user out.
Aegis Assist converts structured real-time telemetry (river discharge, 4-day forecast, open shelter facilities) into warm, articulate prose formatted with react-markdown. Instead of unhelpful key-value lists, citizens receive reassuring, actionable guidance formatted with comfortable typography.
| Domain | Technologies |
|---|---|
| Frontend Framework | React 18, Vite 5, Tailwind CSS |
| Geospatial & Mapping | Leaflet.js, React-Leaflet, CartoDB Tile Layer |
| AI & Markdown | React-Markdown, OpenRouter API, Groq Cloud |
| Authentication & Realtime | Firebase Auth, Google Firestore |
| PWA & Offline | Vite PWA Plugin, Workbox, Service Workers |
| Test Runner | Node.js Test Runner (node --test), Assert |
| CI / CD | GitHub Actions (frontend-ci.yml) |
| Deployment | Render (Static Web Service) |