INFRASTRUCTURE & CONNECTIONS

Cloudflare Services

ServiceID / URLBindingStatus
Workergfs-platform · mikelevine.workers.devLIVE
D1 Database3818ecd5-995e-4694-a08b-a273c94291daDBLIVE
KV Namespacee880e40bc3674963bc37cf90e02f6369CACHEREADY
R2 Bucketgfs-filesSTORAGEREADY
Domainai-globalfoodsolutions.co · Zone 26a291b9ae64675bf5041d0affb22bc9ACTIVE
Worker Routeapi.ai-globalfoodsolutions.co/*SSL PENDING
Cron: Sync*/15 * * * *RUNNING (Worker-side stub; local launchd does actual sync)
Cron: Report0 19 * * *RUNNING (7pm UTC = Worker cron; local daily-report.sh is separate)
Pagesgfs-netsuite-tools.pages.devLIVE
SecretAPI_KEYSET

NetSuite Services

ServiceIDTypeStatus
Account4656898 PRODUCTIONERPCONNECTED
SuiteAPI#2948RESTletDEPLOYED
SuiteQL Tool#2947SuiteletDEPLOYED
Toolkit#2949SuiteletDEPLOYED
SuiteAttachCustom RESTletRESTletDEPLOYED
MCP ServerClaude.ai integrationMCPCONNECTED
Chartstone Prolocalhost:<PORT>Local APIRUNNING
N/llm ModuleCohere Command RNative AIAVAILABLE

DNS Records

TypeNameValueProxy
CNAMEapigfs-platform.mikelevine.workers.devProxied
CNAMEwwwai-globalfoodsolutions.coProxied
MX@route1.mx.cloudflare.net (priority 87)
TXT@v=spf1 include:_spf.mx.cloudflare.net ~all
TXT_dmarcv=DMARC1; p=none; ...
NS@chance.ns.cloudflare.com · leanna.ns.cloudflare.com

Local Services (launchd)

co.globalfoodsolutions.sync

Interval900 seconds (15 min)
Script~/Desktop/gfs-platform/sync.sh
RunAtLoadtrue
Stdoutsync-stdout.log
Stderrsync-stderr.log
PATH/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin

co.globalfoodsolutions.report

Schedule7:00 PM daily
Script~/Desktop/gfs-platform/daily-report.sh
Outputdaily-report-YYYY-MM-DD.md
Logreport.log
QueriesD1 KPIs via wrangler --json + python3 JSON parse

CORS Allowed Origins

https://ai-globalfoodsolutions.co
https://www.ai-globalfoodsolutions.co
http://localhost:3000
http://localhost:8787

Chartstone Pro (Local NetSuite API)

FieldValue
TypeLocal desktop app, localhost HTTP API
URLhttp://127.0.0.1:<PORT> (port changes on restart — check Chartstone app)
AuthBearer token from CHARTSTONE_SECRET in ~/.zshenv
NS Account4656898 PRODUCTION (Mike Bot, Administrator)
TierPro (unlimited queries, 500K row ceiling)
Key EndpointsPOST /suiteql · POST /search · POST /record-json · GET /health
HeadersAccept: application/toon (25-50% token reduction) · Content-Type: application/json
DEPENDENCY: sync.sh requires Chartstone running. If Chartstone is closed, sync fails silently.

Known Issues

IssueStatusImpactFix
sync.sh had macOS quarantine (com.apple.provenance)FIXEDlaunchd sync was failing with "Operation not permitted"xattr -d com.apple.provenance sync.sh
Custom domain SSLPENDINGapi.ai-globalfoodsolutions.co not yet serving HTTPSCheck CF dashboard Edge Certificates
Worker sync cron is stubTODOhandleSync() only writes sync_log, doesn't call SuiteAPIImplement RESTlet delta sync in Worker
Worker daily report emailTODOhandleDailyReport() only logs to consoleImplement via Cloudflare Email
KV and R2 bound but unusedFUTURENo endpoints read/write KV or R2Phase 4: KV caching, R2 file storage
vb_lines coverageRESOLVED100% of bills with inventory items (11,631/11,631). 11,285 expense-only bills have no item lines by design.No action needed
No DKIM TXT record foundCHECKEmail deliverability may be affectedVerify in CF dashboard Email Routing

Credential Locations

CredentialLocationNotes
Cloudflare OAuth~/.wrangler/Managed by wrangler login, not a static key
CHARTSTONE_SECRET~/.zshenv64-char hex string, shared secret for Chartstone
API_KEYCloudflare secret storeSet via wrangler secret put, not on disk
CF Account ID9d209df5a6be33dfbf2b9dea3dfd35f9In wrangler error messages

Wrangler Configuration

