# earthquake-vibecoding/maplibre-esm-app architecture

> Architecture diagram of the GitHub repository earthquake-vibecoding/maplibre-esm-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/earthquake-vibecoding/maplibre-esm-app
- Repository: https://github.com/earthquake-vibecoding/maplibre-esm-app

## Overview

eqm is a real-time Japanese earthquake and EEW monitor. Its principal workflow receives KMONI observation frames on the server, detects and records shaking, then pushes events over SSE for the Svelte renderer to display on a map and use for alerts. Separate relays deliver P2PQuake and Wolfx EEW data; the product also supports history, replay after absence, Discord reports, localization, and Electron. Edges follow the README and shown imports/calls; some unsampled subsystem wiring is intentionally omitted.

Main entry points: [`server/detect-runner.mjs`](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/detect-runner.mjs) (Detection runner), [`src/App.svelte`](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/App.svelte) (Svelte application), [`server/push.mjs`](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/push.mjs) (SSE push), [`server/api.mjs`](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/api.mjs) (API and SSE)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Server ingestion"]
  node_kmoni["KMONI frames<br/>[kmoni-poll.mjs]"]
  node_buffer[("Frame buffer<br/>[frame-buffer.mjs]")]
  node_api["API and SSE<br/>[api.mjs]"]
  node_sse["SSE push<br/>[push.mjs]"]
end

subgraph group_detect["Detection and reporting"]
  node_detectrunner["Detection runner<br/>[detect-runner.mjs]"]
  node_detector["Shaking detector<br/>[detector.ts]"]
  node_webhook["Discord reports<br/>[webhook.mjs]"]
  node_history[("Detection history<br/>[history.mjs]")]
end

subgraph group_feeds["Earthquake feeds"]
  node_p2p["P2P relay<br/>[p2p-feed.mjs]"]
  node_eew["EEW relay<br/>[eew-feed.mjs]"]
end

subgraph group_renderer["Map and interface"]
  node_app["Svelte application<br/>[App.svelte]"]
  node_controller["App controller<br/>[app-controller.ts]"]
  node_map["Map controller<br/>[map-controller.ts]"]
  node_ticker["Animation ticker<br/>[ticker.ts]"]
  node_realtime["Frame display<br/>[realtime-img.ts]"]
  node_eewmask["EEW intensity mask<br/>[est-shindo.ts]"]
  node_i18n["Translations<br/>[i18n.ts]"]
  node_historyui["History drawer"]
end

subgraph group_alerts["Alerts and audio"]
  node_notifications["Browser notifications"]
  node_sound["Sound service<br/>[sound.ts]"]
end

node_user(("Monitor user"))
node_externalfeeds(("P2PQuake and Wolfx"))
node_discord(("Discord"))

node_kmoni -->|"supplies frames"| node_buffer
node_buffer -->|"provides frames"| node_detectrunner
node_detectrunner -.->|"runs detection"| node_detector
node_detectrunner -->|"reports events"| node_webhook
node_detectrunner -->|"records events"| node_history
node_detectrunner -->|"pushes events"| node_sse
node_api -->|"starts"| node_detectrunner
node_api -->|"starts"| node_p2p
node_api -->|"starts"| node_eew
node_webhook -->|"posts reports"| node_discord
node_externalfeeds -.->|"feeds data"| node_p2p
node_externalfeeds -.->|"feeds data"| node_eew
node_p2p -.->|"relays updates"| node_sse
node_eew -.->|"relays updates"| node_sse
node_sse -->|"streams updates"| node_app
node_user -->|"views monitor"| node_app
node_app -->|"initializes"| node_controller
node_controller -->|"updates map"| node_map
node_ticker -->|"reapplies frame"| node_realtime
node_ticker -.->|"updates mask"| node_eewmask
node_app -->|"renders"| node_historyui
node_historyui -->|"translates labels"| node_i18n
node_app -->|"uses alerts"| node_notifications
node_app -.->|"uses audio"| node_sound
node_notifications -->|"notifies"| node_user

