Docs
    Shopify AI Product OptimizerUpdated Jul 13, 2026MD

    ARCHITECTURE

    Markdown file

    docs/ARCHITECTURE.md

    Architecture

    High-level overview of how the system fits together.

    Components

    • Remix app (app/)
      • Embedded Shopify admin UI (Polaris/App Bridge)
      • API routes / webhooks
      • Auth and session storage via Prisma
    • Worker (worker/)
      • Background job processing (BullMQ + Redis)
      • AI analysis/generation work that shouldn’t block web requests
    • Database (Postgres via Prisma)
      • Stores shops, products, suggestions, audit logs, automation settings
      • Stores billing state + metered usage events
      • Staging recommendation: Neon Postgres (usage-based)
    • Queue / cache (Redis)
    • BullMQ backing store
    • Staging recommendation: Upstash Redis (usage-based)
    • Hosting
    • Render runs the web and worker processes from render.yaml

    Data flow (typical)

    1. Merchant installs app → auth flow completes → shop record upserted (token persisted).
    2. App triggers analysis/generation work → worker jobs run.
    3. Results are stored (suggestions/audit trail) and optionally applied to Shopify.
    4. Usage events are recorded in DB and (when wired) reported to Shopify usage billing.

    Billing (in progress)

    • Plan is defined as a line-item billing plan in app/shopify.server.ts (recurring + usage cap).
    • Billing state is synced into DB via app/lib/billing.server.ts.