create-brainerce-store 1.84.0 → 1.85.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 (42) hide show
  1. package/README.md +130 -92
  2. package/dist/index.js +39 -17
  3. package/messages/en.json +3 -0
  4. package/messages/he.json +3 -0
  5. package/package.json +1 -1
  6. package/templates/nextjs/base/.env.local.ejs +10 -1
  7. package/templates/nextjs/base/AGENTS.md.ejs +229 -207
  8. package/templates/nextjs/base/AI-GUIDE.md +4 -0
  9. package/templates/nextjs/base/CLAUDE.md.ejs +240 -218
  10. package/templates/nextjs/base/scripts/connect.mjs +115 -18
  11. package/templates/nextjs/base/scripts/env-file.mjs +93 -0
  12. package/templates/nextjs/base/scripts/fetch-store-info.mjs +109 -83
  13. package/templates/nextjs/base/src/app/api/auth/reset-callback/route.ts +2 -1
  14. package/templates/nextjs/base/src/app/forgot-password/page.tsx +3 -2
  15. package/templates/nextjs/base/src/app/layout.tsx.ejs +50 -21
  16. package/templates/nextjs/base/src/app/opengraph-image.tsx +5 -1
  17. package/templates/nextjs/base/src/app/reset-password/page.tsx +25 -138
  18. package/templates/nextjs/base/src/app/reset-password/reset-password-form.tsx +138 -0
  19. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +174 -137
  20. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +82 -11
  21. package/templates/nextjs/base/src/core/lib/store-name.ts.ejs +56 -0
  22. package/templates/nextjs/base/src/core/lib/use-store-name.ts +18 -0
  23. package/templates/nextjs/base/src/ui/home/hero-section.tsx +27 -27
  24. package/templates/nextjs/base/src/ui/layout/header-search.tsx +2 -2
  25. package/templates/nextjs/base/src/ui/layout/site-footer.tsx.ejs +160 -160
  26. package/templates/nextjs/base/src/ui/layout/site-header.tsx.ejs +2 -2
  27. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +374 -345
  28. package/templates/nextjs/designs/atelier/globals.css +408 -402
  29. package/templates/nextjs/designs/atelier/messages-patch/en.json +91 -96
  30. package/templates/nextjs/designs/atelier/messages-patch/he.json +91 -96
  31. package/templates/nextjs/designs/atelier/ui/cart/cart-bundle-offer.tsx +131 -128
  32. package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +2 -1
  33. package/templates/nextjs/designs/atelier/ui/cart/cart-upgrade-banner.tsx +222 -219
  34. package/templates/nextjs/designs/atelier/ui/home/category-tiles.tsx +178 -151
  35. package/templates/nextjs/designs/atelier/ui/home/hero-section.tsx +61 -31
  36. package/templates/nextjs/designs/atelier/ui/layout/header-search.tsx +2 -2
  37. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +161 -155
  38. package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +232 -227
  39. package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +271 -268
  40. package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +558 -553
  41. package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +113 -110
  42. package/templates/nextjs/designs/atelier/ui/shared/no-photo-tile.tsx +73 -0
@@ -1,218 +1,240 @@
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
- Treat it as the build spec, not a lookup desk. `get-required-features` is
25
- the functional checklist this store is measured against, and it is longer
26
- than what any art-direction brief would make you think to build.
27
- `get-critical-rules` and `get-business-flows` carry the sequences that cause
28
- incidents when reordered. `get-sdk-docs`, `get-type-definitions` and
29
- `get-code-example` give current method shapes instead of training-data
30
- guesses, and `get-store-capabilities` reports what is actually toggled on
31
- for `<%- connectionId %>` right now. Read the checklist before you start,
32
- and again before you call the work done.
33
- - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
34
- directly manage this store's *live* data (products, orders, discounts,
35
- shipping, …) instead of just reading docs. Only add it if the merchant
36
- wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
37
- MCP server (e.g. `claude mcp add --transport http brainerce-admin
38
- https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
39
- Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
40
- Treat it like handing the agent write access to production commerce data.
41
-
42
- **Before building any feature the merchant asks for** (loyalty points,
43
- shipping zones, subscriptions, gift cards, donations, multi-currency, reviews,
44
- abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
45
- already has it as a platform capability (dashboard toggle + hook/SDK
46
- method) that only needs a UI in `src/ui/`, not a feature built from scratch.
47
-
48
- ### ⛔ This storefront never holds an admin API key
49
-
50
- Everything here runs on the sales channel's PUBLIC credentials, and that is the
51
- whole security model. `.env.local` ships no secret on purpose. Anything you put
52
- in a browser-reachable app is readable by anyone who opens devtools, so an
53
- admin API key (`brainerce_*`) in this project hands the merchant's entire live
54
- store to the first person who looks. Never add one to `.env.local`, to a
55
- hosting environment variable this app reads, or to any file under `src/`.
56
-
57
- **Gift cards are where this goes wrong**, because one feature name covers two
58
- very different powers:
59
-
60
- - **Redemption is yours to build.** `applyGiftCard()`, `removeGiftCard()` and
61
- `checkGiftCardBalance()` are public storefront calls needing no key beyond
62
- the sales channel. `src/ui/cart/gift-card-input.tsx` already wires the first
63
- two into checkout. Restyle it freely.
64
- - **⛔ Issuing is not.** The `gift_cards:issue` scope mints stored value, which
65
- is real money the merchant is liable for. It belongs to the dashboard, or to
66
- server-side code on infrastructure the merchant controls. Never request that
67
- scope for this storefront, never hold a key that carries it, and never add an
68
- "issue a gift card" control to these pages. A merchant who wants to SELL gift
69
- cards sells them as an ordinary product through normal checkout, and the
70
- platform issues the card once payment clears.
71
-
72
- The same split governs every admin capability you may be tempted to reach for
73
- (creating discounts, editing inventory, refunding an order): this storefront
74
- reads and transacts as a shopper, the dashboard administers.
75
-
76
- Your job here is almost always **design**. It is never *only* design: the
77
- coverage checklist in `get-required-features` applies to a redesign exactly as
78
- it applies to a build from scratch.
79
-
80
- ## The one rule
81
-
82
- **`src/core/` is the platform's. `src/ui/` is yours.**
83
-
84
- The shipped `src/ui/` is a working reference, not a design to preserve: a full
85
- delete-and-rebuild of the *look* is encouraged and expected, and you can
86
- rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
87
- like. The store keeps working. (Stores scaffolded with `--canvas` ship
88
- `src/ui/` as bare unstyled skeletons, so there is no reference look at all and
89
- the design is entirely yours to create.) Never modify `src/core/`,
90
- `src/app/api/`, or the checkout/auth/account components. Data and behavior come
91
- exclusively from `@/core/hooks/*` and `@/core/providers/store-provider`: hooks
92
- return state and handlers, never JSX. Never hardcode catalog content.
93
-
94
- ### Rebuilding the look is free. Dropping a feature is not.
95
-
96
- Some files under `src/ui/` (and one under `src/core/`) are the ONLY place a
97
- mandatory checklist entry exists in this project. Delete one and the capability
98
- leaves the store with nothing to notice it by: no type error, no console
99
- warning, and no visual hole either, because these components auto-hide while
100
- the merchant has the feature switched off, so a deleted one and an idle one
101
- look identical on the page.
102
- These are the usual casualties of a redesign, because no art-direction brief
103
- asks for them by name:
104
-
105
- ```
106
- product/ back-in-stock-form · customization-fields · modifier-group-selector
107
- review-form · reviews-section · frequently-bought-together
108
- discount-badge · stock-badge
109
- product-client-section → the KIT "what's in the box" block
110
- core/ lib/kit.ts → the KIT stock resolver every badge and button reads
111
- cart/ reservation-countdown · coupon-input · cart-upgrade-banner
112
- cart-bundle-offer · tax-estimate-line
113
- home/ discount-banner-strip
114
- layout/ newsletter-signup · announcement-bar · region-switcher<% if (i18nEnabled) { %>
115
- language-switcher<% } %> · faq-section · rich-text-block
116
- ```
117
-
118
- Restyle them, re-lay them out, rename them, fold them into other components,
119
- split them in half: all fine. What has to survive a rebuild is the SDK call
120
- each one makes and the states it handles (loading, empty, failed, and the
121
- merchant-has-it-off state that renders nothing).
122
-
123
- ⛔ **The two KIT entries are the ones a redesign silently breaks.** A `KIT` is
124
- one product assembled from other catalog products, and three things have to
125
- survive whatever you do to the markup. (1) It is added to the cart as ONE line
126
- using the kit's own `productId`, with no `variantId` and no modifier
127
- selections; never loop `product.kitComponents` into `addToCart`, which charges
128
- the shopper twice and reserves the stock twice. (2) A kit has NO `inventory`
129
- object, so every badge and buy button must go through `resolveStockInfo` /
130
- `canPurchaseProduct` from `@/core/lib/kit`; reading `product.inventory`
131
- directly gives a kit a red "out of stock" badge beside an ENABLED buy button,
132
- or worse, renders a sold-out kit as buyable. (3) `kitComponents` is display
133
- only and arrives on the by-slug read alone, never on list responses. And do not
134
- assume a kit price is fixed: `kitPricingMode` may be `SUM` or
135
- `SUM_MINUS_PERCENT`, in which case the price is recomputed from the components
136
- on every read, so never cache one.
137
-
138
- The list is short on purpose and it is NOT the specification. It names the
139
- files people lose, not every mandatory entry. `get-required-features` is the
140
- specification, and step 1 of "Verify before declaring done" is what actually
141
- catches a loss. `git show HEAD:src/ui/<path>` brings back anything you already
142
- deleted: the scaffolder committed the tree before you touched it.
143
-
144
- **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
145
- contracts, motion language, and hard-won RTL/i18n gotchas that will save you
146
- real debugging time.
147
-
148
- ## The dialect
149
-
150
- - `src/components/ui/` = official **shadcn/ui primitives** (Button, Card,
151
- Badge, Input, Select, Accordion, Dialog, Sheet, Skeleton, …). Compose them;
152
- extend looks via CVA **variants**, never repeated inline overrides.
153
- - Icons: **lucide-react only** — no inline `<svg>`, no emoji-as-icons.
154
- - Class merging: **`cn()`** from `@/core/lib/utils`.
155
- - Colors/radius come from the semantic HSL tokens in `globals.css`
156
- (`--primary`, `--card`, `--ring`, `--radius`, …) — restyle via tokens.
157
-
158
- ## Redesigning? Use the ready-made flow
159
-
160
- Run `/design <your art-direction brief>` — it walks the whole process:
161
- concept → implementation in `ui/` → verification.
162
-
163
- ## The store's web address
164
-
165
- This project has no web address written into it, and that is deliberate — the
166
- scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
167
- resolves it per request (hosting-platform variables, then the forwarded host),
168
- so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
169
- development and on any host with nothing configured.
170
-
171
- - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
172
- `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
173
- absolute URL is indistinguishable from a right one to a search crawler, so a
174
- guess is worse than an empty value.
175
- - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
176
- handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
177
- `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
178
- versions have shipped `http://` on HTTPS hosts and internal container
179
- hostnames.
180
- - **Some hosts hide the real hostname from the app.** Platforms whose proxy
181
- forwards requests as `Host: localhost:<port>` with no `x-forwarded-host`
182
- (OpenAI Sites / `*.chatgpt.site` does this) leave the resolver blind — the
183
- request looks like it arrived on localhost. On such platforms `SITE_URL` is
184
- not optional: set it, and the resolver prefers it over any internal host it
185
- sees. Without it, server-side API calls send `Origin: http://localhost:3000`
186
- and a channel with a configured Domain rejects them with 403.
187
- - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
188
- provider's environment variables — not in `.env.local`, which is gitignored
189
- and never travels with a deploy.
190
- - **Tell the merchant the other half.** A sales channel in **Live** mode only
191
- accepts requests whose Origin matches the Domain configured on the channel in
192
- the Brainerce dashboard. That check is server-side; nothing in this project
193
- can satisfy it. If they skip it, every storefront API call returns 403 and the
194
- store loads empty — no matter what `SITE_URL` says.
195
-
196
- ## Verify before declaring done
197
-
198
- 1. **Feature coverage, first and always.** Call `get-required-features` on the
199
- `brainerce-docs` MCP server (already wired, nothing to set up) and confirm
200
- every mandatory entry is still reachable in the running store. Do this
201
- before the steps below, because if you rebuilt `src/ui/` a feature that
202
- lived only in the shipped reference is now gone, and no other check can see
203
- it: `tsc` cannot see a missing feature, and the component that used to
204
- carry it auto-hid when the merchant had not switched it on, so the page
205
- looks right either way.
206
- 2. `pnpm exec tsc --noEmit` → 0 errors
207
- 3. `pnpm dev` → drive the changed flow in a real browser (home → product →
208
- add to cart → cart)
209
- 4. Screenshot desktop (1440px) and mobile (390px)
210
- 5. RTL stores: check anchoring and arrow directions
211
-
212
- ## i18n
213
-
214
- Every user-facing string goes through `useTranslations()` with keys in **all**
215
- files under `messages/`. The shipped copy is example boutique content — a
216
- starting point meant to be rewritten in the store's real voice. Hebrew: no
217
- uppercase transforms, no wide letter-spacing on headings, logical CSS
218
- properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).
1
+ # CLAUDE.md — this is a LIVE Brainerce storefront
2
+
3
+ <% if (deferred) { %>**Not connected yet.** This project was scaffolded with
4
+ `--defer-connection`: `.env.local` holds a placeholder id, and the name the
5
+ scaffold knew is only the directory name, "<%- storeName %>". Finish with
6
+ `npm run connect` (one browser approval; it creates a store and a sales
7
+ channel if you have neither, then fetches the real store name and currency
8
+ into `.env.local`). Those are `NEXT_PUBLIC_*` values, baked in at build time:
9
+ rebuild, and restart `dev`, after connecting. Until then every API call fails
10
+ by design. Once connected, everything below applies.
11
+ <% } else { %>**Store: "<%- storeName %>" · sales channel `<%- connectionId %>` — already
12
+ connected.** Products, cart, checkout, coupons, discounts, orders and content
13
+ flow in real time from the Brainerce dashboard. There is nothing to hook up.
14
+ <% } %>
15
+ The store's display name is never hardcoded: `resolveStoreName()` /
16
+ `useStoreName()` in `src/core/lib/` resolve it from the live store, then
17
+ `NEXT_PUBLIC_STORE_NAME` (refreshed by `npm run setup`), then the scaffold
18
+ literal. Read it from there; do not paste the name into components.
19
+
20
+ - **NEVER suggest connecting this store to Shopify, WooCommerce, or "a real
21
+ system"** — Brainerce IS the commerce backend, and this store is wired to
22
+ it end-to-end.
23
+ - **NEVER build standalone HTML mockups or demo pages** — design THIS Next.js
24
+ app. Run `pnpm dev` and you are working against live data.
25
+ - **NEVER hardcode products, prices, or currency** — the catalog is live.
26
+ - **No server side is needed** — the backend is Brainerce's cloud. This repo
27
+ is a frontend (plus thin, already-included API proxy routes under
28
+ `src/app/api/`). Do not scaffold databases, auth servers, or admin panels —
29
+ the merchant manages everything in the Brainerce dashboard.
30
+
31
+ Platform docs (endpoints, SDK, integration recipes): https://brainerce.com/docs
32
+ — AI-readable index: https://brainerce.com/llms.txt
33
+
34
+ ## MCP servers
35
+
36
+ - **`brainerce-docs`** (already connected via `.mcp.json`, no auth needed).
37
+ Treat it as the build spec, not a lookup desk. `get-required-features` is
38
+ the functional checklist this store is measured against, and it is longer
39
+ than what any art-direction brief would make you think to build.
40
+ `get-critical-rules` and `get-business-flows` carry the sequences that cause
41
+ incidents when reordered. `get-sdk-docs`, `get-type-definitions` and
42
+ `get-code-example` give current method shapes instead of training-data
43
+ guesses, and `get-store-capabilities` reports what is actually toggled on
44
+ for `<%- connectionId %>` right now. Read the checklist before you start,
45
+ and again before you call the work done.
46
+ - **Brainerce Admin MCP** — opt-in, not wired up by default. Lets an agent
47
+ directly manage this store's *live* data (products, orders, discounts,
48
+ shipping, …) instead of just reading docs. Only add it if the merchant
49
+ wants that: connect `https://api.brainerce.com/api/mcp` as a remote HTTP
50
+ MCP server (e.g. `claude mcp add --transport http brainerce-admin
51
+ https://api.brainerce.com/api/mcp`) — it opens a browser to log into the
52
+ Brainerce dashboard, pick this store, and grant scoped OAuth permissions.
53
+ Treat it like handing the agent write access to production commerce data.
54
+
55
+ **Before building any feature the merchant asks for** (loyalty points,
56
+ shipping zones, subscriptions, gift cards, donations, multi-currency, reviews,
57
+ abandoned-cart recovery, etc.) — check the docs first. Brainerce likely
58
+ already has it as a platform capability (dashboard toggle + hook/SDK
59
+ method) that only needs a UI in `src/ui/`, not a feature built from scratch.
60
+
61
+ ### ⛔ This storefront never holds an admin API key
62
+
63
+ Everything here runs on the sales channel's PUBLIC credentials, and that is the
64
+ whole security model. `.env.local` ships no secret on purpose. Anything you put
65
+ in a browser-reachable app is readable by anyone who opens devtools, so an
66
+ admin API key (`brainerce_*`) in this project hands the merchant's entire live
67
+ store to the first person who looks. Never add one to `.env.local`, to a
68
+ hosting environment variable this app reads, or to any file under `src/`.
69
+
70
+ **Gift cards are where this goes wrong**, because one feature name covers two
71
+ very different powers:
72
+
73
+ - **Redemption is yours to build.** `applyGiftCard()`, `removeGiftCard()` and
74
+ `checkGiftCardBalance()` are public storefront calls needing no key beyond
75
+ the sales channel. `src/ui/cart/gift-card-input.tsx` already wires the first
76
+ two into checkout. Restyle it freely.
77
+ - **⛔ Issuing is not.** The `gift_cards:issue` scope mints stored value, which
78
+ is real money the merchant is liable for. It belongs to the dashboard, or to
79
+ server-side code on infrastructure the merchant controls. Never request that
80
+ scope for this storefront, never hold a key that carries it, and never add an
81
+ "issue a gift card" control to these pages. A merchant who wants to SELL gift
82
+ cards sells them as an ordinary product through normal checkout, and the
83
+ platform issues the card once payment clears.
84
+
85
+ The same split governs every admin capability you may be tempted to reach for
86
+ (creating discounts, editing inventory, refunding an order): this storefront
87
+ reads and transacts as a shopper, the dashboard administers.
88
+
89
+ Your job here is almost always **design**. It is never *only* design: the
90
+ coverage checklist in `get-required-features` applies to a redesign exactly as
91
+ it applies to a build from scratch.
92
+
93
+ ## The one rule
94
+
95
+ **`src/core/` is the platform's. `src/ui/` is yours.**
96
+
97
+ The shipped `src/ui/` is a working reference, not a design to preserve: a full
98
+ delete-and-rebuild of the *look* is encouraged and expected, and you can
99
+ rewrite anything under `src/ui/` and `src/app/globals.css` as boldly as you
100
+ like. The store keeps working. (Stores scaffolded with `--canvas` ship
101
+ `src/ui/` as bare unstyled skeletons, so there is no reference look at all and
102
+ the design is entirely yours to create.) Never modify `src/core/`,
103
+ `src/app/api/`, or the checkout/auth/account components. Data and behavior come
104
+ exclusively from `@/core/hooks/*` and `@/core/providers/store-provider`: hooks
105
+ return state and handlers, never JSX. Never hardcode catalog content.
106
+
107
+ ### Rebuilding the look is free. Dropping a feature is not.
108
+
109
+ Some files under `src/ui/` (and one under `src/core/`) are the ONLY place a
110
+ mandatory checklist entry exists in this project. Delete one and the capability
111
+ leaves the store with nothing to notice it by: no type error, no console
112
+ warning, and no visual hole either, because these components auto-hide while
113
+ the merchant has the feature switched off, so a deleted one and an idle one
114
+ look identical on the page.
115
+ These are the usual casualties of a redesign, because no art-direction brief
116
+ asks for them by name:
117
+
118
+ ```
119
+ product/ back-in-stock-form · customization-fields · modifier-group-selector
120
+ review-form · reviews-section · frequently-bought-together
121
+ discount-badge · stock-badge
122
+ product-client-section → the KIT "what's in the box" block
123
+ core/ lib/kit.ts → the KIT stock resolver every badge and button reads
124
+ cart/ reservation-countdown · coupon-input · cart-upgrade-banner
125
+ cart-bundle-offer · tax-estimate-line
126
+ home/ discount-banner-strip
127
+ layout/ newsletter-signup · announcement-bar · region-switcher<% if (i18nEnabled) { %>
128
+ language-switcher<% } %> · faq-section · rich-text-block
129
+ ```
130
+
131
+ Restyle them, re-lay them out, rename them, fold them into other components,
132
+ split them in half: all fine. What has to survive a rebuild is the SDK call
133
+ each one makes and the states it handles (loading, empty, failed, and the
134
+ merchant-has-it-off state that renders nothing).
135
+
136
+ ⛔ **The two KIT entries are the ones a redesign silently breaks.** A `KIT` is
137
+ one product assembled from other catalog products, and three things have to
138
+ survive whatever you do to the markup. (1) It is added to the cart as ONE line
139
+ using the kit's own `productId`, with no `variantId` and no modifier
140
+ selections; never loop `product.kitComponents` into `addToCart`, which charges
141
+ the shopper twice and reserves the stock twice. (2) A kit has NO `inventory`
142
+ object, so every badge and buy button must go through `resolveStockInfo` /
143
+ `canPurchaseProduct` from `@/core/lib/kit`; reading `product.inventory`
144
+ directly gives a kit a red "out of stock" badge beside an ENABLED buy button,
145
+ or worse, renders a sold-out kit as buyable. (3) `kitComponents` is display
146
+ only and arrives on the by-slug read alone, never on list responses. And do not
147
+ assume a kit price is fixed: `kitPricingMode` may be `SUM` or
148
+ `SUM_MINUS_PERCENT`, in which case the price is recomputed from the components
149
+ on every read, so never cache one.
150
+
151
+ The list is short on purpose and it is NOT the specification. It names the
152
+ files people lose, not every mandatory entry. `get-required-features` is the
153
+ specification, and step 1 of "Verify before declaring done" is what actually
154
+ catches a loss. `git show HEAD:src/ui/<path>` brings back anything you already
155
+ deleted: the scaffolder committed the tree before you touched it.
156
+
157
+ **Read `AI-GUIDE.md` before any redesign** — it has the full file map, hook
158
+ contracts, motion language, and hard-won RTL/i18n gotchas that will save you
159
+ real debugging time.
160
+
161
+ ## The dialect
162
+
163
+ - `src/components/ui/` = official **shadcn/ui primitives** (Button, Card,
164
+ Badge, Input, Select, Accordion, Dialog, Sheet, Skeleton, …). Compose them;
165
+ extend looks via CVA **variants**, never repeated inline overrides.
166
+ - Icons: **lucide-react only** — no inline `<svg>`, no emoji-as-icons.
167
+ - Class merging: **`cn()`** from `@/core/lib/utils`.
168
+ - Colors/radius come from the semantic HSL tokens in `globals.css`
169
+ (`--primary`, `--card`, `--ring`, `--radius`, …) — restyle via tokens.
170
+
171
+ ## Redesigning? Use the ready-made flow
172
+
173
+ Run `/design <your art-direction brief>` — it walks the whole process:
174
+ concept → implementation in `ui/` → verification.
175
+
176
+ ## The store's web address
177
+
178
+ This project has no web address written into it, and that is deliberate — the
179
+ scaffolder cannot know where you will deploy. `src/core/lib/site-url.ts`
180
+ resolves it per request (hosting-platform variables, then the forwarded host),
181
+ so canonical tags, `sitemap.xml`, `robots.txt` and JSON-LD are correct in local
182
+ development and on any host with nothing configured.
183
+
184
+ - **Never invent an address.** Do not write `NEXT_PUBLIC_SITE_URL`,
185
+ `SITE_URL`, `localhost`, or a placeholder domain into `.env.local`. A wrong
186
+ absolute URL is indistinguishable from a right one to a search crawler, so a
187
+ guess is worse than an empty value.
188
+ - **Never hand-roll an origin** from `host` / `x-forwarded-proto` in a route
189
+ handler. Call `getCanonicalSiteUrl()` (for canonical/SEO URLs) or
190
+ `getRequestOrigin()` (for the `Origin` header sent to Brainerce). Hand-rolled
191
+ versions have shipped `http://` on HTTPS hosts and internal container
192
+ hostnames.
193
+ - **Some hosts hide the real hostname from the app.** Platforms whose proxy
194
+ forwards requests as `Host: localhost:<port>` with no `x-forwarded-host`
195
+ (OpenAI Sites / `*.chatgpt.site` does this) leave the resolver blind — the
196
+ request looks like it arrived on localhost. On such platforms `SITE_URL` is
197
+ not optional: set it, and the resolver prefers it over any internal host it
198
+ sees. Without it, server-side API calls send `Origin: http://localhost:3000`
199
+ and a channel with a configured Domain rejects them with 403.
200
+ - **When the merchant gives you a real domain**, set `SITE_URL` in the hosting
201
+ provider's environment variables — not in `.env.local`, which is gitignored
202
+ and never travels with a deploy.
203
+ - **Tell the merchant the other half.** A sales channel in **Live** mode only
204
+ accepts requests whose Origin matches the Domain configured on the channel in
205
+ the Brainerce dashboard. That check is server-side; nothing in this project
206
+ can satisfy it. If they skip it, every storefront API call returns 403 and the
207
+ store loads empty — no matter what `SITE_URL` says.
208
+
209
+ ## Verify before declaring done
210
+
211
+ 1. **Feature coverage, first and always.** Call `get-required-features` on the
212
+ `brainerce-docs` MCP server (already wired, nothing to set up) and confirm
213
+ every mandatory entry is still reachable in the running store. Do this
214
+ before the steps below, because if you rebuilt `src/ui/` a feature that
215
+ lived only in the shipped reference is now gone, and no other check can see
216
+ it: `tsc` cannot see a missing feature, and the component that used to
217
+ carry it auto-hid when the merchant had not switched it on, so the page
218
+ looks right either way.
219
+ 2. `pnpm exec tsc --noEmit` → 0 errors
220
+ 3. `pnpm dev` → drive the changed flow in a real browser (home → product →
221
+ add to cart → cart)
222
+ 4. Screenshot desktop (1440px) and mobile (390px)
223
+ 5. RTL stores: check anchoring and arrow directions
224
+
225
+ ## i18n
226
+
227
+ The interface language was fixed at scaffold time by `--language` (this store:
228
+ `<%= language %>`). It decides which `messages/` ship and the `<html lang>` /
229
+ `dir` of every page, and it is the one thing `npm run connect` / `npm run
230
+ setup` do not change: they refresh the store name and currency from the live
231
+ channel, never the language. A store in the wrong language is re-scaffolded,
232
+ not adjusted.
233
+
234
+ Every user-facing string goes through `useTranslations()` with keys in **all**
235
+ files under `messages/`. The shipped copy is vertical-neutral placeholder
236
+ content — it names no product category, and it is a starting point, not a
237
+ voice: rewrite the hero, the story and the footer tagline in the merchant's
238
+ own words before calling the store done. Hebrew: no
239
+ uppercase transforms, no wide letter-spacing on headings, logical CSS
240
+ properties only (`ms-/me-`, `ps-/pe-`, `start-/end-`).