How kinngh/shopify-nextjs-prisma-app works
Main components
• Frontend: Next.js pages & React components (embedded app UI using Polaris & App Bridge).
• Backend: Next.js API Routes (REST & GraphQL endpoints, proxy, checkout, GDPR, webhooks).
• Middleware & Utils: HMAC/jwt verification, session handling, Shopify client provider.
• Database: Prisma ORM connected to a MySQL-compatible store (e.g., PlanetScale).
• External Services: Shopify Admin API (GraphQL), Shopify Webhooks, App Bridge CDN.
Relationships & data flow
• The browser UI calls serverless API routes.
• API Routes invoke middleware stacks, then handlers in utils/ and pages/api/*.
• Handlers talk to Shopify Admin API or to Prisma for persistence.
• Webhook route receives events directly from Shopify and routes them to handler functions.
• Prisma translates queries to the underlying PlanetScale/MySQL database.
Architectural patterns & principles
• Serverless functions (Next.js API Routes) with per-route middleware.
• Separation of concerns: UI vs. API vs. data access.
• Use of providers (AppBridgeProvider, clientProvider) for dependency injection.
• Modular utils for cryptography, session, webhooks, and Shopify integration.