Skip to content

asafw/quakelog2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

216 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuakeLog 2

iOS CI Android CI Server CI Website CI Docs Sync

A citizen seismograph network. Turns iPhones and Android phones into distributed seismographs using the STA/LTA trigger algorithm. Detected events appear in real time on the live map →.

Live Map

quakelog2.vercel.app — a public, real-time map of all detected seismic events. No login required.

Map overview (24 h window) Event detail panel
QuakeLog 2 live seismic map Event detail panel
Recent events feed
Heatmap density view
Recent events feed open Heatmap density view
7-day window
Network health panel
7-day timeline window Network health panel
  • Events appear as colored circles; size scales with peak acceleration
  • Color encodes confidence: amber = low, orange = medium, red = high
  • Click any circle to open a detail panel: peak acceleration, duration, confidence, corroborated status, location, and raw waveform chart
  • Waveform chart — SVG plot of the x+y+z combined signal; pre-event (grey) vs event (orange) with red trigger marker
  • Timeline slider — filter events by time window: 1 h / 6 h / 24 h / 3 d / 7 d; no refetch
  • Recent events feed — collapsible list of events sorted by recency; click any row to open the detail panel
  • Heatmap layer — toggle density view to visualise clusters across the globe
  • Export CSV — download all currently visible events as a CSV file
  • Data refreshes every 30 seconds from the public GET /functions/v1/events-recent endpoint
  • Built with Next.js 15 + MapLibre GL JS + OpenFreeMap tiles (no API key or payment required)

Screenshots

iOS

Dashboard Active About

Enrollment:

Not Connected Connected Fixed Device

Advanced:

Fixed + Structure Developer Event Detail

Home Screen Widgets:

Small (2×2) Medium (4×2)

Android

Dashboard Active About

Enrollment:

Not Connected Connected Fixed Device

Advanced:

Fixed + Structure Developer Event Detail

Home Screen Widgets:

Small (2×2) Wide

Documentation

Document Audience Platform
Product Vision & Strategy All All platforms
Architecture & Flow Diagrams Developers All platforms
iOS User Manual End users iOS
iOS Technical Reference Developers iOS
Android User Manual End users Android
Android Technical Reference Developers Android
Server Technical Reference Developers Server

Repository Structure

quakelog2/
├── ios/          ← Swift / SwiftUI app (iOS 17+)
├── android/      ← Kotlin / Jetpack Compose app (Android 8+)
├── server/       ← Backend API (Supabase Edge Functions / Deno / TypeScript)
├── website/      ← Next.js 15 live map (quakelog2.vercel.app)
├── docs/         ← User manuals and technical references
├── shared/       ← JSON schemas and API contracts
├── scripts/      ← Developer utility scripts
└── .github/
    └── workflows/
        ├── ios.yml          ← Build + unit test on every PR
        ├── android.yml      ← Build + unit test on every PR
        ├── server.yml       ← Deno unit tests on every PR
        └── docs-sync.yml   ← Enforces CONTEXT.md + instructions.md updated with every code push

iOS App

Swift + SwiftUI. Requires iOS 17+. STA/LTA engine, all four screens, sensor pipeline, frequency filter, push notifications, and background sensor service.

Quick start:

cd ios
xcodegen generate
open QuakeLog2.xcodeproj

Run unit tests:

xcodebuild \
  -project QuakeLog2.xcodeproj \
  -scheme QuakeLog2 \
  -only-testing:QuakeLog2Tests \
  -destination 'platform=iOS Simulator,OS=latest,name=iPhone 16' \
  test

Android App

Kotlin + Jetpack Compose. Requires Android 8.0+ (API 26). Full feature parity with iOS: STA/LTA engine, all four screens, sensor pipeline, and upload support.

Quick start:

cd android
./gradlew assembleDebug
# APK → app/build/outputs/apk/debug/app-debug.apk

Run unit tests:

./gradlew testDebugUnitTest
# Report → app/build/reports/tests/testDebugUnitTest/index.html

Requires JDK 21+ and ANDROID_HOME pointing to the Android SDK.

Backend

Deno + TypeScript on Supabase Edge Functions, backed by PostgreSQL. Handles device enrollment, event ingestion with deduplication and auto-corroboration, raw waveform storage, liveness heartbeats, and APNs/FCM push fan-out triggered by a Postgres DB trigger.

Endpoint Auth Purpose
POST /functions/v1/enroll None Register a device; returns device_id + access_token
POST /functions/v1/events Bearer <access_token> Batch upload seismic events; deduplicates ±30 s; auto-corroborates; returns event_ids[]
POST /functions/v1/heartbeat Bearer <access_token> Periodic liveness ping; updates last_seen_at + GPS (mobile)
POST /functions/v1/waveforms Bearer <access_token> Upload raw accelerometer samples (pre-event + event); best-effort; idempotent
POST /functions/v1/notify Internal (DB trigger) Fan-out APNs/FCM push to nearby devices on new event insert
GET /functions/v1/events-recent None Public read: recent events with coarsened lat/lng for live map

Both apps auto-enroll on first launch using the device's stable UUID as the identity key. After enrollment the access token is stored locally and attached to every event upload.

Fixed-installation devices (seismometers mounted in buildings, bridges, etc.) set device_type: "fixed" and an optional structure_type (building | bridge | dam | other) during enrollment. All devices report GPS coordinates per event.

Run server tests:

cd server
make test

See docs/server/TECHNICAL.md for the full architecture reference.

CI/CD

GitHub Actions pipelines run on every PR and push to main. Each platform is independently scoped via paths filters — only the relevant pipeline runs when files in that platform's folder change.

Platform Status
iOS iOS CI
Android Android CI
Server Server CI
Website Website CI
Docs sync Docs Sync

Every push to main also triggers a Vercel production deployment; every PR gets a preview deployment.

Algorithm

STA/LTA (Short-Term Average / Long-Term Average) seismic trigger.

  • STA = absolute acceleration of the latest sample (|x|+|y|+|z|)
  • LTA = mean absolute acceleration over the last 120 samples (1 min @ 2 Hz)
  • Trigger: STA/LTA ≥ 1.03
  • De-trigger: STA/LTA ≤ 0.995
  • Lift detection: gyroscope > 0.9 rad/s → discard (phone picked up)

Reference: "Understanding & Setting STA/LTA Trigger Algorithm Parameters for the K2", Dr. Amadej Trnkoczy, Kinemetrics Application Note #41 (1998).

About

Citizen seismograph network app - turns phones into distributed seismographs using the STA/LTA trigger algorithm

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors