Infrastructure
Worker endpoints, cron, bindings, secrets map
Cloudflare services
- Worker — gfs-platform, source src/index.ts. Routes api.ai-globalfoodsolutions.co/*.
- D1 — gfs-netsuite (3818ecd5-995e-4694-a08b-a273c94291da).
- KV — namespace CACHE (e880e40bc3674963bc37cf90e02f6369).
- R2 — bucket gfs-files.
- Pages — gfs-netsuite.pages.dev (this platform). Legacy: gfs-system-guide.pages.dev.
- DNS / zone — ai-globalfoodsolutions.co (owned). Corporate domain globalfoodsolutions.co also owned.
Worker endpoints — overview 59 detected
Detected by static analysis of src/index.ts. Detail per endpoint below.
| Path | Auth | Method |
|---|---|---|
| / | Public | GET |
| /api/ | Bearer | GET |
| /api/ai/caps | Bearer | GET |
| /api/ai/metrics | Bearer | GET |
| /api/ar/aging | Bearer | GET |
| /api/assemblies | Bearer | GET |
| /api/assembly-cost-rollup/refresh | Bearer | GET |
| /api/auth/edit-check | Bearer | GET |
| /api/bids | Bearer | GET |
| /api/bids/create | Bearer | GET |
| /api/briefing | Bearer | GET |
| /api/chat/feedback | Bearer | GET |
| /api/chat/sessions | Bearer | GET |
| /api/customers | Bearer | GET |
| /api/customers/ranking | Bearer | GET |
| /api/embed/refresh | Bearer | GET |
| /api/evals | Bearer | GET |
| /api/evals/run | Bearer | GET |
| /api/financials/monthly | Bearer | GET |
| /api/financials/summary | Bearer | GET |
| /api/gl/accounts | Bearer | GET |
| /api/health | Public | GET |
| /api/healthcheck | Bearer | GET |
| /api/items | Bearer | GET |
| /api/items/performance | Bearer | GET |
| /api/kpis | Bearer | GET |
| /api/mapping/confirm | Bearer | GET |
| /api/mapping/fuzzy | Bearer | GET |
| /api/mapping/populate | Bearer | GET |
| /api/mapping/unmatched | Bearer | GET |
| /api/ns/touchpoints | Bearer | GET |
| /api/pricing-chat | Bearer | GET |
| /api/pricing-chat/intent | Bearer | GET |
| /api/pricing/audit/summary | Bearer | GET |
| /api/pricing/compare | Bearer | GET |
| /api/pricing/derive | Bearer | GET |
| /api/pricing/diff | Bearer | GET |
| /api/pricing/push | Bearer | GET |
| /api/programs | Bearer | GET |
| /api/programs/accruals | Bearer | GET |
| /api/programs/create | Bearer | GET |
| /api/quotes | Bearer | GET |
| /api/revenue/trend | Bearer | GET |
| /api/review-queue | Bearer | GET |
| /api/search | Bearer | GET |
| /api/spec-drift-vs-ns | Bearer | GET |
| /api/spec-items | Bearer | GET |
| /api/spec/by-claim | Bearer | GET |
| /api/sync-status | Public | GET |
| /api/transactions | Bearer | GET |
| /api/vendor-costs | Bearer | GET |
| /api/vendor-costs/create | Bearer | GET |
| /api/vendor-mapping/confirm | Bearer | GET |
| /api/vendor-mapping/fuzzy | Bearer | GET |
| /api/vendor-mapping/populate | Bearer | GET |
| /api/vendor-mapping/unmatched | Bearer | GET |
| /api/vendors | Bearer | GET |
| /api/vendors/spend | Bearer | GET |
| /api/whoami | Bearer | GET |
Worker endpoints — per-endpoint detail 24 documented
Param tables, auth, and example responses for every public endpoint. Source: data/api-endpoints.json.
GET /api/healthPublicExample response
GET /api/kpisBearerExample response
GET /api/briefingBearerExample response
GET /api/customersBearerParameters
| Param | Type | Default | Description |
|---|---|---|---|
| q | string | — | Search by company name (LIKE %q%) |
| limit | int | 50 | 1-200 |
| offset | int | 0 | 0-100000 |
Example response
GET /api/customers/:idBearerExample response
GET /api/customers/:id/historyBearerExample response
GET /api/customers/rankingBearerParameters
| Param | Type | Default |
|---|---|---|
| year | int | 2026 |
Example response
GET /api/vendorsBearerGET /api/vendors/spendBearerParameters
| Param | Type | Default |
|---|---|---|
| year | int | 2026 |
GET /api/itemsBearerParameters
| Param | Type | Default | Allowed Values |
|---|---|---|---|
| type | string | — | InvtPart, Assembly, Kit, NonInvtPart |
| allergen | string | — | milk, eggs, peanuts, soybeans, wheat, fish, tree_nuts, crustacean, celery, lupin, molluscs, mustard, sesame, sulphur_dioxide |
| limit | int | 50 | 1-200 |
| offset | int | 0 | 0-100000 |
GET /api/items/:idBearerGET /api/items/performanceBearerParameters
| Param | Type | Default |
|---|---|---|
| year | int | 2026 |
GET /api/items/:id/customersBearerGET /api/transactionsBearerParameters
| Param | Type | Default | Allowed |
|---|---|---|---|
| type | string | CustInvc | 16 validated types |
| year | int | — | 2018-2027 |
| limit | int | 50 | 1-200 |
| offset | int | 0 | 0-100000 |
GET /api/ar/agingBearerExample response
GET /api/financials/summaryBearerExample response
GET /api/financials/monthlyBearerParameters
| Param | Type | Default |
|---|---|---|
| year | int | 2026 |
GET /api/revenue/trendBearerGET /api/gl/accountsBearerParameters
| Param | Type | Default | Values |
|---|---|---|---|
| type | string | — | Bank, AcctRec, AcctPay, Income, COGS, Expense, Equity, OthCurrAsset, OthCurrLiab, FixedAsset, OthIncome, OthExpense, NonPosting |
GET /api/searchBearerParameters
| Param | Type | Required |
|---|---|---|
| q | string | Yes (max 100 chars) |
Example response
GET /api/pricing/deriveBearer (admin)Triggers full re-derivation of customer_pricing_proposed from invoice_lines. Reads up to last 3 invoices per (customer, item) since 2024-01, applies median when 3+ exist, else last_paid. Clears existing 'proposed' rows then inserts the fresh set. Idempotent — running twice produces the same result. Implements ADR-012.
Example response
GET /api/pricing/diffBearerThree-bucket audit across customer_pricing (NS current state) vs customer_pricing_proposed (derived). Listed+Recent = both have rows for the pair → drift check. Listed+Stale = NS has row, derive doesn't → candidate to deprecate. Not-Listed+Recent = derive has row, NS doesn't → orphan items being bought without price-list entry.
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
| customer | int | — | Scope to one customer ID |
Example response
GET /api/pricing/customer/:idBearerPer-customer pricing view: current NS rows + derived proposed rows + stale rows (in NS but no recent invoice). Each proposed row tagged with bucket (listed_recent / not_listed_recent) and delta_pct vs current.
Example response
GET /api/pricing/audit/summaryBearerHigh-level pricing audit snapshot: proposed counts, source breakdown (median_last_3 vs last_paid), three-bucket counts, open SOs in flight (would be affected by cutover), last-derived timestamp.
Example response
Example requests
CORS & security headers
Origins allowed by the Worker: https://ai-globalfoodsolutions.co, https://www.ai-globalfoodsolutions.co, http://localhost:3000, http://localhost:8787.
Headers on every JSON response: X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: strict-origin-when-cross-origin, Content-Security-Policy: default-src 'none'; frame-ancestors 'none'.
DNS records 6 records
Records on the ai-globalfoodsolutions.co zone. Proxied = behind Cloudflare WAF/CDN.
| Type | Name | Value | Proxy |
|---|---|---|---|
| CNAME | api | gfs-platform.mikelevine.workers.dev | Proxied |
| CNAME | www | ai-globalfoodsolutions.co | Proxied |
| MX | @ | route1.mx.cloudflare.net (priority 87) | — |
| TXT | @ | v=spf1 include:_spf.mx.cloudflare.net ~all | — |
| TXT | _dmarc | v=DMARC1; p=none; ... | — |
| NS | @ | chance.ns.cloudflare.com · leanna.ns.cloudflare.com | — |
Cron schedules
Declared in wrangler.jsonc:
- */15 * * * *
- 0 19 * * *
- 0 3 1 * *
- 5 */2 * * *
Local cron (actually running)
| Script | Cadence | Function | Source |
|---|---|---|---|
| sync.sh | every 15 min via launchd | Queries Chartstone (localhost:56411) for modified NS transactions in the last 30 min, upserts into D1. | sync.sh |
| daily-report.sh | archived | (Out of scope — revenue report.) | archive/2026-05/daily-report.sh |
Bindings
| Binding | Type | Target |
|---|---|---|
| DB | D1 database | gfs-netsuite (3818ecd5-995e-4694-a08b-a273c94291da) |
| CACHE | KV namespace | e880e40bc3674963bc37cf90e02f6369 |
| STORAGE | R2 bucket | gfs-files |
| API_KEY | Secret | set via wrangler secret put API_KEY |
Secrets map
Names only. Rotation cadence in runbook → secret rotation.
| Name | Location | Use |
|---|---|---|
| API_KEY | Worker env (Cloudflare) | Bearer for protected REST endpoints |
| CHARTSTONE_SECRET | Local ~/.zshenv | Bearer used by sync.sh to call Chartstone |
| (NetSuite TBA tokens) | NetSuite Manage Auth Tokens | SuiteAttach, Analytics Warehouse, Chartstone Pro |
Deploy commands
Related surfaces
Cloudflare
Workers, D1, KV, R2, Pages, DNS, AI roadmap, pricing pipeline roadmap.
Data model
D1 schema, ER diagram, FK relationships, example queries, SuiteQL admin library.
Admin dashboard
Live health, sync status, risk register, known issues, pricing pipeline status.
Runbook
Procedures, checklists, onboarding, secret rotation, incident response, pricing procedures.
Decision log
11 ADRs covering platform architecture, AI stack, pricing pipeline.