Skip to content

About

Real-time natural hazard monitoring on a live 3D globe: earthquakes, wildfires, cyclones and floods from open data, with watch zones and alerts.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Latest commit

 

History

149 Commits

Folders and files

Repository files navigation

HazardWatch logo

HazardWatch

Earthquakes, wildfires, cyclones and floods on a live globe, from open data,
with alerts when they reach the places you watch.

Open the live map  ·  Architecture  ·  Deploy your own

CI status MIT license Runs on free tiers No API key needed

A tour of HazardWatch: the planet drawn as a live seismogram, the feature tiles alive with the events of the past day, the 3D globe of events turned by hand, and a watch zone around Bangui with the fires inside it

What it does

HazardWatch follows natural hazards around the world as they happen. A worker polls public feeds every few minutes, turns their very different formats into a single kind of event and stores them in PostGIS. The web app shows them on a 3D globe, over live satellite imagery if you like, and lets you draw watch zones around the places you care about: an office, a supplier, a family's town. When an event reaches one of them, you get an alert in the app, by email and as a notification on your devices.

Everything runs on public data and free hosting tiers, without a single API key.

The home page tiles, alive with the events of the past day: events placed over the latest clouds of GOES-East, a watch zone around Paris swept like a radar over the city lights of Europe, and an alert notification

A live globe of every hazard

The live map: a globe with clusters of events coloured by severity, the heat of fires across Africa, and the list of events beside it

  • Every source on one map. Earthquakes from USGS, fires detected from orbit by NASA FIRMS, cyclones, floods, volcanoes and droughts from GDACS, refreshed every minute.
  • Readable at any zoom. Events merge into clusters coloured by their most severe event, fires glow as a heatmap, and events that started in the past six hours pulse.
  • Every event seen from orbit. Its card shows the area around it as NOAA-20 pictured it on its last day of activity, with fires in red, and steps back and forth in days.
  • Shareable views. Filters by type, period and severity live in the URL, so any view can be bookmarked or sent.

The planet seen from orbit

The basemap switches to NASA imagery, fetched by the browser straight from NASA GIBS.

Satellite basemap: Tropical Cyclone Akvan over the Bay of Bengal, in true colour Live clouds basemap: clouds over the western United States, imaged by GOES less than an hour earlier Night lights basemap: the cities of Japan, Korea and China at night
Satellite
True colour of the last complete day, here Tropical Cyclone Akvan over the Bay of Bengal.
Live clouds
A new image every ten minutes from the GOES satellites, over the Americas and the Pacific.
Night lights
The Black Marble composite of city lights, here around the Sea of Japan.

Watch zones and alerts

The watch zones page: three zones, each with its recent events and its alert threshold A watch zone page: a 500 km circle around Bangui with the fires detected inside it, and their list
Your zones, each with its recent events and the most severe of them. A zone's page, with the hazards inside it on the map and in a list.

A watch zone is a circle of 10 to 1,000 km around any point, drawn on the map or typed in. Its page shows the hazards inside it. When a new event reaches a zone at or above the severity chosen for it, an alert appears in the app and, once the address is confirmed, in a digest email. Turn notifications on from the alerts page, and each device you choose gets them within a minute, phones included once the app is installed.

The alerts page: push notifications to turn on, and fires that reached a watch zone, coloured by severity The alert email: two events reached your watch zones, with a link to all alerts
In the app, with an unread count in the header. By email, in one digest every two minutes at most.

A dashboard for your places

The dashboard: zones watched, unread alerts and events worldwide, the busiest zones, the latest alerts, the state of each data feed and the events of the past day by kind

Once signed in, the dashboard sums up your account: the zones with the most severe recent events, the latest alerts, whether each data feed is up to date, and what the planet looked like over the past day.

On any screen

The home page on a phone     The live map on a phone, with the globe above the list of events

How it works

flowchart LR
    subgraph feeds ["Open data feeds"]
        usgs["USGS<br/>earthquakes"]
        firms["NASA FIRMS<br/>fires from orbit"]
        gdacs["GDACS<br/>cyclones, floods,<br/>volcanoes, droughts"]
    end

    worker["Worker<br/>Node.js on Render"]
    db[("PostgreSQL + PostGIS<br/>on Neon")]
    web["Web app<br/>Next.js on Vercel"]
    smtp["SMTP<br/>alert emails"]
    push["Browser push services<br/>notifications"]
    browser(("Browser"))
    gibs["NASA GIBS<br/>satellite imagery"]
    tiles["OpenFreeMap<br/>vector tiles"]

    usgs & firms & gdacs -- "polled every 1 to 30 min" --> worker
    worker -- "upserts events,<br/>raises zone alerts" --> db
    worker -- "digests" --> smtp
    worker -- "notifications" --> push
    push --> browser
    web -- "events, zones, alerts" --> db
    browser --> web
    browser -- "basemap" --> tiles
    browser -- "imagery" --> gibs
