D113 · GPS providers sit behind an adapter, and all of them feed one ingest in Postgres
Proposed · 2026-11-30 · zuki, in the CTO session on #466; it binds when this page's pull request is merged · Applies to M2 (GPS) and every later GPS provider
Decision: Every GPS vendor is a provider with its own adapter, and every adapter feeds one provider-neutral ingest function in Postgres. The adapter knows the vendor's transport and payload shape. The ingest knows devices, positions, duplicates and the stale rule. A provider's transport may be polling, a webhook or MQTT. Easygo offers only a REST API, so its adapter polls it from Postgres with pg_cron and pg_net, with the key in Supabase Vault. Adding a vendor, or a push transport for one, adds an adapter and changes neither the ingest nor the positions table.
- The ingest is the only writer of positions. It takes a provider and a normalized batch (device external id, recorded_at, latitude, longitude, speed and the element as it arrived). It stores positions for the car's active device only (R-VEH-23), skips a position it already has, and records each pull's outcome.
- The raw payload is kept (D32): each position keeps its element as it arrived, and each pull keeps its body and outcome.
- Polling is the Easygo transport, not the goal. Webhook and MQTT are the transports zuki prefers once a vendor offers them. MQTT needs a long-running subscriber outside Supabase, the apps/api trigger in the architecture page, so it waits for its own issue.
- Positions are kept 90 days, then deleted by a scheduled job. They become personal data once tied to a driver through a rental (D15). This sets OQ18's answer for GPS positions only.
- Stale after 15 minutes, an organization setting. The read side returns whether a car is stale, so the page holds no number (D3).
- The fleet monitor shows cars on a MapLibre map with OpenStreetMap tiles, needing no key. The current driver's name appears next to a car only for a user who also holds the driver-read permission at the car's pool (D15).
Why: zuki, 2026-11-30, answering the CTO session on #466: "for now 1 is fine, but do prepare for multiple vendor or gps device/service along with their own implementations, so we need some abstraction layer to isolate this. I also think calling with cron every minute is not ideal. I would want something like webhook, mqtt, or polling-only". Then: "Those 3 are the ideals, yet easygo just provide rest api so for now let's build on pg_cron and pg_net". zuki chose 90 days, 15 minutes as a setting, MapLibre with OSM, and the driver name only with driver read.
Consequences
Section titled “Consequences”- pg_cron, pg_net and Vault are turned on. zuki sets the Easygo key in Vault at L0, as
<EASYGO_API_KEY>. - Activating a backup device and linking devices are in #466.
- An MQTT or webhook provider gets its own issue when a vendor offers it.
- For now each provider belongs to one organization, so one Easygo account serves one organization (zuki, 2026-11-30; R-GPS-41).
- apps/api (Hono) comes with the first MQTT vendor, or when the Easygo pull outgrows pg_cron and pg_net, whichever is first (zuki, 2026-11-30). Until then GPS needs no server of its own.