Watchdog — One Health Urban Stream Early-Warning Network
Inspiration
Urban streams are the primary interface where city residents, companion animals, and wildlife encounter freshwater ecosystems. Across Europe, these corridors face two acute, short-term biological hazards:
- Benthic cyanobacterial blooms producing lethal neurotoxins (such as anatoxin-a) during warm, stagnant, low-flow drought conditions.
- Untreated municipal sewage discharges triggered by Combined Sewer Overflows (CSOs) during heavy rainfall events.
In narrow urban streams (often only 3 to 10 metres wide), satellite remote sensing is physically incapable of detecting water quality due to mixed-pixel resolution limits and dense riparian canopies. Meanwhile, traditional municipal grab-sampling and laboratory cultures take several days—far too slow to prevent acute intoxications.
In August 2017, at least eight dogs died after swimming in the Loire river during a period of extreme heat and low water. Authorities subsequently confirmed toxic benthic cyanobacteria mats on the riverbed, but official public warnings were issued only after the fatalities occurred. Canines routinely act as the primary biological sentinels for these hazards (Hilborn & Beasley, 2015; Backer et al., 2013): dogs swim in shallow shoreline edges, drink surface water, and ingest toxic detached mats.
The gap is not scientific awareness—it is timing and interoperability. OneAquaHealth's research across 100 urban stream sites in five European cities demonstrated that pharmaceuticals were present at 91% of sites, alongside antibiotic-resistance genes in biofilms and elevated human health risks in degraded reaches.
Watchdog exists so the warning arrives before exposure. We operationalize a One Health framework: turning daily riverbank walkers and their pets into distributed biological sensors, fusing their sightings with real-time hydrological forecasts, and passing human-reviewed alerts to public health systems via standard HL7 FHIR R4 transactions.
+-----------------------------------------------------------------------------------+
| WATCHDOG SURVEILLANCE LOOP |
+-----------------------------------------------------------------------------------+
| |
| [Open-Meteo & GloFAS] + [OAH Habitat Indices] |
| │ |
| ▼ |
| 1. Predictive Watch Forecast (72-hour horizon) |
| │ |
| [30s Citizen Reports] ─┼────────────────────────┐ |
| (Signs, Dogs, Photos) ▼ ▼ |
| 2. Signal Evidence Fusion ──> Dispatch Look Request |
| (Role-weighted decay) (Volunteer Verification) |
| │ │ |
| ▼ ▼ |
| 3. Human-in-the-Loop Gate <──────────┘ |
| (Bilingual AI Draft + 8 Strict Guardrails) |
| │ |
| ▼ |
| 4. HL7 FHIR R4 Transaction Bundle ──> [Public Health Authority / HAPI]|
| |
+-----------------------------------------------------------------------------------+
What it does
Watchdog operates a closed, seven-stage syndromic surveillance loop:
- Deterministic Hazard Forecasting: Ingests thermal, precipitation, and discharge telemetry from Open-Meteo and GloFAS, scaled by each reach's physical vulnerability from OneAquaHealth habitat surveys (canopy shade deficiency, channel modification, and soil imperviousness). When biological hazard criteria are met, Watchdog opens a 72-hour Watch window.
- Crowdsourced Sentinel Reporting: A bilingual (English and Portuguese) progressive web app enables riverbank walkers to report observations in under 30 seconds without creating an account. Reporters record four sentinel streams:
- Wildlife: Fish kills, disoriented waterbirds, dead amphibians.
- Water signs: Dark benthic mats, surface scum, discolouration, sewage odour, persistent foam.
- Companion animals: Dogs exhibiting acute lethargy, vomiting, or tremors within 2 hours of water contact.
- Community wellbeing: One-tap emotional response (joy, serenity, concern) tracking perceived ecosystem status.
- Privacy by Construction: Client-side HTML5 Canvas processing scrubs all EXIF metadata (including embedded GPS tags) before image upload. An instant "Forget this device" control erases all local identifiers.
- Signal Synthesis & Evidence Fusion: Aggregates incoming field reports against reach vulnerability using exponential temporal decay and role weighting. When evidence crosses alert thresholds, a Signal is generated for municipal coordinators.
- Human-in-the-Loop Advisory Gate: AI drafts a bilingual public advisory (English and Portuguese). Eight strict deterministic guardrails evaluate the draft, barring sensationalist adjectives, verifying active validity timestamps, and enforcing mandatory veterinary referrals. No machine draft can publish without authenticated human approval.
- Health System Interoperability (HL7 FHIR R4): Approved advisories compile atomically into HL7 FHIR R4 transaction bundles linking environmental observations, canine patients (
patient-animalextension), and cryptographic provenance records for delivery to public health authorities. - Season Ledger & Ecological Restoration: Aggregates seasonal risk-days and attributes root-cause vulnerabilities to physical habitat deficits (e.g., lack of riparian shade), mapping corrective actions directly to the OneAquaHealth Catalogue of Measures.
The Mathematical Formulations
1. Predictive Watch Formulation: A reach Watch quantifies physical hazard plausibility prior to community biological reports:
$$\text{Watch Score} = 100 \times T(\text{Weather}) \times V(s)$$
Where $T(\text{Weather}) \in [0, 1]$ models thermal stress, 14-day cumulative rainfall deficit, and discharge ratio: $$T(\text{Weather}) = \text{clamp}\left(0.45 \cdot \frac{T_{\max} - 22}{14} + 0.35 \cdot \left(1 - \frac{R_{14}}{40}\right) + 0.20 \cdot \left(1 - \text{FlowRatio}\right)\right)$$
And $V(s) \in [0.2, 1.0]$ represents reach physical vulnerability derived from OneAquaHealth habitat parameters (shade deficit, channel modification, and catchment sealed surface fraction).
2. Evidence Fusion Formulation: Field reports are fused into an evidentiary confidence score with exponential temporal decay:
$$\text{Evidence Score} = \min\left(100, \; \sum_{i} w_{\text{role}} \cdot s_{\text{sign}} \cdot e^{-\lambda \Delta t}\right)$$
Verified volunteer accounts carry higher evidentiary weight ($w = 2.5$) than unverified public submissions ($w = 1.0$). Reports older than 48 hours decay to near-zero ($\lambda = 0.05/\text{hr}$). Acute canine neurotoxicity reports (onset under 2 hours) trigger an immediate priority escalation.
How we built it
Watchdog is implemented as an isomorphic full-stack TypeScript application (99.2% TypeScript) engineered for resilience under unreliable network conditions:
- Frontend & UI Architecture: Next.js 15 (App Router), React 19, Tailwind CSS, Zustand state store, and accessible component primitives. Responsive, high-contrast UI with one-tap Portuguese/English switching and a large-text accessibility toggle.
- Dual-Transport Architecture:
- Local Mode: 100% offline, client-side execution via pure reducers for demonstration and field-disconnected operation.
- Remote Mode: Centralized multi-device synchronization backed by libSQL/Turso with optimistic client-side mutation rebasing, in-process transaction mutex write locks, and auto-reconnecting poll cycles.
- Real Environmental Telemetry: Live and historical weather data via Open-Meteo Weather API; hydrological river discharge telemetry via GloFAS (Copernicus Emergency Management Service). Replayed historical calibration week: July 15–21, 2026 (Coimbra, Portugal).
- Responsible AI Engine: Provider-neutral LLM adapter (Gemini 2.5 Flash and Claude 3.5 Sonnet) constrained to structured JSON schemas. Every machine draft is evaluated against eight programmatic safety guardrails before the coordinator can review or publish it.
- Healthcare Interoperability (HL7 FHIR R4): A custom atomic transaction compiler generates validated FHIR R4 bundles connecting environmental, veterinary, and clinical resources:
+-----------------------------------------------------------------------------------+
| HL7 FHIR R4 TRANSACTION BUNDLE |
+-----------------------------------------------------------------------------------+
| |
| Bundle (Type: transaction, Meta: synthetic-demo) |
| │ |
| ├── Location (Site coordinates, reach name, conditional create: ifNoneExist) |
| │ ▲ |
| │ ├── Observation (Watch score: Tmax, rain14, flowRatio, vulnerability) |
| │ ├── Observation (Sentinel signs: dark mats, sewage odour, scum) |
| │ └── Flag (Active public safety warning, validity period) |
| │ |
| ├── Patient (Canine patient: SNOMED CT 448771007 via patient-animal extension) |
| │ ▲ |
| │ └── Observation (Dog unwell: owner-observed symptoms, onset < 2h) |
| │ |
| ├── Communication (Bilingual alert payload, approver identity, audit hash) |
| │ |
| └── Provenance (Target: watch Observation; Agents: verifier + assembler) |
| |
+-----------------------------------------------------------------------------------+
Challenges we ran into
- Idempotent FHIR Transactions on Public Servers: Public HAPI FHIR test endpoints (
hapi.fhir.org/baseR4) reject repeated bundle submissions with HTTP 412 Precondition Failed errors if resource IDs collide. We solved this by implementing conditional create searches (ifNoneExist) acrossLocation,Patient, andProvenanceresources, binding the transaction to unique reach URIs. - Preventing Alarmist AI Drift: General-purpose LLMs tend toward sensationalist language ("deadly contamination", "toxic crisis") or speculative clinical diagnoses. We built eight deterministic server-side guardrails that parse every draft sentence-by-sentence. If an unverified assertion or alarmist adjective is detected, publishing is strictly blocked until remediated.
- Client-Side Privacy Preservation: Walkers often capture high-resolution photos that inadvertently contain EXIF GPS metadata revealing home or route locations. We implemented a dual-pass sanitization architecture: an HTML5 Canvas downsampling pipeline on the mobile client that strips all EXIF headers before upload, supplemented by a native server-side
sharpprocessing filter. - Isomorphic Dual-Transport Sync: Developing an application that operates identically offline in pure local memory and online across multiple paired smartphones and coordinator consoles required designing a pure reducer state machine with deterministic event replay and optimistic mutation rebasing.
Accomplishments that we're proud of
- 94 Vitest Automated Tests Passing: 11 comprehensive test suites validating state reducers, cryptographic audit hash chains, EXIF stripping, multi-language drafting fallbacks, and FHIR transaction idempotency.
- Flawless End-to-End Test Suite: Automated Playwright suites covering all 25 public and coordinator routes, multi-device QR code pairing, and zero accessibility regressions (0 WCAG 2.1 AA violations verified via
@axe-core/playwright). - Real-World Veterinary FHIR Modeling: Fully compliant representation of canine sentinels using the official HL7
patient-animalextension (SNOMED CT 448771007), validated with 0 errors against the HL7 FHIR R4 schema and verified live on public HAPI FHIR servers. - Sub-30-Second Citizen Workflow: Field-tested walker reporting flow requiring only 28 seconds from opening the site to submission—completely accountless, available in Portuguese and English, and respectful of user data.
- OneAquaHealth Ecosystem Alignment: Direct bridging of OneAquaHealth Citizen Science habitat question codes into actionable early-warning triggers, routing to the Decision Support System's Catalogue of Measures.
What we learned
- Sentinels Are Not Diagnosticians: Community members and dog owners are exceptionally perceptive biological observers, but public systems must never present symptom reports as confirmed laboratory diagnoses. Clear, calibrated precaution labels maintain institutional trust.
- AI Belongs in Drafting, Never in Deciding: LLMs excel at rapid multi-lingual draft formatting and symptom extraction from free text, but authorizing public alerts and dispatching field teams must remain under explicit, authenticated human governance.
- One Health Unlocks Proactive Intervention: Treating companion animal illness as an environmental leading indicator provides public health authorities and municipalities with days of advance notice before human exposure occurs or slow laboratory water cultures conclude.
What's next for Watchdog
- Pilot Deployment in Coimbra: Conducting live field trials across Rio Mondego urban stream reaches in collaboration with OneAquaHealth research partners, benchmarking Watch predictions against physical laboratory water assays.
- In-Situ IoT Sensor Integration: Supplementing meteorological forecasts with low-cost solar-powered dissolved oxygen, turbidity, and water temperature probes.
- Real-Time FHIR Subscriptions: Enabling automated FHIR R4 subscription webhooks so regional veterinary hospitals and municipal drinking water authorities receive immediate structured notifications upon advisory publication.
- Multilingual European Expansion: Adding Italian, Dutch, and French localization to support OneAquaHealth partner sites across Benevento, Ghent, and Toulouse.
References
- Hilborn, E. D., & Beasley, V. R. (2015). One Health and Cyanobacteria in Freshwater Systems: Animal Illnesses and Deaths are Sentinel Events for Human Health Risks. Toxins, 7(4), 1374–1395.
- Backer, L. C., et al. (2013). Canine Cyanotoxin Poisonings in the United States (1920s–2012): Review of Suspected and Confirmed Cases. Toxins, 5(9), 1597–1628.
- Bouma-Gregson, K., Kudela, R. M., & Power, M. E. (2018). Widespread Anatoxin-a Detection in Benthic Cyanobacterial Mats Throughout a River Network. PLoS ONE, 13(5), e0197669.
- European Parliament & Council. (2024). Directive (EU) 2024/3019 on Urban Wastewater Treatment (Recast).
- HL7 International. HL7 FHIR Release 4 (v4.0.1): StructureDefinition
patient-animal(SNOMED CT 448771007). - OneAquaHealth Consortium. Horizon Europe Research Project (Grant Agreement No. 101086521): Citizen Science App, Environmental Surveillance System, and Catalogue of Measures.
Quick Links:
- Video Demo: https://youtu.be/t_E37jJ1teE
- Live Application: https://watchdog-875g.vercel.app/
- GitHub Repository: https://github.com/edish-github/Watchdog
- FHIR Implementation Summary: https://github.com/edish-github/Watchdog/blob/main/docs/fhir/FHIR_IMPLEMENTATION_SUMMARY.md
Built With
- axe-core
- gemini-api
- glofas
- hl7-fhir-r4
- libsql
- next.js
- open-meteo
- playwright
- react
- sharp
- tailwind-css
- turso
- typescript
- vercel
- vitest
- zustand

Log in or sign up for Devpost to join the conversation.