OCC System Schema

Every system, trigger, data source, and destination — at a glance.

Data Flow Overview

Triggers
📱 Customer visits portal link
📱 Customer taps SMS confirm link
🛒 WooCommerce order placed
🕐 Cron schedule (daily / weekly / monthly)
🖱️ Howard clicks in Command Center
🖱️ Howard approves email batch
Workers (Edge)
occ-portal
occ-sms-dispatch
occ-empty-confirm
occ-command-center
occ-ot-followup
occ-welcome-email
occ-holiday-notify
occ-wc-to-gd
occ-prepaid-renewal
occ-square-proxy
occ-square-daily
occ-referral-agent
occ-signup-page
occ-inbox-sorter
Data Stores
☁️ Cloudflare KV
57151d059c9a4866…
🗄️ Cloudflare D1
occ-customers (e1ab48e2)
🗄️ Cloudflare D1
referral tracker
🛒 WooCommerce (GoDaddy)
orders, products, coupons
🦍 GorillaDESK
customers, jobs, notes
⬛ Square
payments, refunds
Outbound Sends
📧 Brevo → Customer email
📧 Brevo → info@ (Howard + Jason)
📧 Brevo → howard@ (approvals/BCC)
💬 Brevo SMS → Customer
💬 Twilio SMS → Customer (fallback)
🛒 WC order created
🦍 GD customer created
🦍 GD note written
⬛ Square refund issued
End State
✅ Customer confirmed cans out
👍 Customer rescheduled cleaning
📋 Customer in GD, ready to schedule
🔄 OT customer converted to recurring
💳 Refund processed
📊 Howard sees daily/weekly reports
🗓️ Jason sees holiday schedule alerts
🔔 Prepaid renewals queued and sent
Filter:
Master System Schema
System Type Trigger Reads From Writes / Sends To Auth / Token Status
occ-portal
Customer Portal
Worker Customer visits /?id=GD_ID
Customer submits form via POST /request
GorillaDESK: customer info, next job, notes (credit count)
KV: nothing on read
Brevo → info@ (request email)
Brevo → info@ (limit alert / seasonal flag)
GD: note written on every action
BREVO_KEY env Live Manual link
occ-sms-dispatch
Day-of SMS Sender
Worker Auto Cron 0 12 * * 1-5 (7am ET M–F)
Manual: ?action=send&token=
D1 occ-customers: ZIPs + phones for today's route
KV: check sms_sent:DATE:ID (skip if already sent)
LU_SCHEDULE hardcoded in worker
Brevo SMS → customer (or Twilio fallback)
KV: write sms_sent:DATE:ID (48h TTL)
TOKEN_SECRET, BREVO_SMS_KEY, TWILIO_*
Auth: occ-sms-2026
Pending SMS Built, needs phone # approval
occ-empty-confirm
Tap-to-Confirm Page
Worker Customer taps link from SMS
GET /?t=TOKEN
POST /confirm
GorillaDESK: customer name + address (?include=locations)
KV: check if already confirmed
KV: write empty:DATE:ID{status, confirmed_at} (48h TTL) TOKEN_SECRET (shared with occ-sms-dispatch) Live Pending SMS
occ-signup-page
Personalized Plan Signup
Worker Customer clicks link from OT email
GET /?email=&first=&cans=&touch=
POST /signup · GET /book-onetime
KV: pricing_{email} for discounted rates
URL params: customer info pre-loaded
WooCommerce: create order (POST, not PUT)
Brevo: customer confirmation email + Howard notification
KV: converted_from_ot_{email}, ot_repeat_{email}
No auth (public) · WC keys hardcoded Live
occ-ot-followup
OT Conversion Sequence
Worker Auto Cron 0 9 * * * (daily 9am UTC) GorillaDESK: completed OT jobs (day 3, 21, 86 lookback)
KV: dedup keys per job
Brevo: 3-email drip to customer (BCC howard@)
KV: ot_followup_{jobId}, ot_followup2_, ot_followup3_
BREVO_KEY env · Manual: ?trigger=1&token= Live Automated
occ-welcome-email
New Customer Welcome
Worker Auto Cron (checks GD jobs created in last 2 hrs)
Manual: ?trigger=1&token=
GorillaDESK: new scheduled jobs (M/BM/Q/Prepaid)
GorillaDESK: customer + location note (garbage day)
KV: pricing_{email} · KV: welcome_{id} dedup
Brevo: welcome email to customer (BCC howard@)
KV: write welcome_{customerId} (90d TTL)
BREVO_KEY env Live Automated
occ-holiday-notify
Holiday Schedule Alerts
Worker Auto 3 crons:
0 12 1 * * → monthly overview (1st)
0 12 22 * * → 8-day reminder (22nd)
0 12 * * * → daily 7-day customer check
Holiday definitions hardcoded in worker
KV: hcust_{hauler}_{dow} (customer lists by hauler+day)
KV: dedup keys per month
Brevo → info@ (1st and 22nd internal alerts)
Brevo → howard@ (7-day approval request)
Brevo → customers (after Howard approves)
KV: pending_holiday_{batchId}, holiday_sent_{date}
BREVO_KEY, SECRET_TOKEN env Live Automated
occ-prepaid-renewal
Prepaid Renewal Notices
Worker Auto Cron 0 14 * * 1 (Monday 9am ET)
Manual: ?scan=1&token=occ-renewal-2026
GorillaDESK: live job count per prepaid customer
56 customers hardcoded with GD IDs
KV: renewal_sent_{gd_acct} dedup (90d)
Brevo → howard@ (approval email with batch table)
After approval: Brevo → customers (renewal notice, BCC howard@)
KV: renewal_sent_{gd_acct}
All hardcoded · Approval: /approve?token=occ-renewal-2026&batch= Live Automated
occ-square-daily
Daily Revenue Report
Worker Auto Daily cron (morning, sends yesterday's data)
Manual: ?token=occ-square-daily-2026
Square: Orders Search, Payments, Refunds APIs
(via occ-square-proxy)
Brevo → info@ (daily transaction email) occ-square-daily-2026 Live Automated
occ-wc-to-gd
WooCommerce → GD Sync
Worker Auto Cron (checks WC orders last 48hrs)
Manual: ?trigger=1&token=
WooCommerce: processing/completed orders (last 48hrs)
KV: wc_order_{orderId} dedup
GorillaDESK: creates customer record with full location note
KV: write wc_order_{orderId} (90d TTL)
SECRET_TOKEN env · WC + GD keys hardcoded Live Automated
occ-command-center
Command Center Backend
Worker Called by OCC_Command_Center.html
Cron 0 7 * * * (2am ET nightly GD sync)
GorillaDESK: customers (paginated, ?include=locations)
Square (via occ-square-proxy): revenue, transactions, refunds
D1 occ-customers: search, stats, churn, stale
WooCommerce: stale account card check
D1 occ-customers: full nightly sync (upsert)
D1 customer_changes: delta log
Square (via proxy): refund actions
occ-cc-2026 Live
occ-square-proxy
Square API Proxy
Worker Called by Command Center, Refund Tool, Recon Tool, Daily Report Square: Payments, Orders, Refunds, Revenue APIs Returns JSON to caller
Square: issues refunds (POST action)
?secret=occ-square-2026 Live
occ-referral-agent
Referral Tracker
Worker GET endpoints: public
POST endpoints: Bearer token
ohiocleancans.com/ref/CODE redirect
D1 referral DB: agents, orders
WooCommerce: coupon existence check
D1 referral DB: register agent, log order, mark contacted
WooCommerce: auto-create $10 coupon on agent registration
Bearer API_SECRET env Live
occ-inbox-sorter
Outlook Inbox Sorter
Worker Auto Microsoft Graph webhook (real-time, new email)
Cron: subscription auto-renewal every 3 days
Manual: POST /backlog (50 emails/call)
Microsoft Graph: inbox messages
KV: subscription ID, cursor
Microsoft Graph: move emails to folders / Deleted Items
KV: subscription state
Microsoft OAuth client credentials · occ-reorg-2026 Live
occ-gas-proxy
Management Tool Proxy
Worker Called by legacy OCC Management Tool HTML Google Apps Script (Sheets data)
GorillaDESK: new customers, customer count
Returns JSON to caller ?token=oyDVMFy-CB1VGX_huR9avQ Live Legacy
OCC_Command_Center.html
Central Dashboard
Local Tool Open in browser
Netlify: occ-tools.netlify.app/OCC_Command_Center.html
occ-command-center worker (all data)
occ-square-proxy (revenue, refunds)
occ-sms-dispatch (Game Day status)
Via workers: D1 sync, Square refunds, GD sync, SMS send All via worker tokens Live
OCC_Prepaid_Renewal.html
Prepaid Renewal (Manual)
Local Tool Open in browser · Netlify: occ-tools.netlify.app GorillaDESK prepaid CSV (public URL) Brevo: renewal notice email (manually triggered)
No KV writes — manual send tool only
Brevo key in local config Live
OCC_Square_Refund.html
Refund Tool
Local Tool Open in browser occ-square-proxy: search payments occ-square-proxy: issue refund Via proxy: occ-square-2026 Live
OCC_Square_Reconciliation.html
Reconciliation Tool
Local Tool Open in browser occ-square-proxy: full transaction list Read-only display + CSV export Via proxy: occ-square-2026 Live
OCC_Bible.html
Build Reference
Local Tool Open in browser · Active/OCC_Bible.html Static HTML — no API calls Reference only Live
Shared KV Namespace — 57151d059c9a4866ba45f5d4bbb8ee89
Key Pattern Written By Read By Value / Purpose TTL
empty:YYYYMMDD:customerIdocc-empty-confirmocc-empty-confirm, occ-sms-dispatch{status, confirmed_at, customer_id} — can confirm choice48 hrs
sms_sent:YYYYMMDD:customerIdocc-sms-dispatchocc-sms-dispatchDedup — prevents re-sending same customer same day48 hrs
ot_followup_{jobId}occ-ot-followupocc-ot-followupDedup for OT email 1 (day 3)Long TTL
ot_followup2_{jobId}occ-ot-followupocc-ot-followupDedup for OT email 2 (day 21)Long TTL
ot_followup3_{jobId}occ-ot-followupocc-ot-followupDedup for OT email 3 (day 86)Long TTL
converted_from_ot_{email}occ-signup-pageocc-ot-followupKills future OT emails once customer converts to recurringLong TTL
ot_repeat_{email}occ-signup-pageocc-ot-followupMarks customer as repeat OT booker — skips emails 1+2 on next jobLong TTL
pricing_{email}occ-signup-page / occ-wc-to-gdocc-welcome-email, occ-signup-pageFirst-cleaning discount pricing data for welcome email90 days
welcome_{customerId}occ-welcome-emailocc-welcome-emailDedup — one welcome per customer ever90 days
wc_order_{orderId}occ-wc-to-gdocc-wc-to-gdDedup — one GD create per WC order90 days
hcust_{hauler}_{dow}occ-holiday-notify (?sync)occ-holiday-notifyCustomer list for hauler + day combo (for pickup delay emails)1 year
pending_holiday_{batchId}occ-holiday-notifyocc-holiday-notifyPending approval batch with customer list10 days
holiday_sent_{date}occ-holiday-notifyocc-holiday-notifyDedup — prevents sending customer emails twice for same holiday400 days
holiday_internal_YYYY-MMocc-holiday-notifyocc-holiday-notifyDedup — one 1st-of-month email per month40 days
holiday_midmonth_YYYY-MMocc-holiday-notifyocc-holiday-notifyDedup — one 22nd reminder per month40 days
D1 Database — occ-customers (e1ab48e2-7f56-425a-95e2-ae1a58adc93d)
TableColumnTypeNotes
customers idTEXT PKGorillaDESK customer ID
first_nameTEXT
last_nameTEXT
emailTEXT
phoneTEXT
addressTEXTFrom locations[0].address_line_1 — requires ?include=locations on sync
cityTEXT
stateTEXT
zipTEXTUsed by occ-sms-dispatch to find today's customers by route ZIPs
statusTEXTactive / inactive
tagsTEXTJSON array — contains plan type
service_typeTEXT
created_atTEXTISO date from GD
synced_atTEXTLast sync timestamp
customer_changes idINTEGER PKAuto-increment
customer_idTEXTFK → customers.id
fieldTEXTWhat changed (status, email, etc.)
old_valueTEXT
changed_atTEXTISO timestamp
sync_log idINTEGER PKAuto-increment
synced_atTEXT
totalINTEGERCustomers synced
notesTEXTAny sync errors or notes
D1 Database — Referral Tracker
TableColumnTypeNotes
referral_agents idINTEGER PKAuto-increment
nameTEXT
emailTEXT
codeTEXT UNIQUE2-letter + 3-digit code (e.g. AB123)
wc_coupon_idINTEGERWooCommerce coupon ID for this agent
contactedINTEGER0/1 — marked by Howard
referral_orders idINTEGER PKAuto-increment
agent_codeTEXTFK → referral_agents.code
order_idTEXTWooCommerce order ID
customer_emailTEXT
order_totalREAL
Last updated: April 1, 2026 — Initial schema build