la-rose/README.md
semianiakavy 8c6236c8f1 feat(db): schema, migrations and idempotent seed for the catalog
Implement the data layer from docs/PLAN.md §4 (card #55):

- db/migrations/0001_init.sql: idempotent DDL for the 16 entities (category,
  product, product_category, product_image, product_variant, product_feature,
  cart, cart_item, customer, address, orders, order_item, payment, promo_code,
  content_page, delivery_option) with relations and indexes; explicit index on
  orders.number (product.slug/category.slug are unique-indexed by their keys).
- Currency BYN (R4/Q1): STORE_CURRENCY = 'BYN', money as integer minor units
  (BYN * 100), no float, no interim currency, no FX conversion.
- Idempotent seed: 14 categories (11 visible + 3 hidden visible=false, R13) and
  93 products from docs/CATALOG.md §3 (broken #59 excluded, R14) with prices,
  old prices and badges; cross-listing, images, variants, PDP fields (R9),
  store constants (CATALOG §6), 1 admin + 1 customer and 2 orders.
- scripts/{migrate,seed,verify}.ts + src/db: CLI entry points and an in-process
  Postgres verification harness (satisfies `migrate` + `seed` on a clean clone).
- db/seed/0001_seed.sql: generated single-file SQL for the platform Data Tables
  (`/db-forms`, run_sql) to converge tenant_1 without a Node process.
- Placeholder dev server + storefront currency/constants and money helpers.

Verified on a clean Postgres (PGlite): product = 93; category = 14 with
visible = 11; orders = 2; money integer BYN minor units (0 float rows).
2026-10-04 19:57:52 +00:00

4.4 KiB
Raw Permalink Blame History

Online Shop — W4C project template

A W4C project template. Creating a project from it generates a private copy of this repository in your namespace and starts the Startup Creator agent, which drives the build from this brief.

This repository is deliberately a brief, not a finished app: it ships the product specification, the project metadata and the seed assets; the tech stack chosen in the creation dialog decides the scaffold. Read SPEC.md for the full product contract — roles, routes, data model, flows, functional and non-functional requirements, and the acceptance criteria the work is checked against.

What ships in this repository

Path Purpose
README.md This file: how the template is wired and how to work in the project.
SPEC.md The product specification and acceptance criteria — the contract to build.
.gitignore Default ignores for dependencies, build output, local secrets and editor/OS cruft.
.editorconfig Shared editor defaults (UTF-8, LF, indentation) for the generated project.
.w4c/template.json Template manifest: dialog fields, starter prompt, element list (templates only).
.w4c/project.json Project metadata committed with the repository.
.w4c/diagrams/ Excalidraw architecture diagram.
.w4c/boards/roadmap.json Board columns and the seed tasks for the build.
.w4c/workflows/ The CI workflow to import into the workflows module.
db/migrations/ Idempotent SQL schema (16 tables, relations, indexes) — docs/PLAN.md §4.
db/seed/catalog.tsv The 93-product catalog from docs/CATALOG.md §3 (broken #59 excluded, R14).
src/db/ Data-layer code: migrations, idempotent seed, catalog parsing, DB client.
src/store/ Store constants (STORE_CURRENCY = 'BYN', contacts) and money helpers.
scripts/ CLI entry points: migrate, seed, verify, placeholder dev server.

See .w4c/README.md for the full .w4c/ contract.

Stack

The creation dialog records the chosen stack (and its skill pair stack-* + stack-*-quality). Scaffold with those skills and hold the work to their conventions and quality gates. The stack is not fixed here on purpose: the same brief is built on Vue 3 + Quasar, Next.js, Laravel, Phoenix, … without changing SPEC.md.

Data layer

The schema and seed for the catalog live in this repository:

pnpm install
cp .env.example .env      # point DATABASE_URL at your Postgres database
pnpm migrate              # create/upgrade the schema (idempotent)
pnpm seed                 # load 14 categories + 93 products (idempotent)
pnpm db:verify            # run migrate + seed on a throwaway Postgres and assert the counts

pnpm seed converges the database to 14 categories (11 visible + 3 hidden, R13) and 93 products from docs/CATALOG.md §3 (the broken /product/1997/ is excluded, R14). All money is stored as integer BYN minor units (price_minor, price_minor = BYN × 100) — never a float (R2/R4); the currency comes from the single constant STORE_CURRENCY = 'BYN' in src/store/constants.ts. There is no interim currency and no FX conversion.

pnpm db:verify needs no database: it runs the exact same migrations and seed against an in-process Postgres (PGlite) and fails unless product = 93, category = 14 and visible categories = 11.

Build order

Work top-down, one layer at a time, and verify each layer before starting the next:

  1. Scaffold the stack and get the empty shell running (install → dev server → commit).
  2. Product & scope — routes and the data model from SPEC.md §3–§4.
  3. Catalog & product read paths from seeded data.
  4. Cart, checkout and payment (mock provider first).
  5. Accounts and order history.
  6. Admin area.
  7. Quality — tests, CI, README quickstart, .env.example, accessibility.

The full rationale and the acceptance criteria live in SPEC.md §8–§9.

Working rules

  • One concern per commit, conventional messages (feat:, fix:, chore:, docs:, test:).
  • Money is integer minor units (priceMinor), never floating point; format with the project currency and en-US number formatting.
  • Authorize every mutation on the server; never only in the UI.
  • Never commit secrets — document them in .env.example instead.
  • Keep docs/PLAN.md, the board and .w4c/project.json in sync as the project evolves.