The template is a browser-to-BFF-to-service architecture.
Browser UI
-> local /api/** Next.js route handler
-> src/lib/server/zship.ts (shared proxy instance)
-> Cloudflare Service Binding when available
-> HTTP fallback URL when running locally
-> existing ZShip backend Worker
Routing
Routes are defined with App Router file conventions: page.tsx, layout.tsx, and route.ts under src/app/**. Public marketing pages live in the (marketing) route group. Dynamic params and search params arrive as Promises in server components.
Server components and data
Each public page.tsx is a server component that exports metadata, emits JSON-LD, and fetches its own data through the same proxy layer the route handlers use — forwarding the request cookie, client IP, and user agent. Interactive islands (locale-aware copy, coupon forms, checkout buttons) are client components under src/components/**.
Server routes
Every backend-facing operation lives under src/app/api/**/route.ts. Public machine-readable SEO surfaces live at:
/sitemap.xml/robots.txt/llms.txt/llms-full.txt
Those handlers run server-side, so browser code does not need backend service secrets or direct app-key mutation authority.
Worker deployment
wrangler.jsonc points main at the OpenNext-built .open-next/worker.js, enables nodejs_compat, and declares Service Bindings for auth, pay, support, blog, check-in, AI, CDN, site, prompt, provider1, and enterprise billing. There is no Next.js middleware or proxy.ts — OpenNext on Cloudflare does not run Node middleware.
Shared client providers
src/components/providers.tsx wraps the app with the shared i18n provider (cookie-backed locale) and the theme provider for light, dark, and system modes.