GrowthAgent architecture
Runtime components
Authentication boundaries
- Shopify OAuth — standard install flow at
/auth/installand/auth/callback. OAuth state stored in KV with short TTL. - Embedded admin session — Shopify session tokens verified on every admin request. Session cookie fallback via
/api/session/bootstrapwith partitioned and unpartitioned cookies. - Public chat — rate-limited per-IP with KV-backed counters. Shop validation via request parameters. CORS-restricted.
- Webhooks — HMAC signature verification before any handler logic.
Product data flow
- Store knowledge — merchant triggers catalog and policy sync through
POST /api/knowledge/sync. Webhooks forproducts/create,products/update,products/delete, andinventory_levels/updatesignal content changes. - Chat — storefront shopper message arrives at
POST /chat. The Worker retrieves relevant knowledge, sends context to OpenAI Responses API, and returns the answer. - Handoff — when the assistant identifies a support need, it sends notifications to the merchant-configured email (via Resend), SMS (via Twilio), fax (via Sinch), or webhook endpoint.
- Attribution —
POST /webhooks/ordershashes the order’scart_token, matches against stored conversationcart_token_hash, and records anassisted_orderApp Event. - Simulation — runs within the Worker using saved settings. Does not publish theme changes or send real handoffs.
Privacy handling
Three Shopify compliance webhooks handled atPOST /webhooks/privacy:
customers/data_request— exports customer data to R2 and emails the merchant a signed download linkcustomers/redact— deletes matching conversations, messages, handoff tickets, attribution events, and audit recordsshop/redact— deletes all shop data including knowledge documents, usage events, and the shop record, with best-effort Algolia index cleanup
Infrastructure
Security model
- Shopify OAuth HMAC, webhooks, and embedded-admin session tokens are verified.
- Shop tokens and merchant-supplied OpenAI, Algolia, Twilio, and ElevenLabs credentials are AES-GCM encrypted before storage.
- Public endpoints have shop validation, CORS restrictions, and KV-backed rate limits.
- Mutating operations are auditable and constrained by the app-specific policy boundary.
- The database uses a DML-only runtime role and a DDL-capable migration role, with ownership separated to a non-login role.