Accidents SG
An interactive map of Singapore's LTA-reported traffic accidents, with time filters, historical reports, and clear indicators of location precision and data coverage.
Singapore's traffic incident feed provides a snapshot of what is happening on the roads. Accidents SG collects those reports over time and combines them with historical archives, turning individual updates into an interactive map of LTA-reported accidents.
What It Does
Explore accident locations on a map, filter points by year and time of day, or browse individual reports in a list. A separate road heatmap shows accumulated accident counts across all available years, rebuilt nightly.
Blue points mark coordinates supplied by the source. Amber points indicate estimated locations derived from road names, landmarks, or descriptions, so older reports remain useful while their uncertainty stays visible.
Tech Stack
The app uses Next.js, TypeScript, and Mantine, deployed on Vercel. MapLibre GL JS renders the map, backed by Neon Postgres + PostGIS for spatial data and Drizzle ORM for typed queries. QStash schedules collection every five minutes and the nightly heatmap rebuild.
From Reports to Events
The collector validates the LTA DataMall feed, preserves raw snapshots, and normalizes incoming messages. Repeated observations are deduplicated, then reconciled into accident events so a report appearing across several polls does not become several accidents. Database locks and unique constraints make scheduled retries safe.
One deliberate decision: coordinates are excluded from the observation's deduplication key. If the source changes a location while keeping the same message and report time, that change can be audited without treating it as a new report.
Making Coverage Visible
A quiet feed and a failed collection mean different things. The pipeline records successful empty polls, upstream errors, timeouts, and parsing failures separately, measuring coverage against expected five-minute slots.
Historical reports often identify only a road, which makes whole-road aggregation a useful common basis for the heatmap. The map represents accidents published by LTA; its counts reflect both reported incidents and the coverage of the collected sources.