BlueWatch NI is a full-stack web application designed to transform raw government water quality data and citizen-generated reports into actionable alerts across Northern Ireland. By collapsing decades of time-series measurements into the latest monitoring station snapshots, BlueWatch NI delivers a clear, performant map the helps everyone make informed decisions about water safety and environmental health.
BlueWatch NI was inspired by the specification provided for the 2025 Sustainability Hackathon: Water, hosted by Queen's University Belfast. This solution was not submitted for the hackathon.
- Background & Theoretical Motivation
- System Architecture
- Project Structure
- How to Run
- API Endpoints
- Next Steps & Planned Enhancements
- License
BlueWatch NI: Real-time Water Quality Insights for Northern Ireland
Northern Ireland's water resources face mounting and interconnected problems:
- Climate-driven flooding threatens homes, infrastructure, and agriculture
- Pollution events degrade river, lake, and drinking-water quality
- Data inaccessability — public water dataets exist but aren't actionable for citizens or small businesses
- Lack of community feedback loops means on-the-ground observations go unheard
Our Solution: BlueWatch NI
BlueWatch NI is a web platform that fuses live government water-quality data and hydrological dat with crowd-sourced reports to deliver real-time alerts on water quality and flood risk.
- Latest Reading Aggregation: Collapses 140,000+ historical measurements into a single, up‑to‑date data point per monitoring station.
- Water-Quality Risk Engine: Applies configurable thresholds (e.g., DO < 5) to flag “high risk” conditions and log alerts.
- REST API Endpoints:
GET /api/aggregatereturns { lastAggregationTime, aggregatedData } for map visualization.GET /api/reportreturns all user‑submitted reports.
- Interactive Map Visualisation: Google Maps integration that plots color‑coded circles for each station and markers for user reports.
- Demo-Mode Performance Cap: Environment‑driven
DEMO_FEATURE_LIMITto restrict plotted stations (e.g., 200) for smooth demos. - Secure Key Injection: Google Maps API key injected via EJS templates from
.env, with referrer restrictions for added security. - Containerised Deployment: Docker & Docker Compose configuration ensures consistent setup across development and production.
- River Water Quality Monitoring (1990-2018): GeoJSON feature collection of river-monitoring station readings (DO, pH, etc.), used end-to-end for aggregation, risk evaluation, and map plotting.
Additional OpenData NI water datasets (e.g. lakes, private supplies, protected areas) may be incorporated in future enhancements.
- Data Ingestion: Scheduled tasks fetch GeoJSON from OpenData NI.
- Latest Reading Aggregation: Collapses all time-series samples into the most recent reading per station.
- Risk Engine Evaluation: Applies threshold rules (DO, pH, contaminants) to identify “high risk” sites and triggers alerts.
- Notification Dispatch: Logs alerts in-memory (with extension points for email, push, or external channels).
- API Exposure: Provides RESTful endpoints for aggregated data and user reports.
- Frontend Visualisation: EJS-backed page injects the Google Maps API key and runs
map.jsto render circles and markers.
- Protects Public Health: Surfacing water-quality hazards in real time helps users avoid contaminated water.
- Mitigates Flood Risks: Early, localized flood warnings reduce property damage and enhance preparedness.
- Empowers Communities: Crowdsourced reporting and open data transparency enable grassroots engagement.
- Supports Environmental Resilience: Data-driven insights inform policy decisions and sustainable resource management.
BlueWatch NI is structured as a modern, modular, containerised web application, enabling easy development, testing, and scaling.
- waterDataService: Fetches, caches, and filters GeoJSON data from OpenData NI at regular intervals.
- dataAggregator: Aggregates the latest reading per station, evaluates water-quality risk, and maintains in-memory data structures.
- alertService: Receives risk alerts from the aggregator and logs or dispatches notifications
- reportService: Handles creation, validation, and retrieval of user-submitted reports.
- aggregationRoutes & reportRoutes: Express routers and controllers exposing RESTful endpoints.
- EJS:
index.ejsserves the base HTML and injects environment-configured variables - Map Logic:
map.jsimplements Google Maps integration, rendering color-coded circles for stations and markers for reports. - Static Assets: Served via Express middleware under
/assetsand/scriptsfor CSS and JavaScript.
- RESTful HTTP: All frontend-backend interactions use JSON payloads over HTTP requests to the API routes.
- Stateless Services: No shared process memory beyond in-memory caches.
- Docker & Docker Compose: The application runs via Docker and Docker Compose enabling both development and deployment.
- Environment Configuration: Uses
.envfor secrets. 9 CI/CD Ready: Can integrate with GitLab CI or GitHub Actions for automated builds, tests, and deployment.
bluewatch-ni/
client/
assets/
style.css
scripts/
map.js
views/
index.ejs
src/
app.js
server.js
config/
config.json
controllers/
aggregatorController.js
reportController.js
waterController.js
routes/
aggregateRoutes.js
reportRoutes.js
waterRoutes.js
services/
alertService.js
dataAggregator.js
reportService.js
riskEngineService.js
waterDataService.js
tests/
...Unit & Integration Tests...
.env
.gitlab-ci.yml
docker-compose.yml
Dockerfile
package.json
README.md
- Docker & Docker Compose
git clone https://gitlab.com/BHarris02/bluewatch-ni.git
cd bluewatch-niCopy the example environment file and update it with the required API keys, etc.
cp .env.example .envdocker-compose up --buildThe application will be available at http://localhost:3000
To stop and remove the container, press CTRL+C in your terminal and then run:
docker-compose down- Ensure all required environment variables are set in your .env file, and that the .env file is located at the project root.
- If port 3000 is already in use, stop other processes or change the port in docker-compose.yml
- For other issues, check the container logs:
docker-compose logs <bluewatch-api>Below are the primary RESTful endpoints exposed by the BlueWatch NI API. No authentication is required for demo/hackathon use.
- Description: Returns the timestamp of the latest aggregation and an array of the most recent water-quality features, one per station.
- Parameters: None
- Example:
curl http://localhost:3000/api/aggregate - Response:
{ "lastAggregationTime": "2025-07-15T12:34:56.789Z", "aggregatedData": [ { "properties": { "Station_Name": "River X", "DO_MGL": 7.5, "PH": 7.2 }, "geometry": { "type": "Point", "coordinates": [-6.1, 54.6] } }, // …more features ] }
- Description: Retrieves all user-submitted reports of pollution, flooding, or hazards.
- Parameters: None
- Example:
curl http://localhost:3000/api/report - Response:
[ { "lat": 54.62, "lng": -5.90, "type": "pollution", "comment": "Oil slick observed", "timestamp": "2025-07-14T09:20:00.000Z" }, // …more reports ]
- UI Filtering: Station, basin, and date‑range selectors on the map interface.
- Report Analytics: Query parameters for
/api/report(type, date range) and corresponding UI controls. - Clustering & Heatmaps: Marker clustering and density heatmaps for large datasets.
- Persistence & Authentication: Integrate a database and user authentication for secured report submissions.
This project is licensed under the terms of the MIT License. See the LICENSE file for details.