Overview
N-2 Water is a mineral-first hydration brand. This project is the full digital platform: a Next.js 15 (App Router) store in an npm workspaces monorepo, integrated with Shopify Storefront API (GraphQL) and Customer Account API (OAuth 2.0 + PKCE), deployed on Vercel. Development spans static HTML → React store → 20+ designer-delivered components across homepage, science, shop, and account surfaces.
Problem & Context
The brand needed marketing storytelling and real e-commerce (catalog, PDP variants, cart, checkout, authenticated orders) in one maintainable codebase. Early static HTML could not support PKCE account flows, shared cart state across origins, or the scoped UI work from an external designer — without a controlled migration path.
Constraints
- Public OAuth client — no server-side secret; PKCE required for Customer Account API.
- Cross-origin cart: legacy static site and Next app on different origins; cookies alone are insufficient (
SameSitelimits). - OpenID Connect discovery for Shopify customer endpoints — avoid hardcoded URLs.
- Designer phases must land inside App Router without blocking commerce-critical paths.
- No fabricated Lighthouse or revenue metrics — performance hardening and production domains remain planned/deferred per internal status docs.
Approach & Design Decisions
- Gradual migration: root
vercel.jsonredirect shell sends traffic to the store app; legacy static remained reachable during build-out. - PKCE + short-lived HttpOnly cookies for OAuth state/nonce/verifier (5-minute TTL), cleared after token exchange — tokens never exposed to client JS.
X-Cart-Idheader:widget.jsstores Shopify cart id inlocalStoragefor the static site; API routes read header (static) or cookie (same-origin).DesignContext+Shift+Ctrl+D: CEO/stakeholder toggle comparing designer vs legacy components until Phase 9 cleanup (delete legacy/admin paths).- Zod on API routes for safe request parsing before Shopify mutations.
Implementation Highlights
- GraphQL via
graphql-request: products, cart mutations, customer operations (seeshopify.ts/ customer OAuth helpers). - REST API routes:
/api/cart,/api/auth/*,/api/account/*, newsletter/contact stubs ready for provider wiring. - next/image migration (v2.2.0):
<img>→<Image>across key surfaces;remotePatternsfor Shopify CDN. - Jest: integration, security (CORS, injection), safety, and E2E-style coverage categories.
- Workflow alignment (v2.3.0): docs and audit patterns aligned to shared workflow-core Mode A conventions.
Results & Evaluation
My work supported a production headless commerce storefront, including marketing pages, authenticated accounts, order history, subscriptions, and cross-domain cart persistence. I collaborated with stakeholders and designers through iterative feedback and staged rollout. My role ended in August 2026.
Jest coverage included integration, security, and safety scenarios. I do not claim a measured revenue or performance improvement from these engineering changes.
Tradeoffs & Further Work
- Shopify API behavior and rate limits are external dependencies.
- A staged migration creates temporary complexity around legacy pages and shared cart state.
- Broader performance and conversion evaluation requires representative production measurements; no figures are published here.
What I Learned
Migrating a live brand site while integrating OAuth PKCE, cross-domain cart state, and parallel designer UI forces explicit contracts: cookie shapes, CORS allowlists, and feature flags for safe rollout.