How It
Works
Technical architecture of the live Wikipedia edit stream
Overview
The Knowledge Observatory displays every Wikipedia edit from around the world in real-time. When someone edits a Wikipedia article — in any language — the change appears on this page within seconds. There is no polling, no refreshing, and no backend server. The entire application is a single static HTML page running in your browser.
The data flows through three layers: Wikipedia's servers produce edit events → Wikimedia's Kafka cluster buffers and routes them → the EventStreams HTTP service streams them to your browser using a protocol called Server-Sent Events (SSE). Our JavaScript client connects to this stream, filters the events, and renders them as cards.
The Data Source: Wikimedia EventStreams
Wikimedia Foundation runs an open, public streaming API at stream.wikimedia.org. It exposes continuous streams of structured event data — every page creation, edit, deletion, move, and categorization across all 347 active Wikipedia language editions, plus Wikimedia Commons and Wikidata.
Stream endpoint
https://stream.wikimedia.org/v2/stream/recentchange
The service superseded RCStream (which used Socket.IO) and may eventually replace irc.wikimedia.org. It is internally backed by Apache Kafka — WMF operates multiple Kafka clusters producing hundreds of thousands of messages per second across all wikis.
The key architectural decision was to use HTTP SSE over WebSockets. The reasoning: EventStreams is read-only — it only pushes data from server to client. SSE uses standard HTTP (no protocol upgrade, no custom handshake), making it consumable from any HTTP client without specialized libraries. The internal Kafka-SSE bridge, called KafkaSSE, maps Kafka consumer groups to HTTP SSE connections using chunked transfer encoding.
WMF runs the service in an active/active multi-datacenter setup across two Kafka clusters. Every SSE message includes an id field containing Kafka topic, partition, and timestamp metadata for both clusters. The browser's EventSource API uses this id (via the Last-Event-ID header) to resume from the correct position after a disconnect — even across datacenter failovers.
Raw SSE wire format
event: message
id: [{"topic":"eqiad.mediawiki.recentchange","partition":0,"timestamp":1532031066001},
{"topic":"codfw.mediawiki.recentchange","partition":0,"offset":-1}]
data: {"title":"Albert Einstein","user":"Physicist99","type":"edit",...}
Wikimedia also injects canary events into every stream multiple times per hour — artificial test events that allow WMF engineers to distinguish between a broken stream (no data) and an idle stream (no real edits). Every consumer must discard events where meta.domain === 'canary'.
Server-Sent Events & the EventSource API
Server-Sent Events is a W3C-standardized server push technology, formalized as a Recommendation in 2015 and now part of the WHATWG HTML Living Standard. It uses the MIME type text/event-stream and a line-based protocol where messages are delimited by double newlines.
The browser's built-in EventSource interface handles connection management transparently:
- Auto-reconnection — on any disconnect, the browser automatically reconnects after a few seconds
- Resume tracking — the
Last-Event-IDHTTP header tells the server where to resume from - Connection lifecycle —
onopen,onmessage,onerrorhandlers - No polling overhead — a single persistent HTTP connection with chunked transfer encoding
WMF's HTTP infrastructure enforces a 15-minute connection timeout. This is transparent to users — EventSource automatically reconnects and resumes from the last received event ID. No data is lost.
Why SSE over WebSockets
| SSE | WebSocket |
|---|---|
| Standard HTTP, works with any proxy/CDN | Custom protocol upgrade, may break with proxies |
| Unidirectional (server → client only) | Bidirectional |
| Built-in auto-reconnect + resume | Manual reconnection logic required |
Browser-native EventSource API |
Browser-native WebSocket API |
| Text-only (UTF-8) | Text and binary |
The recentchange Event Schema
Each event follows the mediawiki/recentchange JSON schema (version 1.0.1). The stream also supports more specific schemas like revision-create, page-create, page-delete, and page-move — accessible as separate stream endpoints.
Key fields used by the Observatory
| Field | Type | Purpose |
|---|---|---|
| title | string | Full page name, displayed as link |
| type | string | edit / new / log / categorize / external |
| user | string | Username or IP address, with bot flag |
| bot | boolean | Whether the edit was made by a bot |
| minor | boolean | Whether marked as a minor edit |
| comment | string | Editor's summary of the change |
| wiki | string | Wiki identifier (e.g. enwiki, dewiki, commonswiki) |
| namespace | integer | Namespace ID (0=Article, 1=Talk, 2=User, etc.) |
| timestamp | integer | Unix timestamp of the edit |
| length | object | {old, new} — page size before & after the edit |
| revision | object | {old, new} — revision IDs for building diff links |
| server_url | string | Canonical wiki URL for building article links |
| server_name | string | Domain name (e.g. en.wikipedia.org) |
| meta.dt | string | ISO 8601 UTC datetime |
Client-Side Architecture
1. Connection & Lifecycle
On page load, new EventSource(url) opens a persistent HTTP connection to stream.wikimedia.org. The onopen handler updates the connection indicator from "CONNECTING" to "CONNECTED". The onerror handler switches it to "RECONNECTING" and the browser handles reconnection automatically.
A visibilitychange listener detects when the browser tab is hidden and returned — if the connection dropped while the tab was backgrounded, it reconnects. A beforeunload handler cleanly closes the EventSource on page navigation.
2. Filtering (Client-Side Only)
EventStreams does not support server-side filtering. Every event arrives at the client, and we filter in JavaScript. Every event goes through the matches() function which checks seven conditions:
- Canary event check — discard if
meta.domain === 'canary' - Wiki language — must match selected wiki (or "all")
- Namespace — must match selected namespace (or "all")
- Edit type — must match selected type (or "all")
- Minor edits — filter out if toggle is off
- Bot edits — filter out if toggle is off
- Anonymous editors — filter out if toggle is off (detects IP addresses via regex)
- Tiny edits — filter out if |new − old| < 10 bytes and toggle is off
3. Throttling
During peak activity, hundreds of edits can arrive per second. A render throttle (80ms) prevents the DOM from being overwhelmed. If a new event arrives within 80ms of the last render, it is stored as a single "pending" event. A flush timer (every 100ms) empties the pending slot. At most one pending event is held — any newer event overwrites it. This means the feed shows at most ~12 cards per second, regardless of the underlying event rate.
4. DOM Management
Each event creates a new <div> element via document.createElement, populated with the event data as innerHTML strings. The card is prepended to the feed container. When the feed exceeds 50 cards, the oldest card is removed via lastElementChild.remove(). This is simple create-and-discard — no virtual DOM, no object pooling. The browser garbage collector handles cleanup.
Time-ago labels ("3s ago", "2m ago") are updated every 2 seconds by a setInterval that queries the feed for all [data-ts] elements and recomputes the elapsed time from the stored ISO timestamp.
5. Audio Synthesis (Web Audio API)
The typewriter tick sound is synthesized entirely in the browser — no audio files are loaded. The Web Audio API generates a white noise burst (25ms buffer) routed through a bandpass filter (2.6–3.6 kHz, randomized per tick) with a fast gain envelope (attack 2ms, decay to silence by 28ms). The AudioContext is created lazily on the first user interaction or first event, respecting browser autoplay policies.
Audio signal chain
WhiteNoiseBuffer → BiquadFilterNode (bandpass, 2.6–3.6kHz) → GainNode (envelope) → AudioContext.destination
6. Stats Computation
Edits-per-minute is computed using a rolling 60-second window. Every event timestamp is pushed onto an array. The EPM counter is the count of timestamps that are less than 60 seconds old. The session total is a simple incrementing integer.
7. Language Detection
On first load, the page reads navigator.language (e.g. "de-DE") and extracts the ISO 639-1 language code ("de"). A static lookup table maps 37 language codes to wiki identifiers ("de" → "dewiki"). If the user's language is not in the table, it defaults to enwiki. The matching wiki is pre-selected in the dropdown.
The Tech Stack
| Layer | Technology |
|---|---|
| Hosting | PageWeave (static HTML, Hetzner DE) |
| CSS framework | Tailwind CSS v4 + daisyUI v5 (custom dark theme) |
| JavaScript | Vanilla ES5 (zero dependencies, zero build step) |
| Data transport | Browser-native EventSource API (WHATWG standard) |
| Data source | Wikimedia EventStreams → Kafka → MediaWiki RecentChanges |
| Audio | Web Audio API (white noise → bandpass filter synthesis) |
| Fonts | DM Serif Display (headings) + JetBrains Mono (data) |
| Analytics | PageWeave server-side (no cookies, no JS trackers) |
Sources & References
- wikitech.wikimedia.org — EventStreams HTTP Service Official WMF technical documentation
- mediawiki.org — Manual:RCFeed RecentChanges event schema reference
- en.wikipedia.org — Server-Sent Events SSE protocol specification and history
- MDN — EventSource API Browser API reference
- github.com/wikimedia/KafkaSSE Source code of the Kafka-to-SSE bridge library
- Apache Kafka Distributed event streaming platform backing EventStreams