Realtime, by design
Every dashboard surface — KPIs, pipeline bar, needs-attention queue, live feed — subscribes to Postgres CDC. Aggregate queries debounce at 500ms; RLS scopes the channel automatically.
postgres_changes · cdcA real-time, append-only operations platform for small-to-mid logistics teams. Every parcel, every scan, every signoff — on the record. Built around a six-step Golden Path and a three-fence authorization model that holds even when one layer fails.
Six handshakes from pickup to doorstep. Every feature has to compose with this without breaking it — the invariant the entire system defends.
What ships in Phase 1 — minus the marketing. Real subsystems backed by production code.
Every dashboard surface — KPIs, pipeline bar, needs-attention queue, live feed — subscribes to Postgres CDC. Aggregate queries debounce at 500ms; RLS scopes the channel automatically.
postgres_changes · cdcUploaders capture a printed slip with their phone camera; on-device OCR extracts customer + address fields. No data leaves the handset until the parcel is committed.
expo-camera · ml-kitESC/POS thermal printers receive the barcode the moment a parcel is created — even offline. The barcode encodes the client UUID so labels stay valid through queue replay.
esc/pos · bt 5300The Rider's terminal action is the scan; only the Uploader who created the parcel can mark it complete. This is the heart of the handshake — and it is hard-enforced.
point-to-point notifyPostgres RLS, a state-machine trigger, and nine SECURITY DEFINER RPCs. Bypass any one and the other two still hold. Every override is logged in audit_events.
rls · trigger · rpcparcel_events is the source of truth; lifecycle columns on parcels are denormalized via trigger. Filters and sorts are backed by covering indexes — never JOIN events.
v_audit_log_combinedThe authorization model isn't a wrapper — it's three layers, each authoritative on its own. Defense in depth, expressed in SQL.
parcels_read scopes visibility to the creator, the assignee, and admin/super_admin/verifier roles. parcels_no_update and parcels_no_delete are hard-deny — every mutation is forced through an RPC.
A BEFORE INSERT on parcel_events validates the (from_status, event_kind, actor_role) tuple. AFTER INSERT updates denormalized lifecycle columns and fans out targeted notifications. Invalid transitions raise P0001.
Nine SECURITY DEFINER functions — parcel_create, _assign, _reassign, _scan, _fail, _complete, _reopen, notification_mark_read, dashboard_kpis_today. Each starts with a caller-identity check.
Each role sees a different surface, all backed by the same row in parcel_events. RLS scopes what's visible; RPCs scope what's possible.
Captures parcels via OCR, prints thermal labels, assigns to a rider, verifies the scan, and signs off completion.
Sees parcels assigned today, scans the barcode at destination. The scan is the rider's terminal action — never the closing one.
Watches the full lifecycle, manages shops + riders + roles, resolves exceptions, generates manifests. Overrides are logged.
Read-only oversight. Can view every parcel and audit row but cannot mutate state. Optional governance role.
Sign in to the SDLS admin web. Authentication is Supabase SSR with email + password — middleware refreshes the session on every request, riders are blocked, and your role determines what surfaces you see.