click node_kmoni "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/kmoni-poll.mjs"
click node_buffer "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/frame-buffer.mjs"
click node_api "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/api.mjs"
click node_sse "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/push.mjs"
click node_detectrunner "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/detect-runner.mjs"
click node_detector "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/detect/detector.ts"
click node_webhook "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/webhook.mjs"
click node_history "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/history.mjs"
click node_p2p "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/p2p-feed.mjs"
click node_eew "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/eew-feed.mjs"
click node_app "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/App.svelte"
click node_controller "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/app-controller.ts"
click node_map "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/map/map-controller.ts"
click node_ticker "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/ticker.ts"
click node_realtime "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/detect/realtime-img.ts"
click node_eewmask "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/quake/est-shindo.ts"
click node_notifications "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/services/notification.svelte.ts"
click node_sound "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/services/sound.ts"
click node_i18n "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/i18n/i18n.ts"
click node_historyui "https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/components/HistoryDrawer.svelte"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_kmoni,node_buffer,node_api,node_sse,node_user toneBlue
class node_detectrunner,node_detector,node_webhook,node_history toneAmber
class node_p2p,node_eew toneMint
class node_app,node_controller,node_map,node_ticker,node_realtime,node_eewmask,node_i18n,node_historyui toneRose
class node_notifications,node_sound,node_externalfeeds,node_discord toneIndigo
```

## Components

### Server ingestion

- [KMONI frames](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/kmoni-poll.mjs): `server/kmoni-poll.mjs`
- [Frame buffer](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/frame-buffer.mjs): `server/frame-buffer.mjs`
- [API and SSE](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/api.mjs): `server/api.mjs`
- [SSE push](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/push.mjs): `server/push.mjs`

### Detection and reporting

- [Detection runner](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/detect-runner.mjs): `server/detect-runner.mjs`
- [Shaking detector](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/detect/detector.ts): `src/lib/detect/detector.ts`
- [Discord reports](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/webhook.mjs): `server/webhook.mjs`
- [Detection history](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/history.mjs): `server/history.mjs`

### Earthquake feeds

- [P2P relay](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/p2p-feed.mjs): `server/p2p-feed.mjs`
- [EEW relay](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/server/eew-feed.mjs): `server/eew-feed.mjs`

### Map and interface

- [Svelte application](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/App.svelte): `src/App.svelte`
- [App controller](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/app-controller.ts): `src/lib/app-controller.ts`
- [Map controller](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/map/map-controller.ts): `src/lib/map/map-controller.ts`
- [Animation ticker](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/ticker.ts): `src/lib/ticker.ts`
- [Frame display](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/detect/realtime-img.ts): `src/lib/detect/realtime-img.ts`
- [EEW intensity mask](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/quake/est-shindo.ts): `src/lib/quake/est-shindo.ts`
- [Translations](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/i18n/i18n.ts): `src/lib/i18n/i18n.ts`
- [History drawer](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/components/HistoryDrawer.svelte): `src/lib/components/HistoryDrawer.svelte`

### Alerts and audio

- [Browser notifications](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/services/notification.svelte.ts): `src/lib/services/notification.svelte.ts`
- [Sound service](https://github.com/earthquake-vibecoding/maplibre-esm-app/blob/main/src/lib/services/sound.ts): `src/lib/services/sound.ts`

### Other components

- **Monitor user**
- **P2PQuake and Wolfx**
- **Discord**

## Connections

- KMONI frames → Frame buffer: supplies frames (evidence: `server/frame-buffer.mjs`)
- Frame buffer → Detection runner: provides frames (evidence: `server/detect-runner.mjs`)
- Detection runner → Shaking detector: runs detection
- Detection runner → Discord reports: reports events (evidence: `server/detect-runner.mjs`)
- Detection runner → Detection history: records events (evidence: `server/detect-runner.mjs`)
- Detection runner → SSE push: pushes events (evidence: `server/detect-runner.mjs`)
- API and SSE → Detection runner: starts (evidence: `server/api.mjs`)
- API and SSE → P2P relay: starts (evidence: `server/api.mjs`)
- API and SSE → EEW relay: starts (evidence: `server/api.mjs`)
- Discord reports → Discord: posts reports (evidence: `server/webhook.mjs`)
- P2PQuake and Wolfx → P2P relay: feeds data
- P2PQuake and Wolfx → EEW relay: feeds data
- P2P relay → SSE push: relays updates
- EEW relay → SSE push: relays updates
- SSE push → Svelte application: streams updates
- Monitor user → Svelte application: views monitor
- Svelte application → App controller: initializes (evidence: `src/App.svelte`)
- App controller → Map controller: updates map (evidence: `src/lib/app-controller.ts`)
- Animation ticker → Frame display: reapplies frame (evidence: `src/lib/ticker.ts`)
- Animation ticker → EEW intensity mask: updates mask
- Svelte application → History drawer: renders (evidence: `src/App.svelte`)
- History drawer → Translations: translates labels (evidence: `src/lib/components/HistoryDrawer.svelte`)
- Svelte application → Browser notifications: uses alerts (evidence: `src/App.svelte`)
- Svelte application → Sound service: uses audio
- Browser notifications → Monitor user: notifies (evidence: `src/lib/services/notification.svelte.ts`)
