REFERENCE

Database

Database

MySQL/MariaDB via TypeORM. Entities are in src/entities/; the connection is configured in database.module.ts.

products ──< product_images       (one row per S3 slot: main, gallery-1, cart, …)
products ──< product_stock        (one row per size, so stock is size-level)
orders   ──< order_items >── products
orders   >── customers
categories  addresses  payment_cards  preferences  feed_posts  ugc_posts

Prices are stored as price_cents integers — never floats, to avoid rounding drift. payment_cards holds display metadata only (brand + masked number); real cards belong in the processor's vault, keyed by a token.

Setup

CREATE DATABASE my_store CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'my_store'@'127.0.0.1' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON my_store.* TO 'my_store'@'127.0.0.1';

Then set DB_* in apps/api/.env and run:

npm run seed --workspace=apps/api

DB_SYNCHRONIZE=true creates and updates tables from the entities on boot. That is convenient locally but rewrites schema and can drop columns, so the app refuses to start with it enabled when NODE_ENV=production — generate real migrations before deploying.