Platform + SDK
A developer-first location event platform. A React Native SDK detects geofence enter and exit events on-device. A Firebase backend authenticates, stores and processes them. An admin portal shows them live, and they can trigger signed webhooks or in-app campaigns.
01Context
Built and shipped on my own as a monorepo with five parts: an admin portal, a React Native SDK, a Cloud Functions backend, shared types, and an Expo playground app. The SDK is published on npm as @damn-coding/geopulse-react-native, and the portal is live.
02Problem
Adding geofence-triggered behaviour to a mobile app means building the detection, event pipeline, retries, admin tooling and delivery logic yourself. Teams also get no clear view of why an event failed to trigger anything.
03Approach
Make the pipeline one focused path: device → ingestion → event store → rules/webhooks or campaigns → back to the device. An admin defines locations and circular geofences. The SDK detects crossings. Every event's outcome, success or failure and the reason, is recorded and visible.
04Frontend
Built the admin portal in Next.js (App Router) with Tailwind and shadcn-style components. It covers projects, Mapbox-based location and geofence editing, rules, webhooks and a campaign/experience editor with live preview. Events update through Firestore onSnapshot, so the live feed never needs a refresh.
05Backend & SDK
Wrote the Cloud Functions for event ingestion and config sync. The SDK authenticates with an app-scoped SDK key. Payloads are validated with Zod, and the server re-derives project and geofence ownership instead of trusting the client. Webhooks are HMAC-SHA256 signed and retried with exponential backoff.
06Data
Firestore holds an organization → project → application hierarchy, plus locations, geofences, events, campaign deliveries and webhook deliveries. Event IDs are generated on the client and used as document IDs with .create(), so retries are idempotent. Data-retention and export controls are built in.
07Challenges
Reliable delivery from an unreliable device. An event might fire offline, get retried, or arrive twice. Detection also had to avoid re-firing "enter" while a user stays inside a geofence.
08Decisions
Geofence detection runs entirely on-device, using haversine distance and a state machine. The backend is only contacted at init and on a real transition. Experiences reach the device by polling over the SDK's existing connection, so there's no FCM/APNs dependency. The SDK has no Firebase dependency, and only Cloud Functions ever write events.
Layer 01 / 4
React Native SDK
Detects enter and exit on-device with a state machine, queues events offline, and polls for experiences.
Key features
- On-device geofence detection
- Offline event queue with retry
- Live event feed
- Rules and signed webhooks
- Campaigns and in-app experiences
- Operations dashboard with failure tracking
- Published npm SDK
- Emulator-based integration tests
Result
Built and shipped the full pipeline end to end: SDK on npm, a live admin portal, and documentation with one doc per subsystem. Event processing is observable, with a failure category, reason and correlation ID on every failed event. Unit tests and emulator-based integration tests cover the SDK, the backend and tenant isolation.
What I'd improve
Use the OS-level native geofencing APIs for better background and battery behaviour. Replace polling with push delivery for experiences. Add polygon geofences.
Next dossier · 02
MAGE