{
  "name": "gfs-platform",
  "main": "src/index.ts",
  "compatibility_date": "2026-05-18",
  "workers_dev": true,
  "d1_databases": [{ "binding": "DB", "database_name": "gfs-netsuite", "database_id": "3818ecd5-..." }],
  "r2_buckets": [{ "binding": "STORAGE", "bucket_name": "gfs-files" }],
  "kv_namespaces": [{ "binding": "CACHE", "id": "e880e40bc367..." }],
  "triggers": { "crons": ["*/15 * * * *", "0 19 * * *"] },
  "routes": [{ "pattern": "api.ai-globalfoodsolutions.co/*", "zone_name": "ai-globalfoodsolutions.co" }]
}

Operations Runbook

Deploy Worker Update

cd ~/Desktop/gfs-platform
# Edit src/index.ts
wrangler deploy
# Verify:
curl -s https://gfs-platform.mikelevine.workers.dev/api/health

Deploy Guide Update

cd ~/Desktop/gfs-platform
# Edit guide/*.html
# Rebuild deploy dir:
rm -rf /tmp/gfs-deploy && mkdir -p /tmp/gfs-deploy/docs /tmp/gfs-deploy/diagrams
for f in guide/*.html guide/*.css; do cp "$f" /tmp/gfs-deploy/; done
cp guide/diagrams/*.html /tmp/gfs-deploy/diagrams/
cp infrastructure-dashboard.html executive-dashboard.html /tmp/gfs-deploy/
cp docs/04-Power-Tools.html /tmp/gfs-deploy/docs/
wrangler pages deploy /tmp/gfs-deploy --project-name gfs-system-guide

Load Data into D1

# Single SQL file:
wrangler d1 execute gfs-netsuite --remote --file=sql/01_customers.sql

# Ad-hoc query:
wrangler d1 execute gfs-netsuite --remote --command="SELECT COUNT(*) FROM transactions"

# JSON output for scripting:
wrangler d1 execute gfs-netsuite --remote --json --command="SELECT ..."

Sync Troubleshooting

# Check sync status:
cat ~/Desktop/gfs-platform/sync.log
cat ~/Desktop/gfs-platform/sync-stderr.log

# Check launchd:
launchctl list | grep globalfood

# If "Operation not permitted":
xattr -d com.apple.provenance sync.sh

# If Chartstone port changed:
# Check Chartstone app for new port
# Update sync.sh PORT variable

# Manual sync test:
bash ~/Desktop/gfs-platform/sync.sh

Secret Rotation

# Rotate Worker API key:
cd ~/Desktop/gfs-platform
wrangler secret put API_KEY
# Type new key, then update all clients

# Chartstone secret is in ~/.zshenv:
# CHARTSTONE_SECRET=<64-char-hex>

# CF OAuth — re-login:
wrangler login

D1 Capacity

# Current: 29.6 MB / 18 tables / ~185K rows
# D1 Limits (paid): 10 GB storage, 10M rows
# Headroom: ~98% free
# Growth rate: ~30 txns/day = ~11K/year
# At current rate: decades of capacity

# Check DB size:
wrangler d1 execute gfs-netsuite --remote --json \
  --command="SELECT * FROM sqlite_master" 2>/dev/null \
  | python3 -c "import sys; print(len(sys.stdin.read()),'bytes')"

Glossary

TermDefinition
SuiteQLNetSuite's SQL dialect (Oracle-style). Used for querying NS data directly.
RESTletNetSuite custom REST endpoint built with SuiteScript. SuiteAPI #2948 is a RESTlet.
SuiteletNetSuite custom web page built with SuiteScript. SuiteQL Tool #2947 is a Suitelet.
SuiteScriptNetSuite's JavaScript-based scripting language (SS 2.0/2.1). Runs server-side in NS.
N/llmNetSuite's native AI module. Calls Cohere Command R. 0 governance units per call.
MCPModel Context Protocol. Lets AI agents (Claude) call tools in external systems (NetSuite).
TBAToken-Based Authentication. NS auth method using consumer/token key pairs.
D1Cloudflare's serverless SQLite database on the edge. Our mirror of NS data.
KVCloudflare Workers Key-Value store. Bound as CACHE, not yet used.
R2Cloudflare's S3-compatible object storage. Bound as STORAGE, not yet used.
ChartstoneLocal desktop app providing unlimited localhost API access to NetSuite via SuiteQL.
EntityCustomer or vendor internal ID on a transaction. Backfilled 78,616 records to 100%.
DepartmentIn GFS context = Brand (Right Start, Power Up, etc). Maps to ref_departments.
Governance UnitsNS script execution budget. Suitelets get 10,000. N/llm calls cost 0.
SuiteFrameTim Dietrich's framework for building NS web apps. Single-Suitelet MVC pattern.