@thorprovider/create-thor-app 4.1.1 → 4.1.2
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.
- package/README.md +43 -0
- package/package.json +1 -1
- package/templates/default/.agents/AGENTS.md +22 -1
- package/templates/default/ai-validator.json +33 -2
- package/templates/default/docs/README.md +16 -0
- package/templates/default/docs/decision-matrix.md +54 -0
- package/templates/default/docs/patterns.md +102 -0
- package/templates/default/docs/project-structure.md +11 -0
- package/templates/default/docs/rules.md +29 -0
package/README.md
CHANGED
|
@@ -426,6 +426,49 @@ The package is structured for maintainability:
|
|
|
426
426
|
| `src/helpers/agents-dir.ts` | .agents/ directory generation (AGENTS.md + context/ + skills/) |
|
|
427
427
|
| `tsup.config.ts` | Build config + template bundling hook |
|
|
428
428
|
|
|
429
|
+
## How V0 is Programmed for ThorBuilder
|
|
430
|
+
|
|
431
|
+
ThorBuilder does not rely on a single prompt. V0 is guided through multiple aligned mechanisms that must stay in sync as the codebase evolves.
|
|
432
|
+
|
|
433
|
+
### Guardrail Layers
|
|
434
|
+
|
|
435
|
+
1. **Template `.agents/AGENTS.md`**
|
|
436
|
+
- Compact mission, architecture, runtime, and conflict-resolution rules
|
|
437
|
+
- Used as project-level instructions and persisted for later chat injection
|
|
438
|
+
|
|
439
|
+
2. **Template docs** (`templates/default/docs/`)
|
|
440
|
+
- `types.md` → domain contracts
|
|
441
|
+
- `commerce-api.md` → all allowed `commerce.*` methods
|
|
442
|
+
- `patterns.md` → canonical implementation patterns
|
|
443
|
+
- `rules.md` → non-negotiable constraints
|
|
444
|
+
- `project-structure.md` → file ownership and boundaries
|
|
445
|
+
- `decision-matrix.md` → fast architecture decisions when prompts create pressure to drift
|
|
446
|
+
|
|
447
|
+
3. **Validator rules** (`templates/default/ai-validator.json`)
|
|
448
|
+
- Regex-based post-generation checks that catch architectural drift
|
|
449
|
+
- Examples: backend SDK imports, raw backend fetches, env gating, alternate backend stacks
|
|
450
|
+
|
|
451
|
+
4. **Dynamic ThorBuilder prompt injection**
|
|
452
|
+
- `thor-commerce-builder/lib/thor-context.ts` injects project config, guardrail policy, and backend guidance at chat time
|
|
453
|
+
- Mode-aware: mock, incomplete real backend config, or live backend configured
|
|
454
|
+
|
|
455
|
+
### Core Programming Rules for V0
|
|
456
|
+
|
|
457
|
+
- Build a **ThorCommerce storefront**, not a generic web app
|
|
458
|
+
- Use **`commerce.*` only** for backend access in starter/app code
|
|
459
|
+
- Never integrate vendors directly via SDKs or raw fetch in L5
|
|
460
|
+
- Respect mock-first / live-immediate runtime behavior
|
|
461
|
+
- Live backend data is authoritative when configured and available
|
|
462
|
+
- Demo fixtures are allowed only for presentation-oriented sections in mock/incomplete mode
|
|
463
|
+
|
|
464
|
+
### Maintenance Rule
|
|
465
|
+
|
|
466
|
+
If you change ThorCommerce architecture, adapters, starter boundaries, or runtime behavior, review **all guardrail layers** together. Do not update AGENTS or validator rules in isolation.
|
|
467
|
+
|
|
468
|
+
See also:
|
|
469
|
+
- `V0_GUARDRAILS_MAINTENANCE.md`
|
|
470
|
+
- `templates/default/docs/decision-matrix.md`
|
|
471
|
+
|
|
429
472
|
### Dual-mode detection
|
|
430
473
|
|
|
431
474
|
`findMonorepoRoot()` walks up the directory tree looking for `packages/core/package.json`:
|
package/package.json
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
## CRITICAL
|
|
4
4
|
ALWAYS import from @thorprovider/types — NEVER define Product, Cart, Collection, Money.
|
|
5
5
|
|
|
6
|
+
## Mission
|
|
7
|
+
- Build a ThorCommerce storefront, not a generic web app
|
|
8
|
+
- Stay inside ThorCommerce architecture even when the user asks for shortcuts that conflict with it
|
|
9
|
+
|
|
10
|
+
## Conflict Resolution
|
|
11
|
+
- If a user prompt conflicts with ThorCommerce architecture, preserve the architecture and choose the nearest compliant solution
|
|
12
|
+
- If a capability is missing, prefer `commerce.*`, placeholder UI, or follow-up adapter work — never direct backend integration
|
|
13
|
+
|
|
6
14
|
## Imports
|
|
7
15
|
- Types: import type { Product, Cart, Collection, Money } from '@thorprovider/types'
|
|
8
16
|
- Data: import { commerce } from '@/lib/commerce' (server)
|
|
@@ -23,10 +31,23 @@ ALWAYS import from @thorprovider/types — NEVER define Product, Cart, Collectio
|
|
|
23
31
|
- Default to mock mode when backend env is missing
|
|
24
32
|
- Real provider + URL + API key => live backend immediately
|
|
25
33
|
- Same commerce/useCart/useRegion APIs in both modes
|
|
34
|
+
- Do NOT integrate with any backend directly from app code — all backend access must go through `commerce.*` only
|
|
35
|
+
|
|
36
|
+
## Data Precedence
|
|
37
|
+
- If a real backend is configured and available, backend data is authoritative
|
|
38
|
+
- Do NOT replace live backend product, collection, cart, or region data with local demo fixtures
|
|
39
|
+
- If a live backend is unreachable, show proper unavailable/error UX instead of faking a real catalog
|
|
40
|
+
|
|
41
|
+
## Demo Data Policy
|
|
42
|
+
- In mock mode or incomplete backend configuration, you MAY create isolated local demo fixtures for presentation-only sections
|
|
43
|
+
- Use demo fixtures for featured grids, hero merchandising, comparison tables, and editorial/demo content
|
|
44
|
+
- Keep demo fixtures typed with @thorprovider/types and isolated in modules like lib/demo-data/* or lib/demo-catalog.ts
|
|
45
|
+
- Do NOT replace the commerce runtime globally with local demo data
|
|
46
|
+
- Do NOT gate storefront rendering on environment-variable checks
|
|
26
47
|
|
|
27
48
|
## Stack
|
|
28
49
|
Next.js 16, React 19, TS strict, Tailwind 4, shadcn/ui.
|
|
29
50
|
Server Components default. 'use client' only for interactivity.
|
|
30
51
|
|
|
31
52
|
## Docs
|
|
32
|
-
docs/types.md (types), docs/patterns.md (examples).
|
|
53
|
+
docs/types.md (types), docs/patterns.md (examples), docs/rules.md (constraints), docs/commerce-api.md (methods).
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
{
|
|
9
9
|
"id": "no-backend-sdk-imports",
|
|
10
10
|
"filePattern": "**/*.{ts,tsx}",
|
|
11
|
-
"pattern": "from\\s+['\"]@medusajs/js-sdk['\"]|from\\s+['\"]@shopify/api['\"]",
|
|
12
|
-
"description": "Never import backend SDKs directly —
|
|
11
|
+
"pattern": "from\\s+['\"]@medusajs/js-sdk['\"]|from\\s+['\"]@shopify/api['\"]|from\\s+['\"]@shopify/storefront-api-client['\"]|from\\s+['\"]@bigcommerce/|from\\s+['\"]@woocommerce/|from\\s+['\"]@spree/|from\\s+['\"]@magento/",
|
|
12
|
+
"description": "Never import backend SDKs directly — all backend integration must go through commerce.* from @/lib/commerce"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"id": "no-raw-commerce-fetch",
|
|
@@ -108,12 +108,43 @@
|
|
|
108
108
|
"pattern": "createProvider\\(",
|
|
109
109
|
"description": "Never call createProvider() in app/ — import commerce from @/lib/commerce (singleton)"
|
|
110
110
|
},
|
|
111
|
+
{
|
|
112
|
+
"id": "no-env-gating-in-pages",
|
|
113
|
+
"filePattern": "app/**/*.{ts,tsx}",
|
|
114
|
+
"pattern": "isEnvConfigured\\(|process\\.env\\.NEXT_PUBLIC_COMMERCE_API_(URL|KEY)|process\\.env\\.NEXT_PUBLIC_COMMERCE_PROVIDER",
|
|
115
|
+
"description": "Do not gate storefront rendering on commerce env vars in app code — use the backend-optional runtime and commerce.*"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "no-provider-branching-in-app",
|
|
119
|
+
"filePattern": "app/**/*.{ts,tsx}",
|
|
120
|
+
"pattern": "NEXT_PUBLIC_COMMERCE_PROVIDER|commerce\\.isMock\\s*\\?|commerce\\.isMock\\s*&&|isMockMode\\s*\\?",
|
|
121
|
+
"description": "Do not create separate app-level provider branches for mock vs live — keep one storefront architecture using commerce.*"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "no-direct-backend-fetch",
|
|
125
|
+
"filePattern": "app/**/*.{ts,tsx}",
|
|
126
|
+
"pattern": "fetch\\(.*(/store/|/admin/|/api/graphql|/graphql|products|collections)",
|
|
127
|
+
"description": "Never integrate with backend endpoints directly from app code — use commerce.* methods only",
|
|
128
|
+
"required": false
|
|
129
|
+
},
|
|
111
130
|
{
|
|
112
131
|
"id": "no-thorprovider-components-import",
|
|
113
132
|
"filePattern": "**/*.{ts,tsx}",
|
|
114
133
|
"pattern": "from\\s+['\"]@thorprovider/components['\"]|from\\s+['\"]@thorprovider/providers['\"]",
|
|
115
134
|
"description": "Do not import from @thorprovider/components or @thorprovider/providers — use local providers from @/components/providers/ and shadcn/ui for UI"
|
|
116
135
|
},
|
|
136
|
+
{
|
|
137
|
+
"id": "no-alternate-backend-stacks-in-app",
|
|
138
|
+
"filePattern": "app/**/*.{ts,tsx}",
|
|
139
|
+
"pattern": "from\\s+['\"]@supabase/|from\\s+['\"]firebase|from\\s+['\"]@prisma/client['\"]|from\\s+['\"]graphql-request['\"]|from\\s+['\"]@apollo/client['\"]",
|
|
140
|
+
"description": "Do not introduce alternate backend/data clients into starter app code — preserve ThorCommerce architecture"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "no-alternate-backend-stacks-in-components",
|
|
144
|
+
"filePattern": "components/**/*.{ts,tsx}",
|
|
145
|
+
"pattern": "from\\s+['\"]@supabase/|from\\s+['\"]firebase|from\\s+['\"]@prisma/client['\"]|from\\s+['\"]graphql-request['\"]|from\\s+['\"]@apollo/client['\"]",
|
|
146
|
+
"description": "Do not introduce alternate backend/data clients into starter UI code — use commerce.* and local providers"
|
|
147
|
+
},
|
|
117
148
|
{
|
|
118
149
|
"id": "use-format-price",
|
|
119
150
|
"filePattern": "**/*.tsx",
|
|
@@ -32,6 +32,22 @@ V0 generates feature code (pages, components) on top of this frozen infrastructu
|
|
|
32
32
|
| `patterns.md` | Code templates for pages, components, cart, auth, styling |
|
|
33
33
|
| `rules.md` | Non-negotiable constraints (read before generating) |
|
|
34
34
|
| `project-structure.md` | Folder map + where to put new files |
|
|
35
|
+
| `decision-matrix.md` | Fast decisions when prompts pressure V0 to leave ThorCommerce architecture |
|
|
36
|
+
|
|
37
|
+
## Guardrail Maintenance
|
|
38
|
+
|
|
39
|
+
V0 is guided by multiple aligned layers, not a single prompt.
|
|
40
|
+
|
|
41
|
+
- `.agents/AGENTS.md` — mission, runtime, conflict resolution
|
|
42
|
+
- `docs/*.md` — types, methods, patterns, rules, structure, decisions
|
|
43
|
+
- `ai-validator.json` — regex-based architectural checks
|
|
44
|
+
- ThorBuilder prompt injection — project/runtime-specific guardrails at chat time
|
|
45
|
+
|
|
46
|
+
If the architecture changes, these layers must be reviewed together.
|
|
47
|
+
|
|
48
|
+
See maintainer documentation in `packages/create-thor-app/`:
|
|
49
|
+
- `V0_GUARDRAILS_MAINTENANCE.md`
|
|
50
|
+
- `AI_GUARDRAILS_AGENTS.md`
|
|
35
51
|
|
|
36
52
|
## Quick Import Reference
|
|
37
53
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Decision Matrix"
|
|
3
|
+
purpose: "Fast guardrail decisions for V0-native Thor Commerce starters"
|
|
4
|
+
lastReviewed: "2026-05-02"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Decision Matrix
|
|
8
|
+
|
|
9
|
+
Use this matrix when a user prompt creates pressure to leave the ThorCommerce architecture.
|
|
10
|
+
|
|
11
|
+
## Core Principle
|
|
12
|
+
|
|
13
|
+
Prefer the nearest **ThorCommerce-compliant** solution over the fastest generic Next.js solution.
|
|
14
|
+
|
|
15
|
+
## Architecture Decisions
|
|
16
|
+
|
|
17
|
+
| Situation | Do This | Never Do This |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| User asks to connect a backend | Use `commerce.*` from `@/lib/commerce` | Add vendor SDKs or raw backend fetches in app code |
|
|
20
|
+
| A needed backend capability is missing | Keep architecture intact and plan adapter work or use placeholder UI | Add a “temporary” direct backend integration |
|
|
21
|
+
| User asks to remove ThorCommerce abstractions | Keep `commerce.*`, providers, and types in place | Delete or bypass ThorCommerce architecture because a generic approach is easier |
|
|
22
|
+
| User asks for a non-ecommerce feature | Redirect toward storefront-relevant implementation if possible | Turn the starter into a generic SaaS/app platform |
|
|
23
|
+
|
|
24
|
+
## Runtime Decisions
|
|
25
|
+
|
|
26
|
+
| Situation | Do This | Never Do This |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| No backend configured | Use mock runtime and keep storefront useful | Return an empty storefront because env vars are missing |
|
|
29
|
+
| Real backend configured at project creation | Use live backend data immediately | Keep showing mock/demo data as the main source |
|
|
30
|
+
| Backend added later in settings | Keep the same `commerce.*`, `useCart()`, and `useRegion()` code paths | Rewrite pages around a second live-only architecture |
|
|
31
|
+
| Live backend unreachable | Show unavailable/error UX | Fake a real catalog with local demo data |
|
|
32
|
+
|
|
33
|
+
## Demo Data Decisions
|
|
34
|
+
|
|
35
|
+
| Situation | Do This | Never Do This |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| Brief requires vertical-specific merchandising in mock/incomplete mode | Add isolated typed demo fixtures for presentation-only sections | Replace catalog, cart, or region runtime globally with local demo data |
|
|
38
|
+
| Need homepage storytelling before backend exists | Use `lib/demo-data/*` or `lib/demo-catalog.ts` for hero/editorial sections | Build the whole storefront on ad hoc local data |
|
|
39
|
+
| Live backend is available | Treat backend data as authoritative | Override live listings/collections with demo fixtures |
|
|
40
|
+
|
|
41
|
+
## Scope Decisions
|
|
42
|
+
|
|
43
|
+
| Situation | Do This | Never Do This |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| User asks for persistence or infra not owned by ThorBuilder | Stay within the current ownership boundaries | Reimplement platform concerns already owned by v0 SDK or create-thor-app |
|
|
46
|
+
| User asks for architecture changes outside P0 scope | Preserve P0 runtime guarantees and document future work | Quietly mix P1/P3/P4 features into the starter without guardrails |
|
|
47
|
+
|
|
48
|
+
## Escalation Rule
|
|
49
|
+
|
|
50
|
+
If the user request cannot be implemented cleanly inside ThorCommerce:
|
|
51
|
+
|
|
52
|
+
1. Preserve the architecture
|
|
53
|
+
2. Use the nearest compliant fallback
|
|
54
|
+
3. Prefer adapter extension or follow-up work over direct backend shortcuts
|
|
@@ -11,6 +11,8 @@ lastReviewed: "2026-05-01"
|
|
|
11
11
|
Write storefront code against `commerce`, `useCart()`, `useRegion()`, and `useCommerce()` directly.
|
|
12
12
|
|
|
13
13
|
- Do **not** create separate mock-vs-live component trees for normal storefront UI.
|
|
14
|
+
- Do **not** integrate with any backend directly from pages, components, or route handlers.
|
|
15
|
+
- Backend access must go through `commerce.*` only.
|
|
14
16
|
- The same patterns should work in preview with mock data and later against a live backend.
|
|
15
17
|
- Provider transitions are handled by the infrastructure layer, not by per-component conditionals.
|
|
16
18
|
|
|
@@ -30,6 +32,7 @@ export default async function ProductsPage() {
|
|
|
30
32
|
|
|
31
33
|
- Server Components fetch data directly — no useEffect, no loading spinners for initial data.
|
|
32
34
|
- Retry logic is built into the adapter — no manual wrapping needed.
|
|
35
|
+
- Never call vendor SDKs or raw backend fetches here — use `commerce.*` only.
|
|
33
36
|
|
|
34
37
|
---
|
|
35
38
|
|
|
@@ -187,6 +190,105 @@ const customer = await commerce.auth.getCurrentCustomer();
|
|
|
187
190
|
|
|
188
191
|
---
|
|
189
192
|
|
|
193
|
+
## 8. Backend Integration Boundary
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
// Correct — backend access always goes through commerce.*
|
|
197
|
+
import { commerce } from '@/lib/commerce';
|
|
198
|
+
|
|
199
|
+
const products = await commerce.getProducts({ first: 12 });
|
|
200
|
+
const collection = await commerce.getCollection('featured');
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
// Wrong — never integrate with a backend directly from the app
|
|
205
|
+
import Medusa from '@medusajs/js-sdk';
|
|
206
|
+
|
|
207
|
+
const medusa = new Medusa({
|
|
208
|
+
baseUrl: process.env.NEXT_PUBLIC_COMMERCE_API_URL!,
|
|
209
|
+
publishableKey: process.env.NEXT_PUBLIC_COMMERCE_API_KEY!,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const products = await medusa.store.product.list();
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
// Wrong — never bypass adapters with raw fetch
|
|
217
|
+
const response = await fetch(`${process.env.NEXT_PUBLIC_COMMERCE_API_URL}/products`);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
- V0 must not add direct Medusa, Shopify, BigCommerce, or other backend integrations.
|
|
221
|
+
- V0 must only use the local commerce singleton: `import { commerce } from '@/lib/commerce'`.
|
|
222
|
+
- If a capability is needed, check `docs/commerce-api.md` first and call the matching `commerce.*` method.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 9. Demo Fixtures for Mock/Incomplete Mode
|
|
227
|
+
|
|
228
|
+
Use this only for presentation-oriented sections when the brief requires vertical-specific merchandising that is not yet represented by the generic mock catalog.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
// lib/demo-catalog.ts
|
|
232
|
+
import type { Product } from '@thorprovider/types';
|
|
233
|
+
|
|
234
|
+
export const demoFeaturedProducts: Product[] = [
|
|
235
|
+
// Typed demo fixtures for hero/editorial sections only
|
|
236
|
+
];
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
// app/page.tsx
|
|
241
|
+
import { commerce } from '@/lib/commerce';
|
|
242
|
+
import type { Product } from '@thorprovider/types';
|
|
243
|
+
import { demoFeaturedProducts } from '@/lib/demo-catalog';
|
|
244
|
+
import { HeroSpotlight } from '@/components/hero-spotlight';
|
|
245
|
+
import { ProductGrid } from '@/components/product-grid';
|
|
246
|
+
|
|
247
|
+
export default async function HomePage() {
|
|
248
|
+
const products: Product[] = await commerce.getProducts({ first: 8 });
|
|
249
|
+
const heroProducts = commerce.isMock === true
|
|
250
|
+
? demoFeaturedProducts
|
|
251
|
+
: products.slice(0, 4);
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<main>
|
|
255
|
+
<HeroSpotlight products={heroProducts} />
|
|
256
|
+
<ProductGrid products={products} />
|
|
257
|
+
</main>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
- Live backend data remains authoritative when configured and available.
|
|
263
|
+
- Use demo fixtures only in mock mode or incomplete backend configuration.
|
|
264
|
+
- Keep demo fixtures isolated in `lib/demo-data/*` or `lib/demo-catalog.ts`.
|
|
265
|
+
- Do not replace normal product listings, collections, cart, or region flows with demo fixtures.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 10. What NOT to Do in Backend-Optional Mode
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
// Wrong — do not gate storefront rendering on env checks
|
|
273
|
+
if (!process.env.NEXT_PUBLIC_COMMERCE_API_URL) {
|
|
274
|
+
return <div>No products yet</div>;
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
// Wrong — do not branch into a separate backend integration path
|
|
280
|
+
if (process.env.NEXT_PUBLIC_COMMERCE_PROVIDER === 'medusa') {
|
|
281
|
+
// direct vendor SDK integration
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
// Correct — same commerce.* interface in mock and live modes
|
|
287
|
+
const products = await commerce.getProducts({ first: 8 });
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
190
292
|
## Import Path Summary
|
|
191
293
|
|
|
192
294
|
| What | Import From |
|
|
@@ -40,6 +40,8 @@ lib/
|
|
|
40
40
|
commerce.ts ← Commerce singleton — FROZEN
|
|
41
41
|
env.ts ← Zod environment schema — FROZEN
|
|
42
42
|
utils.ts ← cn() + formatPrice()
|
|
43
|
+
demo-data/ ← Optional typed demo fixtures for presentation-only sections in mock/incomplete mode
|
|
44
|
+
demo-catalog.ts ← Optional single-file demo fallback for brief-specific merchandising
|
|
43
45
|
|
|
44
46
|
docs/
|
|
45
47
|
types.md ← Full @thorprovider/types reference
|
|
@@ -57,6 +59,7 @@ docs/
|
|
|
57
59
|
| Reusable UI primitive | `npx shadcn@latest add [component]` → `components/ui/` |
|
|
58
60
|
| API route | `app/api/[route]/route.ts` |
|
|
59
61
|
| Environment variables | `.env.local` |
|
|
62
|
+
| Typed demo fixtures for mock/incomplete presentation fallback | `lib/demo-data/*` or `lib/demo-catalog.ts` |
|
|
60
63
|
|
|
61
64
|
## Component Decision
|
|
62
65
|
|
|
@@ -80,8 +83,16 @@ Need a UI element?
|
|
|
80
83
|
|------|-------|--------------|
|
|
81
84
|
| `lib/commerce.ts` | Infrastructure | Never |
|
|
82
85
|
| `lib/env.ts` | Infrastructure | Never |
|
|
86
|
+
| `lib/demo-data/*` | Feature support | Yes — only for isolated presentation-only fixtures |
|
|
87
|
+
| `lib/demo-catalog.ts` | Feature support | Yes — only for isolated presentation-only fixtures |
|
|
83
88
|
| `components/providers/*` | Infrastructure | Never |
|
|
84
89
|
| `styles/tokens.css` | Brand config | Only via create-thor-app flags |
|
|
85
90
|
| `app/globals.css` | Design tokens | Only to add custom tokens |
|
|
86
91
|
| `app/**/*.tsx` | Feature code | Yes — V0 creates pages |
|
|
87
92
|
| `components/**/*.tsx` | Feature code | Yes — V0 creates components |
|
|
93
|
+
|
|
94
|
+
## Backend Access Boundary
|
|
95
|
+
|
|
96
|
+
- Never integrate with any backend directly from `app/`, `components/`, or route handlers.
|
|
97
|
+
- All commerce/backend access must go through `import { commerce } from '@/lib/commerce'`.
|
|
98
|
+
- Do not add vendor SDK clients or raw backend fetch utilities to feature code.
|
|
@@ -24,6 +24,32 @@ Non-negotiable constraints. Breaking these causes build failures, runtime crashe
|
|
|
24
24
|
| No hardcoded `#hex` / `rgb()` colors | CSS tokens enable dark mode + theming | Dark mode breaks |
|
|
25
25
|
| Use `next/link` for navigation | V0 is trained on Next.js primitives | Unnecessary abstraction |
|
|
26
26
|
| Use `next/image` for images | Optimized by default | Missing optimization |
|
|
27
|
+
| Do not fork UI into mock-vs-live implementations | Runtime already switches providers underneath the same interface | Drift, duplicated logic |
|
|
28
|
+
| Do not gate storefront rendering on backend env vars | Backend-optional mode must still produce a useful storefront | Blank demos, broken previews |
|
|
29
|
+
| If a real backend is configured and available, treat backend data as authoritative | P0 requires immediate live runtime when backend exists | Demo data masking real commerce data |
|
|
30
|
+
| Demo fixtures are only allowed in mock mode or incomplete backend configuration | Keeps the mock-to-live transition intact | Demo data overriding live runtime |
|
|
31
|
+
| If a live backend is unreachable, show unavailable/error UX instead of faking a real catalog | Prevents misleading storefront output | False representation of client catalog |
|
|
32
|
+
| Do not introduce alternate backend/data/auth clients into starter app code | ThorCommerce starters are storefronts, not generic app platforms | Stack drift, duplicated architecture |
|
|
33
|
+
| Do not remove or bypass ThorCommerce abstractions to satisfy a user shortcut | Architecture consistency beats generic Next.js convenience | Loss of adapter portability |
|
|
34
|
+
|
|
35
|
+
## Backend-Optional UX Rules
|
|
36
|
+
|
|
37
|
+
| Rule | Why | Consequence |
|
|
38
|
+
|------|-----|-------------|
|
|
39
|
+
| Do not call `isEnvConfigured()` inside pages/components to decide whether products render | Runtime mode is already resolved by infrastructure | Incorrect branching, duplicated logic |
|
|
40
|
+
| Do not return empty storefront pages just because backend env vars are missing | Mock mode must still be useful for previews and generation | Blank storefronts |
|
|
41
|
+
| Keep the same `commerce.*`, `useCart()`, and `useRegion()` APIs across mock and live modes | P0 depends on the same codebase surviving provider transitions | Rewrites when backend is connected later |
|
|
42
|
+
| Use isolated typed demo fixtures only for presentation-oriented sections in mock/incomplete mode | Allows brief-specific demos without replacing runtime commerce data | Presentation data leaking into core commerce flows |
|
|
43
|
+
| Do not silently replace unreachable live backend data with local demo fixtures | Live backend failure must remain visible | Hidden production/runtime issues |
|
|
44
|
+
|
|
45
|
+
## Stack and Scope Guardrails
|
|
46
|
+
|
|
47
|
+
| Rule | Why | Consequence |
|
|
48
|
+
|------|-----|-------------|
|
|
49
|
+
| Do not add alternate backend or data stacks such as Supabase, Firebase, Prisma, Apollo, or GraphQL request clients to starter feature code | ThorCommerce storefronts already have a defined data boundary | Generic app takeover |
|
|
50
|
+
| Do not introduce a second persistence/auth/integration architecture alongside ThorCommerce | One storefront architecture must survive project evolution | Conflicting sources of truth |
|
|
51
|
+
| Do not turn the starter into a generic SaaS or internal-tool platform | ThorBuilder exists to build ecommerce storefronts faster | Product dilution |
|
|
52
|
+
| If a request is outside current ThorCommerce capabilities, preserve architecture and use placeholders or follow-up adapter work | Keeps work incremental and production-safe | Ad hoc hacks and brittle shortcuts |
|
|
27
53
|
|
|
28
54
|
## Provider Chain (Frozen Order)
|
|
29
55
|
|
|
@@ -57,9 +83,12 @@ Never modify these — they are infrastructure:
|
|
|
57
83
|
- [ ] No `@thorprovider/components` or `@thorprovider/providers` imports?
|
|
58
84
|
- [ ] No backend SDK imports (`@medusajs/*`, `@shopify/*`)?
|
|
59
85
|
- [ ] No raw `fetch(COMMERCE_API_URL...)` calls?
|
|
86
|
+
- [ ] No env-based gating that disables storefront rendering?
|
|
87
|
+
- [ ] No alternate backend/data/auth clients (Supabase/Firebase/Prisma/Apollo/etc.) added to starter code?
|
|
60
88
|
- [ ] All prices rendered via `formatPrice()`?
|
|
61
89
|
- [ ] Using `product.handle` in URLs?
|
|
62
90
|
- [ ] No hardcoded hex/rgb colors?
|
|
63
91
|
- [ ] Types from `@thorprovider/types` (not redefined locally)?
|
|
64
92
|
- [ ] `tsc --noEmit` passes?
|
|
65
93
|
- [ ] Server components fetch; client components receive data via props?
|
|
94
|
+
- [ ] Live backend data remains authoritative when configured?
|