← Back to brief

project pwa cloud independence roadmap

memory · project_pwa_cloud_independence_roadmap.md

Goal

Make all PWA data sources truly cloud-independent so the dashboard stays live with fresh data even when the Mac is off or sleeping.

Why: Joseph travels and the Mac goes to sleep. Currently Track and KeyData metrics go stale because extraction runs on the Mac.

Current state (2026-05-10)

SourceMac needed?Notes
SmartLead❌ NoCF Worker (skyrun-sync) fetches from SL API directly
BeenVerified❌ NoHealth = expiry date math; enrichment still needs Chrome
KeyData✅ Yesextract_keydata_metrics.py uses Playwright on Mac → pushes to KV
Track✅ Yesextract_track_metrics.py scrapes dashboard on Mac → pushes to KV
Track auto-relogin is wired (2026-05-10) so session recovers within 5 min of Mac waking — but data still goes stale while Mac is off.

Work to do

Track — CF Worker form login + scrape

The original plan (reference_session_keep_alive.md) was a CF Worker doing form login + HTML scrape.

Implementation path:
1. Add a new route in skyrun-sync worker (or a dedicated track-sync worker)
2. Worker does: GET / → extract security CSRF token → POST login with Keychain creds → follow redirect → scrape dashboard HTML
3. Problem: Track credentials need to be in CF Secrets (not Keychain). Store via wrangler secret put TRACK_USERNAME and TRACK_PASSWORD.
4. Worker writes scraped metrics to SKYRUN_DATA KV key track_metrics
5. Trigger: CF Cron Trigger (0 /1 = hourly, or /15 * = every 15 min)
6. _worker.js already reads track_metrics from KV — no PWA changes needed

Key constraint: Track's form POST requires a security CSRF token from the login page GET. CF Workers can do this (fetch the GET, parse the token, POST). Tested programmatically in Python — works.

KeyData — CF Worker with stored session token OR API key

Two options:

Option A (simpler): Store session token in CF KV / Secrets, fetch via authenticated API calls

Option B (proper): KeyData API key

How to apply

When Joseph is ready post-usage-reset, start with Track CF Worker (most impactful — Track is the primary ops data source). KeyData Option B is the ideal but requires operator action to get API key.

Preconditions: