Skip to content
ModernPathPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Roadwatch

Finnish road weather map (MVP): MapLibre map with weather stations, road cameras, and forecast sections. The BFF polls Fintraffic Digitraffic by default and serves normalized GeoJSON to the SPA.

Prerequisites

  • Node.js 22 LTS (see engines in root package.json)
  • pnpm 10.30.1 (corepack enable recommended)

No API keys are required for fixture mode. Live upstream needs outbound HTTPS and a non-personal DIGITRAFFIC_USER header value.

Install

pnpm install

Dependencies are pinned in pnpm-lock.yaml.

Development

Run the Vite frontend and Fastify BFF together:

pnpm dev

Build the frontend once before using the BFF alone (pnpm build), or run pnpm dev so Vite and the BFF start together.

Service URL Notes
Frontend (Vite) http://127.0.0.1:5173 (next free port if busy) Binds 127.0.0.1; proxies /api and /health to the BFF
BFF http://127.0.0.1:3000 Health endpoints and API stubs

If the BFF is not on port 3000, set BFF_URL when starting Vite (e.g. BFF_URL=http://127.0.0.1:3099 pnpm --filter @roadwatch/frontend dev).

Forecast road colors use the validated mapping when intervals are current (see docs/forecast-severity-gate.md). The UI labels fixture vs live data using /api/status.

Production build and run

pnpm build
pnpm start

Open http://127.0.0.1:3000 — the BFF serves the built SPA. Client-side routes (e.g. /explore/finland) reload correctly. Unknown paths under /api return JSON 404, not the SPA.

Docker (single container)

docker build -t roadwatch:local .
docker run --rm -p 3000:3000 roadwatch:local

MVP assumes one replica (one polling owner in later sprints). Scaling out requires shared cache and a single upstream poller before increasing replicas.

Health endpoints

Endpoint Purpose Success response
GET /health/live Process liveness 200 { "status": "alive" }
GET /health/ready Can serve SPA and report app status 200 { "status": "ready", "services": { "application": "ok", "staticAssets": "ok" } }

Readiness returns 503 with staticAssets: "unavailable" if index.html is missing (e.g. before build). It does not depend on Fintraffic or other upstream feeds.

Verification

pnpm test          # Vitest: frontend components + server integration
pnpm typecheck     # TypeScript across packages
pnpm lint          # ESLint
pnpm build         # Vite + server compile
pnpm test:e2e      # Playwright smoke (fixtures upstream; frees port 3099 unless PLAYWRIGHT_REUSE_SERVER)
pnpm test:docker   # Build image and smoke-test health, SPA, and API 404

E2E and local pnpm start use live Digitraffic (HTTPS). Unit/integration tests under packages/server may set USE_UPSTREAM=fixtures.

Configuration

Variable Default Description
HOST 0.0.0.0 BFF bind address
PORT 3000 BFF port
STATIC_ROOT packages/frontend/dist Directory of built SPA assets
USE_UPSTREAM live (default) Set to fixtures only for offline tests (packages/server vitest)
UPSTREAM_BASE_URL https://tie.digitraffic.fi Digitraffic API host
DIGITRAFFIC_USER Roadwatch/dev 0.1 Non-personal Digitraffic-User header
FIXTURE_DIR server test fixtures path Upstream fixture JSON directory
Configuration is validated at startup (Zod). Secrets must not be committed.

Live contract check (opt-in, no CI)

After pnpm build:

node scripts/live-contract-check.mjs

Uses sanitized samples under packages/server/test/fixtures/upstream/live-contract/.

Project layout

  • packages/frontend — React + Vite + TypeScript SPA shell
  • packages/server — Fastify BFF, static hosting, health routes
  • specs/ — Feature specifications and acceptance criteria
  • docs/ — PRD, architecture, prototypes

Documentation

FMI rain radar

Enable Rain radar · FMI in the sidebar. The map shows observed precipitation intensity with source time/timezone, the past hour's five-minute frames, playback, latest and opacity controls. Images use FMI's current radar_finland_cappi_rate GeoTIFF Download Service; no API key is needed. Metadata refreshes every five minutes while enabled; delayed sources and failures are labeled. This is radar-estimated intensity (mm/h), not hourly accumulation or a forecast. Grey denotes missing coverage.

FMI receives normal browser IP/request information for a fixed Finland extent; precise user coordinates are not sent. FMI data: CC BY 4.0, provider palette displayed with adjusted transparency. See radar specification and FMI radar documentation.

Camera overlays include a view selector and 24h time-lapse button. Open history to play or scrub through available captures. Cameras typically update about every 10 minutes; the player shows each capture's time and does not imply live video. History availability varies by view.

Optional national maintenance/TMS, Oulu traffic/maintenance and aerial layers are under Explore more data, all off by default. Camera details resolve source-linked weather stations and readable view names. See open-data research and NLS configuration for provider availability, licensing and VITE_NLS_API_KEY setup. Aerial images are archival, not current weather.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages