Where the numbers come from.
Manage the connections that power this dashboard. Sync jobs run hourly via Vercel Cron; trigger them manually from API Status.
Data Flow
┌─────────────────────────────────────────────────────────┐
│ SOURCES │
│ │
│ Google Ads ─┐ │
│ ├──→ SyncWith ──→ Google Sheet (Ad Spend) │
│ Meta Ads ──┘ │ │
│ │ │
│ NWS Sales Sheet ──────────────────────┤ │
│ (Sold Data tab) │ │
└─────────────────────────────────────────┼────────────────┘
▼
┌─────────────────────────────────────────────────────────┐
│ Vercel Cron Jobs (hourly) │
│ /api/sync/sheet — sales sheet │
│ /api/sync/google-ads-sheet — Google via SyncWith │
│ /api/sync/meta-sheet — Meta via SyncWith │
└────────────────────┬────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────┐
│ Supabase (nws_* tables) │
│ nws_campaigns nws_leads │
│ nws_ad_spend_daily nws_sync_log │
└────────────────────┬────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────┐
│ Dashboard (Next.js Server Components) │
│ Reads only via SQL — no direct API calls │
└─────────────────────────────────────────────────────────┘
Connected Sources
Supabase
LiveBackend databaseStores all synced data. Cron jobs write here. Dashboard reads from here. Tables prefixed nws_*.
Sales Sheet — Closed Deals
LiveGoogle Sheets API (service account)NWS's 'Sold Data' tab. Closed deals, sale value, cash collected, UTM attribution. Read hourly.
Google Ads — Daily Spend
LiveSyncWith → Google Sheet → SupabaseSyncWith pulls Google Ads campaign data into a Google Sheet hourly. The dashboard reads that sheet via the same service account as Sales. No Developer Token or MCC needed.
Meta Ads — Daily Spend
LiveMeta Marketing API (direct)Pulls campaign insights (spend, impressions, clicks, lead conversions) directly from the Meta Marketing API using a system-user token. Synced hourly.
Sync Schedule
0 * * * *5 * * * *10 * * * *Required Environment Variables
Live in D:\AdSpendDashboard\.env.local (local) and Vercel project settings (production). Never commit secrets to git.
NEXT_PUBLIC_SUPABASE_URLsetNEXT_PUBLIC_SUPABASE_ANON_KEYsetSUPABASE_SERVICE_ROLE_KEYsetGOOGLE_SERVICE_ACCOUNT_PATHunsetLEADS_SHEET_IDsetLEADS_SHEET_RANGEsetGOOGLE_SERVICE_ACCOUNT_PATHunsetMETA_ACCESS_TOKENsetMETA_AD_ACCOUNT_IDset