Loading
  1. Ingestion. The worker polls each feed on its own interval and maps it to one event model: a kind, a severity, a location and a period of activity. Satellite fire detections, about 100,000 a day, are grouped into fires by cells of 0.25°.
  2. Alerts. In the same transaction that writes the events, a single PostGIS query matches them against every watch zone, on the surface of the Earth, and raises the alerts that pass each zone's threshold.
  3. Email and push. Every two minutes, the worker claims the alerts waiting for an email and sends each confirmed user one digest. Every minute, it pushes the new ones to the browsers that turned notifications on, through the Web Push protocol.
  4. Web. Pages are React Server Components reading the database. The map runs MapLibre in the browser, which also loads the imagery from NASA directly, so the server never proxies a tile.

The reasoning behind each choice is recorded in architecture decision records, such as modelling events as activity periods, raising alerts when events are written or grouping fire detections into grid cells.

Tech stack

Layer Technologies
Frontend Next.js React Tailwind CSS Motion Radix Lenis
Maps MapLibre OpenStreetMap NASA
Backend Node.js Better Auth Zod pino
Data PostgreSQL PostGIS Drizzle
Quality TypeScript Vitest ESLint Prettier GitHub Actions
Tooling pnpm Turborepo Docker commitlint
Hosting Vercel Render Neon

A few things worth knowing about how they fit together:

  • One TypeScript monorepo, with pnpm workspaces and Turborepo: two apps and two shared packages, type-checked and linted together.
  • Geospatial work happens in the database. Events and zones are PostGIS geographies, so "is this event within 250 km of that point" is one indexed query, measured on the Earth rather than on a flat map.
  • No map provider account. Vector tiles come from OpenFreeMap and imagery from NASA, both free and keyless.
  • Free to run. Vercel hosts the web app, Render the worker, kept awake by an uptime monitor, and Neon the database.

Data sources

Source What it provides Polled
USGS Earthquakes worldwide Every minute
NASA FIRMS Fires detected by the VIIRS instruments of NOAA-20 and NOAA-21 Every 30 minutes
GDACS Tropical cyclones, floods, volcanoes and droughts, with their impact Every 10 minutes
NASA GIBS Satellite imagery: true colour, live clouds and city lights By the browser
OpenFreeMap Vector tiles built from OpenStreetMap By the browser

Data may be delayed or incomplete. HazardWatch is not meant for emergency response.

Getting started

You need Node.js 22.12 or later, pnpm 10 and Docker.

pnpm install
cp .env.example .env    # then set BETTER_AUTH_SECRET
docker compose up -d    # PostgreSQL with PostGIS on port 5433, Mailpit on 1025
pnpm db:migrate
pnpm dev                # web app and worker

The web app runs on http://localhost:3000. Generate a secret with openssl rand -base64 32. Emails sent in development never leave your machine: Mailpit catches them and shows them on http://localhost:8025.

Command What it does
pnpm dev Starts the web app and the worker in watch mode
pnpm test Runs the unit tests
pnpm test:integration Runs the tests against a real PostGIS database
pnpm lint Lints every workspace
pnpm typecheck Type-checks every workspace
pnpm build Builds everything, as the CI does

Project structure

apps/
  web/          Next.js app: pages, authentication, server actions, the globe
  worker/       Polls the hazard feeds, raises alerts and sends their emails
packages/
  db/           Drizzle schema, PostGIS queries and migrations
  email/        Email templates and sending
docs/
  architecture.md
  deployment.md
  adr/          Architecture decision records

Documentation

  • Architecture: the moving parts, how data flows between them and the principles behind the code.
  • Deployment: setting up Neon, Vercel and Render, all on free tiers.
  • Decision records: why PostGIS, Better Auth, a dedicated worker, MapLibre, the globe and more.
  • Contributing: workflow, branch names and commit conventions.

Credits

Designed & Built by Hiratra Danarson.

Events from USGS, NASA FIRMS and GDACS. Imagery from NASA's Global Imagery Browse Services (GIBS), part of NASA's Earth Science Data and Information System (ESDIS). Maps from OpenFreeMap and OpenStreetMap contributors. Land outlines from Natural Earth.

License

MIT

About

Real-time natural hazard monitoring on a live 3D globe: earthquakes, wildfires, cyclones and floods from open data, with watch zones and alerts.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages