create-brainerce-store 1.66.0 → 1.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/templates/nextjs/base/.env.local.ejs +45 -24
  4. package/templates/nextjs/base/.eslintrc.json +51 -57
  5. package/templates/nextjs/base/AGENTS.md.ejs +107 -81
  6. package/templates/nextjs/base/CLAUDE.md.ejs +118 -92
  7. package/templates/nextjs/base/next.config.ts +103 -86
  8. package/templates/nextjs/base/scripts/fetch-store-info.mjs +104 -97
  9. package/templates/nextjs/base/src/app/agents.md/route.ts +4 -3
  10. package/templates/nextjs/base/src/app/api/auth/me/route.ts +65 -59
  11. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +255 -242
  12. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +311 -308
  13. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +277 -276
  14. package/templates/nextjs/base/src/app/blog/rss.xml/route.ts +4 -3
  15. package/templates/nextjs/base/src/app/category/[slug]/page.tsx +6 -5
  16. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +46 -46
  17. package/templates/nextjs/base/src/app/indexnow-key.txt/route.ts +25 -26
  18. package/templates/nextjs/base/src/app/layout.tsx.ejs +273 -257
  19. package/templates/nextjs/base/src/app/llms.txt/route.ts +4 -3
  20. package/templates/nextjs/base/src/app/opengraph-image.tsx +1 -1
  21. package/templates/nextjs/base/src/app/page.tsx +65 -64
  22. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +92 -92
  23. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +6 -5
  24. package/templates/nextjs/base/src/app/robots.ts +3 -2
  25. package/templates/nextjs/base/src/app/sitemap.ts +4 -3
  26. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +294 -292
  27. package/templates/nextjs/base/src/components/seo/article-json-ld.tsx +60 -59
  28. package/templates/nextjs/base/src/components/seo/category-json-ld.tsx +60 -61
  29. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +2 -1
  30. package/templates/nextjs/base/src/core/lib/brainerce.server.ts +81 -0
  31. package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +60 -110
  32. package/templates/nextjs/base/src/core/lib/site-url.ts +197 -0
  33. package/templates/nextjs/base/src/ui/product/review-form.tsx +294 -294
  34. package/templates/nextjs/base/src/ui/product/reviews-section.tsx.ejs +108 -108
  35. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +301 -285
  36. package/templates/nextjs/designs/atelier/ui/layout/faq-section.tsx +97 -96
  37. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +142 -141
  38. package/templates/nextjs/designs/atelier/ui/layout/site-header.tsx.ejs +139 -138
  39. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +295 -267
  40. package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +148 -148
  41. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +72 -71
  42. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +83 -82
  43. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +120 -119
  44. package/templates/nextjs/ui-canvas/product/faq-section.tsx.ejs +54 -0
  45. package/templates/nextjs/ui-canvas/product/review-form.tsx +267 -266
  46. package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +96 -96
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "create-brainerce-store",
34
- version: "1.66.0",
34
+ version: "1.67.0",
35
35
  description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
36
36
  bin: {
37
37
  "create-brainerce-store": "dist/index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.66.0",
3
+ "version": "1.67.0",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"
@@ -1,24 +1,45 @@
1
- # Brainerce Sales Channel — preferred env var name.
2
- NEXT_PUBLIC_BRAINERCE_SALES_CHANNEL_ID=<%= connectionId %>
3
- # Legacy alias kept for backwards compatibility — both are accepted by the SDK.
4
- # @deprecated will be removed when SDK 2.0 ships.
5
- NEXT_PUBLIC_BRAINERCE_CONNECTION_ID=<%= connectionId %>
6
-
7
- # Store info (pre-fetched during setup to avoid flash on first load)
8
- NEXT_PUBLIC_STORE_NAME=<%- storeNameEnv %>
9
- NEXT_PUBLIC_STORE_CURRENCY=<%- currencyEnv %>
10
-
11
- # Backend API URL (server-side only — used by BFF proxy and SSR, never exposed to browser)
12
- BRAINERCE_API_URL=<%- apiBaseUrlEnv %>
13
-
14
- # Public API origin for the AI chat widget (public, unauthenticated endpoints only).
15
- # The widget streams chat directly from the browser, so this one IS public.
16
- NEXT_PUBLIC_BRAINERCE_API_URL=<%- apiBaseUrlEnv %>
17
-
18
- # Public site URL — used for sitemap, robots.txt, and SEO metadata
19
- NEXT_PUBLIC_SITE_URL=http://localhost:3000
20
-
21
- # Optional: floating WhatsApp contact button (used by some designs, e.g.
22
- # passepartout). Digits only, international format without "+"
23
- # (e.g. 14155550123). Leave unset to hide the button.
24
- # NEXT_PUBLIC_WHATSAPP_PHONE=
1
+ # Brainerce Sales Channel — preferred env var name.
2
+ NEXT_PUBLIC_BRAINERCE_SALES_CHANNEL_ID=<%= connectionId %>
3
+ # Legacy alias kept for backwards compatibility — both are accepted by the SDK.
4
+ # @deprecated will be removed when SDK 2.0 ships.
5
+ NEXT_PUBLIC_BRAINERCE_CONNECTION_ID=<%= connectionId %>
6
+
7
+ # Store info (pre-fetched during setup to avoid flash on first load)
8
+ NEXT_PUBLIC_STORE_NAME=<%- storeNameEnv %>
9
+ NEXT_PUBLIC_STORE_CURRENCY=<%- currencyEnv %>
10
+
11
+ # Backend API URL (server-side only — used by BFF proxy and SSR, never exposed to browser)
12
+ BRAINERCE_API_URL=<%- apiBaseUrlEnv %>
13
+
14
+ # Public API origin for the AI chat widget (public, unauthenticated endpoints only).
15
+ # The widget streams chat directly from the browser, so this one IS public.
16
+ NEXT_PUBLIC_BRAINERCE_API_URL=<%- apiBaseUrlEnv %>
17
+
18
+ # Public site URL — canonical tags, sitemap.xml, robots.txt, JSON-LD, and the
19
+ # Origin header the Brainerce backend checks against your sales channel's
20
+ # configured domain.
21
+ #
22
+ # Intentionally unset. Nothing at setup time knows where this store will be
23
+ # served from, so the storefront resolves its own origin at runtime: hosting
24
+ # platform variables first (Vercel / Netlify / Render / Railway / Cloudflare
25
+ # Pages), then the incoming request's forwarded host. It is correct in local
26
+ # development and on any host, with nothing set here.
27
+ #
28
+ # ⛔ Do not write a placeholder address into this variable. A wrong absolute
29
+ # URL is indistinguishable from a right one to a search crawler, so a guess
30
+ # here is worse than leaving it empty. Either set your real domain or nothing.
31
+ #
32
+ # Once you have that domain, set it — an explicit value is the only source a
33
+ # request header cannot forge, and it keeps canonical URLs stable across
34
+ # preview deployments:
35
+ #
36
+ # SITE_URL=https://shop.example.com
37
+ #
38
+ # Set it in your hosting provider's environment variables, not in this file:
39
+ # .env.local is gitignored and never travels with a deploy.
40
+ # `NEXT_PUBLIC_SITE_URL` is still read as a backwards-compatible alias.
41
+
42
+ # Optional: floating WhatsApp contact button (used by some designs, e.g.
43
+ # passepartout). Digits only, international format without "+"
44
+ # (e.g. 14155550123). Leave unset to hide the button.
45
+ # NEXT_PUBLIC_WHATSAPP_PHONE=
@@ -1,57 +1,51 @@
1
- {
2
- "extends": [
3
- "next/core-web-vitals"
4
- ],
5
- "overrides": [
6
- {
7
- "files": [
8
- "src/ui/**/*.{ts,tsx}"
9
- ],
10
- "rules": {
11
- "no-restricted-imports": [
12
- "error",
13
- {
14
- "patterns": [
15
- {
16
- "group": [
17
- "@/core/lib/*",
18
- "!@/core/lib/auth",
19
- "!@/core/lib/brainerce",
20
- "!@/core/lib/image-hosts",
21
- "!@/core/lib/navigation",
22
- "!@/core/lib/product-options",
23
- "!@/core/lib/sanitize",
24
- "!@/core/lib/sanitize-html",
25
- "!@/core/lib/translations",
26
- "!@/core/lib/use-currency",
27
- "!@/core/lib/utils"
28
- ],
29
- "message": "UI consumes data via @/core/hooks/* and @/core/providers/* — not core internals. (Approved presentation helpers are exempt.)"
30
- }
31
- ]
32
- }
33
- ]
34
- }
35
- },
36
- {
37
- "files": [
38
- "src/core/**/*.{ts,tsx}"
39
- ],
40
- "rules": {
41
- "no-restricted-imports": [
42
- "error",
43
- {
44
- "patterns": [
45
- {
46
- "group": [
47
- "@/ui/*"
48
- ],
49
- "message": "core/ must never depend on presentation (ui/)."
50
- }
51
- ]
52
- }
53
- ]
54
- }
55
- }
56
- ]
57
- }
1
+ {
2
+ "extends": ["next/core-web-vitals"],
3
+ "overrides": [
4
+ {
5
+ "files": ["src/ui/**/*.{ts,tsx}"],
6
+ "rules": {
7
+ "no-restricted-imports": [
8
+ "error",
9
+ {
10
+ "patterns": [
11
+ {
12
+ "group": [
13
+ "@/core/lib/*",
14
+ "!@/core/lib/auth",
15
+ "!@/core/lib/brainerce",
16
+ "!@/core/lib/brainerce.server",
17
+ "!@/core/lib/image-hosts",
18
+ "!@/core/lib/navigation",
19
+ "!@/core/lib/product-options",
20
+ "!@/core/lib/sanitize",
21
+ "!@/core/lib/tracking",
22
+ "!@/core/lib/sanitize-html",
23
+ "!@/core/lib/translations",
24
+ "!@/core/lib/use-currency",
25
+ "!@/core/lib/utils"
26
+ ],
27
+ "message": "UI consumes data via @/core/hooks/* and @/core/providers/* — not core internals. (Approved presentation helpers are exempt.)"
28
+ }
29
+ ]
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "files": ["src/core/**/*.{ts,tsx}"],
36
+ "rules": {
37
+ "no-restricted-imports": [
38
+ "error",
39
+ {
40
+ "patterns": [
41
+ {
42
+ "group": ["@/ui/*"],
43
+ "message": "core/ must never depend on presentation (ui/)."
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
49
+ }
50
+ ]
51
+ }
@@ -1,81 +1,107 @@
1
- # AGENTS.md — this is a LIVE Brainerce storefront
2
-
3
- **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
- connected.** Products, cart, checkout, coupons, discounts, orders and content
5
- flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
-
7
- - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
- system"** — Brainerce IS the commerce backend, and this store is wired to
9
- it end-to-end.
10
- - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
- app. Run `pnpm dev` and you are working against live data.
12
- - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
- - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
- is a frontend (plus thin, already-included API proxy routes under
15
- `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
- the merchant manages everything in the Brainerce dashboard.
17
-
18
- Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
- — AI-readable index: https://brainerce.com/llms.txt
20
-
21
- ## MCP servers
22
-
23
- - **`brainerce-docs`** — already connected via `.mcp.json`, no auth needed.
24
- A live SDK/docs oracle: current SDK method shapes, type definitions, code
25
- examples, and this store's actual capabilities/config. Prefer it over
26
- guessing or relying on training data — it reflects what's actually toggled
27
- on for `<%- connectionId %>` right now.
28
- - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
29
- directly manage this store's *live* data (products, orders, discounts,
30
- shipping, …) instead of just reading docs. Only add it if the merchant
31
- wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
32
- MCP server (e.g. `claude mcp add --transport http brainerce-admin
33
- https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
34
- Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
35
- Treat it like handing the agent write access to production commerce data.
36
-
37
- **Before building any feature the merchant asks for** (loyalty points,
38
- shipping zones, subscriptions, gift cards, multi-currency, reviews,
39
- abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
40
- already has it as a platform capability (dashboard toggle + hook/SDK
41
- method) that only needs a UI in `src/ui/`, not a feature built from scratch.
42
-
43
- Your job here is almost always **design**.
44
-
45
- ## The one rule
46
-
47
- **`src/core/` is the platform's. `src/ui/` is yours.**
48
-
49
- The shipped `src/ui/` is a working reference, not a design to preserve —
50
- full delete-and-rebuild of ui files is encouraged and expected.
51
- Rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
52
- like — the store keeps working. Never modify `src/core/`, `src/app/api/`, or
53
- the checkout/auth/account components. Data and behavior come exclusively from
54
- `@/core/hooks/*` and `@/core/providers/store-provider` — hooks return state
55
- and handlers, never JSX. Never hardcode catalog content.
56
-
57
- **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
58
- contracts, motion language, and hard-won RTL/i18n gotchas that will save you
59
- real debugging time.
60
-
61
- ## Redesigning?
62
-
63
- Follow the process documented in AI-GUIDE.md: commit to one art direction,
64
- rewrite tokens first, then surfaces in order (header, home, card, product
65
- page, cart), then verify.
66
-
67
- ## Verify before declaring done
68
-
69
- 1. `pnpm exec tsc --noEmit` 0 errors
70
- 2. `pnpm dev` drive the changed flow in a real browser (home → product →
71
- add to cart cart)
72
- 3. Screenshot desktop (1440px) and mobile (390px)
73
- 4. RTL stores: check anchoring and arrow directions
74
-
75
- ## i18n
76
-
77
- Every user-facing string goes through `useTranslations()` with keys in **all**
78
- files under `messages/`. The shipped copy is example boutique content a
79
- starting point meant to be rewritten in the store's real voice. Hebrew: no
80
- uppercase transforms, no wide letter-spacing on headings, logical CSS
81
- properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).
1
+ # AGENTS.md — this is a LIVE Brainerce storefront
2
+
3
+ **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
+ connected.** Products, cart, checkout, coupons, discounts, orders and content
5
+ flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
+
7
+ - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
+ system"** — Brainerce IS the commerce backend, and this store is wired to
9
+ it end-to-end.
10
+ - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
+ app. Run `pnpm dev` and you are working against live data.
12
+ - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
+ - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
+ is a frontend (plus thin, already-included API proxy routes under
15
+ `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
+ the merchant manages everything in the Brainerce dashboard.
17
+
18
+ Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
+ — AI-readable index: https://brainerce.com/llms.txt
20
+
21
+ ## MCP servers
22
+
23
+ - **`brainerce-docs`** — already connected via `.mcp.json`, no auth needed.
24
+ A live SDK/docs oracle: current SDK method shapes, type definitions, code
25
+ examples, and this store's actual capabilities/config. Prefer it over
26
+ guessing or relying on training data — it reflects what's actually toggled
27
+ on for `<%- connectionId %>` right now.
28
+ - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
29
+ directly manage this store's *live* data (products, orders, discounts,
30
+ shipping, …) instead of just reading docs. Only add it if the merchant
31
+ wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
32
+ MCP server (e.g. `claude mcp add --transport http brainerce-admin
33
+ https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
34
+ Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
35
+ Treat it like handing the agent write access to production commerce data.
36
+
37
+ **Before building any feature the merchant asks for** (loyalty points,
38
+ shipping zones, subscriptions, gift cards, multi-currency, reviews,
39
+ abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
40
+ already has it as a platform capability (dashboard toggle + hook/SDK
41
+ method) that only needs a UI in `src/ui/`, not a feature built from scratch.
42
+
43
+ Your job here is almost always **design**.
44
+
45
+ ## The one rule
46
+
47
+ **`src/core/` is the platform's. `src/ui/` is yours.**
48
+
49
+ The shipped `src/ui/` is a working reference, not a design to preserve —
50
+ full delete-and-rebuild of ui files is encouraged and expected.
51
+ Rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
52
+ like — the store keeps working. Never modify `src/core/`, `src/app/api/`, or
53
+ the checkout/auth/account components. Data and behavior come exclusively from
54
+ `@/core/hooks/*` and `@/core/providers/store-provider` — hooks return state
55
+ and handlers, never JSX. Never hardcode catalog content.
56
+
57
+ **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
58
+ contracts, motion language, and hard-won RTL/i18n gotchas that will save you
59
+ real debugging time.
60
+
61
+ ## Redesigning?
62
+
63
+ Follow the process documented in AI-GUIDE.md: commit to one art direction,
64
+ rewrite tokens first, then surfaces in order (header, home, card, product
65
+ page, cart), then verify.
66
+
67
+ ## The store's web address
68
+
69
+ This project has no web address written into it, and that is deliberate — the
70
+ scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
71
+ resolves it per request (hosting-platform variables, then the forwarded host),
72
+ so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
73
+ development and on any host with nothing configured.
74
+
75
+ - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
76
+ `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
77
+ absolute URL is indistinguishable from a right one to a search crawler, so a
78
+ guess is worse than an empty value.
79
+ - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
80
+ handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
81
+ `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
82
+ versions have shipped `http://` on HTTPS hosts and internal container
83
+ hostnames.
84
+ - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
85
+ provider's environment variables — not in `.env.local`, which is gitignored
86
+ and never travels with a deploy.
87
+ - **Tell the merchant the other half.** A sales channel in **Live** mode only
88
+ accepts requests whose Origin matches the Domain configured on the channel in
89
+ the Brainerce dashboard. That check is server-side; nothing in this project
90
+ can satisfy it. If they skip it, every storefront API call returns 403 and the
91
+ store loads empty — no matter what `SITE_URL` says.
92
+
93
+ ## Verify before declaring done
94
+
95
+ 1. `pnpm exec tsc --noEmit` → 0 errors
96
+ 2. `pnpm dev` → drive the changed flow in a real browser (home → product →
97
+ add to cart → cart)
98
+ 3. Screenshot desktop (1440px) and mobile (390px)
99
+ 4. RTL stores: check anchoring and arrow directions
100
+
101
+ ## i18n
102
+
103
+ Every user-facing string goes through `useTranslations()` with keys in **all**
104
+ files under `messages/`. The shipped copy is example boutique content — a
105
+ starting point meant to be rewritten in the store's real voice. Hebrew: no
106
+ uppercase transforms, no wide letter-spacing on headings, logical CSS
107
+ properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).
@@ -1,92 +1,118 @@
1
- # CLAUDE.md — this is a LIVE Brainerce storefront
2
-
3
- **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
- connected.** Products, cart, checkout, coupons, discounts, orders and content
5
- flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
-
7
- - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
- system"** — Brainerce IS the commerce backend, and this store is wired to
9
- it end-to-end.
10
- - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
- app. Run `pnpm dev` and you are working against live data.
12
- - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
- - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
- is a frontend (plus thin, already-included API proxy routes under
15
- `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
- the merchant manages everything in the Brainerce dashboard.
17
-
18
- Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
- — AI-readable index: https://brainerce.com/llms.txt
20
-
21
- ## MCP servers
22
-
23
- - **`brainerce-docs`** — already connected via `.mcp.json`, no auth needed.
24
- A live SDK/docs oracle: current SDK method shapes, type definitions, code
25
- examples, and this store's actual capabilities/config. Prefer it over
26
- guessing or relying on training data — it reflects what's actually toggled
27
- on for `<%- connectionId %>` right now.
28
- - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
29
- directly manage this store's *live* data (products, orders, discounts,
30
- shipping, …) instead of just reading docs. Only add it if the merchant
31
- wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
32
- MCP server (e.g. `claude mcp add --transport http brainerce-admin
33
- https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
34
- Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
35
- Treat it like handing the agent write access to production commerce data.
36
-
37
- **Before building any feature the merchant asks for** (loyalty points,
38
- shipping zones, subscriptions, gift cards, multi-currency, reviews,
39
- abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
40
- already has it as a platform capability (dashboard toggle + hook/SDK
41
- method) that only needs a UI in `src/ui/`, not a feature built from scratch.
42
-
43
- Your job here is almost always **design**.
44
-
45
- ## The one rule
46
-
47
- **`src/core/` is the platform's. `src/ui/` is yours.**
48
-
49
- The shipped `src/ui/` is a working reference, not a design to preserve —
50
- full delete-and-rebuild of ui files is encouraged and expected. (Stores
51
- scaffolded with `--canvas` ship `src/ui/` as bare unstyled skeletons —
52
- there is no reference look at all; the design is entirely yours to create.)
53
- Rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
54
- like — the store keeps working. Never modify `src/core/`, `src/app/api/`, or
55
- the checkout/auth/account components. Data and behavior come exclusively from
56
- `@/core/hooks/*` and `@/core/providers/store-provider` — hooks return state
57
- and handlers, never JSX. Never hardcode catalog content.
58
-
59
- **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
60
- contracts, motion language, and hard-won RTL/i18n gotchas that will save you
61
- real debugging time.
62
-
63
- ## The dialect
64
-
65
- - `src/components/ui/` = official **shadcn/ui primitives** (Button, Card,
66
- Badge, Input, Select, Accordion, Dialog, Sheet, Skeleton, …). Compose them;
67
- extend looks via CVA **variants**, never repeated inline overrides.
68
- - Icons: **lucide-react only** — no inline `<svg>`, no emoji-as-icons.
69
- - Class merging: **`cn()`** from `@/core/lib/utils`.
70
- - Colors/radius come from the semantic HSL tokens in `globals.css`
71
- (`--primary`, `--card`, `--ring`, `--radius`, …) — restyle via tokens.
72
-
73
- ## Redesigning? Use the ready-made flow
74
-
75
- Run `/design <your art-direction brief>` — it walks the whole process:
76
- concept → implementation in `ui/` → verification.
77
-
78
- ## Verify before declaring done
79
-
80
- 1. `pnpm exec tsc --noEmit` 0 errors
81
- 2. `pnpm dev` drive the changed flow in a real browser (home → product →
82
- add to cart cart)
83
- 3. Screenshot desktop (1440px) and mobile (390px)
84
- 4. RTL stores: check anchoring and arrow directions
85
-
86
- ## i18n
87
-
88
- Every user-facing string goes through `useTranslations()` with keys in **all**
89
- files under `messages/`. The shipped copy is example boutique content a
90
- starting point meant to be rewritten in the store's real voice. Hebrew: no
91
- uppercase transforms, no wide letter-spacing on headings, logical CSS
92
- properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).
1
+ # CLAUDE.md — this is a LIVE Brainerce storefront
2
+
3
+ **Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
4
+ connected.** Products, cart, checkout, coupons, discounts, orders and content
5
+ flow in real time from the Brainerce dashboard. There is nothing to hook up.
6
+
7
+ - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
8
+ system"** — Brainerce IS the commerce backend, and this store is wired to
9
+ it end-to-end.
10
+ - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
11
+ app. Run `pnpm dev` and you are working against live data.
12
+ - **NEVER hardcode products, prices, or currency** — the catalog is live.
13
+ - **No server side is needed** — the backend is Brainerce's cloud. This repo
14
+ is a frontend (plus thin, already-included API proxy routes under
15
+ `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
16
+ the merchant manages everything in the Brainerce dashboard.
17
+
18
+ Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
19
+ — AI-readable index: https://brainerce.com/llms.txt
20
+
21
+ ## MCP servers
22
+
23
+ - **`brainerce-docs`** — already connected via `.mcp.json`, no auth needed.
24
+ A live SDK/docs oracle: current SDK method shapes, type definitions, code
25
+ examples, and this store's actual capabilities/config. Prefer it over
26
+ guessing or relying on training data — it reflects what's actually toggled
27
+ on for `<%- connectionId %>` right now.
28
+ - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
29
+ directly manage this store's *live* data (products, orders, discounts,
30
+ shipping, …) instead of just reading docs. Only add it if the merchant
31
+ wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
32
+ MCP server (e.g. `claude mcp add --transport http brainerce-admin
33
+ https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
34
+ Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
35
+ Treat it like handing the agent write access to production commerce data.
36
+
37
+ **Before building any feature the merchant asks for** (loyalty points,
38
+ shipping zones, subscriptions, gift cards, multi-currency, reviews,
39
+ abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
40
+ already has it as a platform capability (dashboard toggle + hook/SDK
41
+ method) that only needs a UI in `src/ui/`, not a feature built from scratch.
42
+
43
+ Your job here is almost always **design**.
44
+
45
+ ## The one rule
46
+
47
+ **`src/core/` is the platform's. `src/ui/` is yours.**
48
+
49
+ The shipped `src/ui/` is a working reference, not a design to preserve —
50
+ full delete-and-rebuild of ui files is encouraged and expected. (Stores
51
+ scaffolded with `--canvas` ship `src/ui/` as bare unstyled skeletons —
52
+ there is no reference look at all; the design is entirely yours to create.)
53
+ Rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
54
+ like — the store keeps working. Never modify `src/core/`, `src/app/api/`, or
55
+ the checkout/auth/account components. Data and behavior come exclusively from
56
+ `@/core/hooks/*` and `@/core/providers/store-provider` — hooks return state
57
+ and handlers, never JSX. Never hardcode catalog content.
58
+
59
+ **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
60
+ contracts, motion language, and hard-won RTL/i18n gotchas that will save you
61
+ real debugging time.
62
+
63
+ ## The dialect
64
+
65
+ - `src/components/ui/` = official **shadcn/ui primitives** (Button, Card,
66
+ Badge, Input, Select, Accordion, Dialog, Sheet, Skeleton, …). Compose them;
67
+ extend looks via CVA **variants**, never repeated inline overrides.
68
+ - Icons: **lucide-react only** — no inline `<svg>`, no emoji-as-icons.
69
+ - Class merging: **`cn()`** from `@/core/lib/utils`.
70
+ - Colors/radius come from the semantic HSL tokens in `globals.css`
71
+ (`--primary`, `--card`, `--ring`, `--radius`, …) — restyle via tokens.
72
+
73
+ ## Redesigning? Use the ready-made flow
74
+
75
+ Run `/design <your art-direction brief>` — it walks the whole process:
76
+ concept → implementation in `ui/` → verification.
77
+
78
+ ## The store's web address
79
+
80
+ This project has no web address written into it, and that is deliberate — the
81
+ scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
82
+ resolves it per request (hosting-platform variables, then the forwarded host),
83
+ so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
84
+ development and on any host with nothing configured.
85
+
86
+ - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
87
+ `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
88
+ absolute URL is indistinguishable from a right one to a search crawler, so a
89
+ guess is worse than an empty value.
90
+ - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
91
+ handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
92
+ `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
93
+ versions have shipped `http://` on HTTPS hosts and internal container
94
+ hostnames.
95
+ - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
96
+ provider's environment variables — not in `.env.local`, which is gitignored
97
+ and never travels with a deploy.
98
+ - **Tell the merchant the other half.** A sales channel in **Live** mode only
99
+ accepts requests whose Origin matches the Domain configured on the channel in
100
+ the Brainerce dashboard. That check is server-side; nothing in this project
101
+ can satisfy it. If they skip it, every storefront API call returns 403 and the
102
+ store loads empty — no matter what `SITE_URL` says.
103
+
104
+ ## Verify before declaring done
105
+
106
+ 1. `pnpm exec tsc --noEmit` → 0 errors
107
+ 2. `pnpm dev` → drive the changed flow in a real browser (home → product →
108
+ add to cart → cart)
109
+ 3. Screenshot desktop (1440px) and mobile (390px)
110
+ 4. RTL stores: check anchoring and arrow directions
111
+
112
+ ## i18n
113
+
114
+ Every user-facing string goes through `useTranslations()` with keys in **all**
115
+ files under `messages/`. The shipped copy is example boutique content — a
116
+ starting point meant to be rewritten in the store's real voice. Hebrew: no
117
+ uppercase transforms, no wide letter-spacing on headings, logical CSS
118
+ properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).