# Build my own camera retail store on Crystallize, like Photo Store

I want a storefront for my business that works like **Photo Store** (https://photo-store-vector.superfast.shop), a demo store built on Crystallize: Every shopper sees their own store: campaigns, grids, search, the mega menu and the basket are ranked from each customer’s order history — and every position explains itself.

The content model and the wiring below are proven in that store: keep them for the features I want, and rename things to fit my trade. If a feature doesn't fit my business, leave its parts out rather than forcing it. Everything I see is mine to decide: brand, colours, typography, layout, copy and pages. Don't copy the demo's look; build my brand.

What the demo does: vector personalisation, explainable ranking, merchandising rules, typo-tolerant search, campaigns, multiple markets, multi-currency, customer price lists. It is B2C and B2B, in English; my markets and languages may differ.

## How to work with me

- You need to run commands, edit files and use MCP tools. If you can't (for example in a plain chat), tell me, and suggest I paste this prompt into Claude Code, Cursor or another coding agent instead.
- Ask your questions a few at a time (three to five), in the order of the steps below, and suggest a sensible default for each so I can just say yes. Ask each thing once, even where two lists overlap, and ask the ones that change the build first. Don't start a step before the one before it is done.
- The technical detail below is for you. Talk to me in plain words, and explain a choice only when I need to make it.
- Keep the folder empty until step 5, apart from `.env.local`.
- Never ask me to paste an access token secret into the chat, and tell me not to paste a filled-in command or its output either. Tell me which command to run or which file to put it in, and I'll do it.
- Before you create or change anything in Crystallize, show me the plan (shapes, pieces, topics, price variants, markets) and wait for my yes. Before an import, show me a sample of five items.
- Use the Crystallize skills (the `skills` MCP tool, or the use-crystallize plugin) for how-to: `content-model`, `information-architecture`, `taxonomy`, `data-creation`, `mass-operations`, `pricing`, `query`, `mutation`, `js-api-client`, `responsive-images`, `payments`, and when this store needs them `subscriptions`, `bookable-resources`, `vector-ranking` and `permissions`. Where this prompt and a skill disagree, the skill wins. Check the live schemas with the MCP instead of guessing field names.
- When something I asked for isn't possible in Crystallize the way I pictured it, say so and offer the closest thing that is.
- **The storefront never reads from the Core API on customer-facing pages.** Products, public prices, stock and content come from the Discovery API and the Catalogue API; confidential prices (negotiated B2B price lists) from the Catalogue API on the server.
- **Use the Shop API for everything about customers:** carts, checkout, customers, orders (including orders created directly, such as renewals), order meta, pipeline stages, payments and subscription contracts. Take the customer identifier from the server session, never from the browser. The Core API is for setup scripts, back-office tools, scheduled jobs and what the Shop API can't do, always on the server and never once per page view.

## Step 1: Crystallize tenant, tokens and MCP

Ask me:
1. Do I have a Crystallize account and a tenant for this store? If not, I sign up for free at https://app.crystallize.com/signup and create an empty tenant. Ask for its **tenant identifier**.
2. Do I have access tokens? If not, tell me: in the Crystallize App, go to **Settings → Access Tokens → Generate a new token**, name it, and keep the ID and the secret (the secret is shown once). A token acts with its user's role, so while we build, that user needs to be Tenant Admin (or have a role that can write shapes, pieces, topics, items and prices and run mass operations). Once the store is built, switch the MCP to a token from a read-only user.
3. Is the Crystallize MCP connected, with write access? Check that you have its write tools (`run-mass-operation`, `mutate-core`), not only the read tools (`tenant-overview`, `fetch-content-model`): with only the read tools, it was added without `?exposeWrite=true`. If it's missing, have me run this in my terminal with my own token, then restart you:
   ```bash
   npx add-mcp "https://mcp.crystallize.com/mcp?exposeWrite=true" \
     --header "X-Crystallize-Access-Token-Id: <token id>" \
     --header "X-Crystallize-Access-Token-Secret: <token secret>"
   ```
   If the MCP can't be connected in my tool, say so and fall back to scripts that call the Crystallize APIs with the tokens from `.env.local`.
   In Claude Code, also suggest the Crystallize skills: `/plugin marketplace add crystallizeapi/ai`, then `/plugin install use-crystallize@crystallize-ai`. The plugin brings its own read-only Crystallize MCP entry with placeholder credentials: keep using the one added above (and add `&exposeSkills=false` to its URL once the plugin's skills are installed).
4. Confirm the connection with `tenant-overview`, and tell me what's already in the tenant. If it isn't empty, ask whether to build next to what's there or in a fresh tenant.

The storefront needs the tenant identifier and its own credentials: an access token pair for the Shop API (server only), and a static auth token if Discovery and the Catalogue API are secured. Don't reuse the admin build token in production. Put them in `.env.local` (have me fill in the secrets) and make sure `.env*` is in `.gitignore`.

## Step 2: my business and my brand

Ask me:
- What I sell, who buys it, and what makes us different. My brand name and a one-line pitch.
- My markets, currencies and languages, and my VAT/tax setup.
- Where my product data lives today: a spreadsheet or CSV, an export from Shopify, WooCommerce or another platform, a PIM or ERP, my current website, or nothing yet. Where my product images are.
- My brand: logo (SVG if I have it), colours, typefaces, tone of voice, and two or three sites whose look I like. If I have no brand guide, propose a direction from my answers and show it before building pages.
- Where it should run: my own domain, and hosting (suggest Vercel for Next.js).

Then ask what is particular to this kind of store:

- Which brands do I carry? Which of them own a system (a lens mount, a battery or accessory platform) and which make compatible products?
- What compatibility matters in my range (camera mounts, platforms, ecosystems), and which products fit everything?
- My product types, and which ones replace each other (two cameras) and which go together (a camera and a memory card)?
- The use cases or customer interests I merchandise by (wildlife, portrait, travel, video…), and levels (beginner to pro).
- My markets, currencies and tax rates; do prices in my data include tax?
- Can I export margin, units sold in the last 30 days, ratings and stock per SKU? The ranking uses them.
- Do I have order history per customer to import (through the Shop API's `/order` `create`, never Core)? It builds each shopper's taste; without it the store starts on house ranking.
- Which campaigns am I running: name, dates, priority and which products.

## Step 3: the content model

Create this in my tenant with the MCP, renamed to fit my trade, after I have approved the plan. Keep the structure: it is what the storefront's features depend on.

Build in dependency order, since mass operations run in sequence with no rollback: pieces and shapes (empty first, then their components), topic maps (at most 30 topics per `topic/create`), price variants, markets and VAT types, the folder tree (two to four levels, five to twelve per level), and only then items. Use lowercase-hyphen identifiers. Decide now which fields are translated and which are discoverable. Restrict every item relation with `acceptedShapeIdentifiers`. Never add price or stock components to a shape: variants have them built in.

- **seo** piece: title, description, image.
- **category** (folder): intro, description, hero, seo.
- **brand** (document): description, logo, website, seo.
- **campaign** (document): headline, subheading, badge, body, `image` (a banner with no text burned in), `cta` chunk (label, url), `layout` selection (hero, tall or square; required, so set it at creation), `priority`, `valid-from`, `valid-to`, `products` relation (max 8), seo.
- **product** (product):
  - `description`, `brand` relation (exactly one, set at creation), `usp` (repeatable chunk: text), `specs` (repeatable chunk: label, value), `related` relation → product (max 8), seo.
  - Discoverable merchandising numerics: `margin` (0–1), `sold-30d`, `rating`, `campaign-boost`.
  - One variant per product with images and stock on it. SKU as `externalReference`.
- Topic maps, exactly two levels, where the root is a taste dimension and the leaf its value: `brand`, `system` (mounts or platforms, plus `system-agnostic`), `category` (product types), `usecase`, `level`, `price-tier`. Topic order on a product matters: own brand before compatible brand, strongest use case first.
- Vector vocabularies, with weights by topic position:
  - `brand`: brand [1.0, 0.5, 0.25], system [1.0, 0.5].
  - `usecase`: usecase [1.0, 0.7, 0.45, 0.3].
  - `gear`: category [1.0, 0.5], level [1.0], price tier [0.8].
  - Leave out keys that mean "no preference" (`system:system-agnostic`, `brand:other`).
- Catalogue: two levels of category folders (e.g. `/cameras/mirrorless-cameras`, `/lenses/sony-lenses`, `/accessories/tripods`), plus `/brands` and `/campaigns`.
- Pricing: net prices (four decimals), one price variant per currency. Tax is applied per market in the cart.
- Customer groups per market and segment (B2C, B2B): B2B sees prices excluding tax by default, with a VAT toggle.
- Stock: one default location.

## Step 4: my data

Import my products and content with mass operations, mapping my data onto the model: validate each file with `build-mass-operation`, run it with `run-mass-operation` and follow it with `get-mass-operation-status`. Read the operation logs, not just the task status: a task can finish as complete with failed operations, and there is no rollback. Give every upsert a `resourceIdentifier` so a re-run updates instead of duplicating, and chunk large imports. Start with a small batch, check it in the Crystallize App with me, then run the rest.

Publish every imported item in each language: the storefront only sees published versions (in a mass operation, `item/publish` needs real `itemId`s). Import images from URLs with `copyRemoteAsset`, or upload them (presigned upload, then `registerImage`). Renditions are generated in a queue: after a large import, republish once they exist, and have the storefront fall back to the original image URL while `variants` is empty. Before building pages, query Discovery once; if the tenant isn't ignited yet, run `igniteDiscoApi` (with `stacks: opensearch` if we use vector ranking), wait for the task to complete, and allow a few minutes. If I have no data yet, create a small, clearly labelled placeholder set (ten or so products) so we can build the pages, and remind me to replace it.

- The demo holds 350 products from about 43 brands in 28 folders, with 21 campaigns. Its merchandising signals, customers and orders are fictional.
- Build order: tenant (VAT, price variants, currency) → model (piece, shapes, topic maps, vocabularies) → images → catalogue → customers and order history → vectors (last).
- From me: products with brand, category, compatible system, use cases, level, price tier, net prices per currency, stock and images; margin, sales and rating (or proxies); campaigns; order history per customer.

## Step 5: the storefront

- Next.js (App Router) on Vercel, plain `fetch` GraphQL clients; Crystallize's WebP renditions go straight into `srcset`. One catch-all route resolves category, product, campaign and brand by path.
- **Discovery API** (public) for all browsing: front page, campaigns, category listings with topic facets, product pages, brand pages, search, autocomplete and recommendations.
- **Ranking per surface:** `search(context: { userTaste }, rankBy: { terms, tieBreaker })`, with a badge that says why a product is where it is, built from the shopper's taste and the product's topics. Request `explain: true` only behind a merchandiser flag (`rankExplain` is null on taste-only and `nearestTo`-only queries).
  - Field names are per-tenant enums: introspect `TenantRankByField` and `TenantRankByTieBreaker` (e.g. `fieldBoost` on `sold_30d_number`, `inStockBoost` on `stock_default`, `recency` on `publishedAt`). A numeric you facet on can't be boosted.
  - House terms: boosts on sales (0.55), margin (0.35), rating (0.3), campaign boost (0.25), in stock (0.25), and recency (0.2, 90-day half-life).
  - Front page: `tasteCosine` brand 1.7, use case 1.4, gear 0.8, plus house. Category pages: 1.4 / 1.2 / 1.0 plus house. Campaigns: taste plus campaign priority. Search: relevance 2.0 plus lighter taste.
  - Upsell ("others also buy"): the basket's taste blended over the shopper's, excluding what's in the basket and products that replace it.
  - Drop the taste terms when there is no shopper taste; never send `context: null`.
- **Similar products:** `nearestTo: { vocabulary: gear, like: { sku }, k }` (`k` replaces the page size). An anchor with no `gear` taste returns nothing, so check before rendering; to blend in stock or margin, add a `tasteCosine` term `from: nearestTo` to a `rankBy`.
- **Search:** `term` with `options: { fuzzy: { fuzziness: SINGLE, prefixLength: 1 } }`. **Autocomplete** is a prefix match per word (it doesn't fix typos): use `filters: { name: { autocomplete: { term } } }` with the same `term` and `sorting: { score: desc }`, and drop hits with score 0. If it finds nothing, fall back to single-edit fuzzy search; use double only as a last resort.
- **Shopper taste:** read the customer's orders from the Shop API (`orders(customerIdentifier)`, on the server), get each SKU's leaf topics from Discovery, and sum them, weighted by quantity (capped at 3), share of spend and recency (180-day half-life). Send one `userTaste` entry per vocabulary as `{ vocabulary, weights: { "dim:value": w }, magnitude }`, where magnitude is the square root of the sum of squared weights (a wrong magnitude raises no error, so unit-test it). Read orders with `limit: 100` and the identifier from the session, deduplicated by `coreId`.
- **Shop API:** a JWT from `/auth/token` (scopes `cart`, `order`); `hydrate` with taxes not included, the market's tax rate, `decimals: 4` and the market's price variant; then `place`, and create the order with `/order` `createFromCart` once per cart (after a verified payment webhook when paying by card).
- Env: `CRYSTALLIZE_TENANT_IDENTIFIER`, `CRYSTALLIZE_ACCESS_TOKEN_ID`, `CRYSTALLIZE_ACCESS_TOKEN_SECRET`.

Build my design, not a demo's: my typefaces, colours and tone, with pages that suit my products. Show me the home page, a category and a product page early, and adjust the design with me before building the rest.

Every page is built for search engines, answer engines and AI agents from the start, not added at the end:
- **SEO:** server-rendered HTML, one `<h1>`, a unique title and description, canonical URLs, `hreflang` per language, a sitemap and `robots.txt`, and clean, translated paths.
- **Structured data:** JSON-LD on every page that has a subject: `Organization` and `WebSite` (with a `SearchAction`) on the home page, `Product` with `Offer` (price, currency, availability) on product pages, `BreadcrumbList` on categories and products, `Article` or `Recipe` on content. Generate it from the same data as the page.
- **GEO, for answer engines and agents:** `/llms.txt` (an H1, a summary, links to every section), `/llms-full.txt`, and a Markdown twin of every page (its URL plus `.md`, or `Accept: text/markdown`), with prices, stock and facts written out in plain sentences.
- **Agents can act, not only read:** register the store's actions (search, add to cart, check availability) with WebMCP (`navigator.modelContext.registerTool`, or annotated forms), and keep the accessibility tree clean: semantic HTML, labelled controls, real buttons and links.
- **Fast and stable:** responsive images from Crystallize, no layout shift (reserve space for images and late content), little client JavaScript. Aim for 100 in every Lighthouse category (Performance, Accessibility, Best Practices, SEO; heavy 3D or video pages may score lower on performance) and pass every Agentic Browsing check.

## Step 6: run it, then ship it

Run it locally and walk me through each feature above with my own data. Fix what I find. Before you call it done, run Lighthouse on the home page, a category and a product page (`npx lighthouse <url> --only-categories=performance,accessibility,best-practices,seo,agentic-browsing`), validate the JSON-LD (https://validator.schema.org), open `/llms.txt` and a page's `.md` twin, and fix what falls short. Deploy only when I ask: set the same environment variables on the host, point my domain, and give me the live URL.

## Watch out for

- Vector ranking must be enabled for the tenant, then indexed with `igniteDiscoApi(stacks: opensearch)`: poll the task until complete and allow a few minutes. Detect the capability by checking that `__type(name: "RankByInput")` is non-null, not by error text; `ExperimentalFeaturesNotAvailableError` means ranking isn't enabled.
- Vectors go last, in this order: vocabulary (`upsertVocabulary` replaces it whole) → `setItemTaste` (it writes the draft and empties variant components) → rewrite variant components → `publishItem` per item and language → `igniteDiscoApi(stacks: opensearch)`. After the first index, pass the vocabulary as an unquoted enum.
- Topic maps must be exactly two levels for the path-to-taste-key rule (or store the taste key in each topic's meta); share the taxonomy code between the setup scripts and the storefront.
- Pass required components (the brand relation, the layout selection) when creating items, not afterwards.
- Create shapes empty first, then add their components, so relations and pieces resolve.
- Changing a price later needs `modifyProductVariantPrice` and a republish.
- Keep four-decimal net prices and `decimals: 4` in the Shop API, or basket totals are off by pennies.
- Under `rankBy`, `term` still decides which items match; only a `relevance` term makes the text match affect the order. Don't pass `sorting` with ranking; page ranked lists with `skip` and `limit` inside the rerank window (500 by default). Double fuzziness on full search matches nearly everything.
- Discovery rejects explicit `null` variables: leave them out.
- Don't invent facts about my business (prices, stock, certifications, delivery promises). Ask, or leave a clearly marked placeholder.

And for every Crystallize store, from the skills:
- **Orders:** create and change them through the Shop API `/order` (`createFromCart`, `create`, `setMeta` with `merge: true`, `addToStage`, `setPayments`). Editing an order in Core adds a duplicate to the Shop API's list. Read a customer's orders with the identifier from the session, `limit: 100`, grouped by `coreId` (keep the newest). Seed order history through `/order` `create`, not Core `registerOrder`. The order id is the cart id; don't call `fulfill` after `createFromCart`.
- **Payments:** create the order from the payment provider's verified webhook, never from the browser, once per cart.
- **Cart meta** goes in `hydrate(input: { meta })`; `hydrate` is the whole cart, so send every line each time.
- **Images:** serve them straight from Crystallize (not through an image optimizer such as `next/image` in its default setup): a WebP `srcset` from the returned `variants` with an accurate `sizes`, falling back to the original URL while renditions are missing. Replace an image by uploading a new one, not with `registerImageRevision`.
- **Ranking (if the store ranks per shopper):** check that `__type(name: "RankByInput")` exists; pass `context` as a variable, with `userTaste` entries of `{ vocabulary, weights, magnitude }` (magnitude = the square root of the sum of squared weights); `tieBreaker` is required; don't combine `sorting` with ranking, and page with `skip` and `limit` inside the rerank window; introspect `TenantRankByField` for field names; leave `context` out when there's no taste; use `explain: true` only for tuning.
- **Bookings (if the store books):** durations are in seconds; the role needs the `bookingPolicies` permission; put the customer on the cart before `bookSkuItem`; every `hydrate` must resend each booked line with its window and unit, or the booking is cancelled; remove a booking by re-hydrating without it.

## Done when

- My tenant has the content model above with my products, prices and images in it.
- The storefront runs on my domain in my brand, and every feature I chose works with my data: we have clicked through each one together.
- Lighthouse scores close to 100 in every category and every Agentic Browsing check passes on the home, category and product pages.
- I know how to add a product, change a price and publish, in the Crystallize App.
