Geo Tracking - Specs

Architecture

Components, responsibilities, and data flows between the application, native module, Cloudflare, and dashboard.

Geo Tracking keeps position capture and queueing in native code. React Native provides controls and diagnostics; Cloudflare persists incoming data and feeds the operator dashboard.

Component map

Expo / React Native application
  ├─ Tracking screen → enrollment, permissions, start/stop, diagnostics
  ├─ Route simulation → provider:test events
  └─ GeoMonitoring Expo module
       ├─ iOS: Core Location → SQLite → HTTP
       └─ Android: Fused Location + foreground service → SQLite → HTTP
                                  │
                                  ▼
Cloudflare Worker geo-tracking-lab
  ├─ request authentication and validation
  ├─ DeviceRegistry → installation catalog and enrollment
  ├─ TrackingDevice per deviceId → SQLite, configuration, and WebSocket
  ├─ R2 → APK and checksum downloads
  └─ static files → dashboard, Leaflet, and styles
                                  │
                                  ▼
Web dashboard → HTTP catalog + HTTP history + per-device WebSocket

Geo Tracking - Specs → separate Worker, static documentation only

Directories and responsibilities

DirectoryResponsibility
geo-demo/src/app/Application routes and interface.
geo-demo/src/features/tracking/Enrollment, validation, action coordination, state, and simulation.
geo-demo/modules/geo-monitoring/Expo bridge and native Swift/Kotlin implementations.
geo-demo/src/features/geo-monitoring/Model, geometry, and support for the polygon demo.
tracking-server/src/Worker, authentication, registry, storage, and API validation.
tracking-server/public/Web dashboard and map assets.
scripts/Failure proxy and Android field-test build.
.maestro/Android interface automation.
docs/Contracts, historical plans, and validation reports.
specs/This site: MDX, navigation, search, build, and deployment configuration.

From enrollment to the first point

  1. The app checks the existing native connection. An installation that is already configured retains its identity.
  2. For a new installation, it generates a random key and persists it with SecureStore before requesting enrollment.
  3. The API derives the installation's identity and credential. The persisted key allows an interrupted request to be retried without creating another device.
  4. The native module receives the configuration. Enrollment does not start tracking.
  5. The user taps Start, grants permissions, and the collector records the local session.
  6. The native sample passes validation, receives an identifier, and is written to SQLite.
  7. The transport sends pending events and handles acknowledgments by eventId.
  8. The Durable Object persists new events and publishes updates to connected dashboards.

Authentication, geolocation, and queue and synchronization explain each boundary.

Local, desired, and observed state

StateOwnerMeaning
Local sessionApplication/native moduleThe user requested tracking to start or stop on this device.
Remote configurationTrackingDeviceThe server requests specific enabled, distance, and interval settings.
Applied configurationNative moduleLatest version retrieved and accepted by the device.
Latest positionPer-device databaseLatest known capture by source, with no guarantee of current connectivity.
Dashboard connectionBrowser/WebSocketChannel between the browser and server, independent of the phone's network.

The operator changes the desired configuration in the dashboard. The app retrieves it through HTTP queries and upload responses. The local stop action remains the user's decision; a dashboard should not be interpreted as authorization to collect data.

Persistence at each boundary

On the phone, route positions are stored in SQLite; configuration and credentials have different implementations on each platform. On the server, each TrackingDevice uses Durable Object SQLite storage. DeviceRegistry maintains the catalog and enrollment controls. This backend has no D1 database.

The R2 bucket contains downloadable Android artifacts, not GPS history. The Geo Tracking - Specs Worker also receives no positions, tokens, or bindings to those databases: it publishes its static build output.

Two geolocation models

Route tracking collects positions during movement and sends them through real HTTP requests. The polygon monitor creates proximity circles and classifies each position against the actual geometry. Its demo states and events are not interchangeable with TrackingLocation.

The earlier implementation remains in the code and tests, but the current interface focuses on Tracking. See polygons for its separate contract.

Repository sources

  • geo-demo/src/features/tracking/device-enrollment.ts and native-tracking.ts.
  • geo-demo/modules/geo-monitoring/ios/GeoTrackingService.swift.
  • geo-demo/modules/geo-monitoring/android/src/main/java/expo/modules/geomonitoring/TrackingEngine.kt.
  • tracking-server/src/index.ts, registry.ts, downloads.ts, and wrangler.jsonc.
  • specs/vite.config.ts, specs/src/lib/search.server.ts, and specs/wrangler.jsonc.

On this page