Skip to content

Products

The Products app lets sellers create, manage, and sell digital and physical products. It provides a full product catalog with media galleries, downloadable files, specifications, order tracking, and revenue analytics.

  • Create digital or physical products with pricing and compare-at pricing
  • Media gallery management (images and videos)
  • Downloadable file attachments for digital products
  • Key-value specification pairs (e.g., Format: PDF)
  • Draft / Published / Inactive lifecycle
  • Order tracking with status management
  • Dashboard stats: total products, published count, sales, and revenue
RoutePurpose
/business/apps/productsDashboard with stats cards, quick nav, and recent products list
/business/apps/products/newCreate product form (title, description, type, pricing, thumbnail)
/business/apps/products/[id]Product detail view with media, files, specs, and orders sections

The main page displays four stat cards (Total Products, Published, Total Sales, Revenue) and a quick-nav grid linking to product management sections. Below that, the five most recent products are listed with thumbnail, title, type, sales count, price, and status badge.

The creation form uses sveltekit-superforms with Zod validation (createProductSchema). Fields include title, description, product type (digital/physical), price, compare price, and thumbnail URL.

The detail page shows full product info and provides inline management for three sub-resources via dialog modals:

  • Media — add/remove images and videos
  • Files — add/remove downloadable files (title + file path)
  • Specifications — add/remove key-value pairs

It also lists orders for the product and supports publish and delete actions.

TableDescription
ext_products.productsCore product record (title, slug, price, type, status, seller_id)
ext_products.product_mediaImage/video gallery items linked to a product
ext_products.product_filesDownloadable file attachments
ext_products.product_specificationsKey-value specification pairs
ext_products.product_ordersPurchase orders with buyer, amount, and status
  • Product — id, seller_id, title, slug, description, price, compare_price, type (digital | physical), status (draft | published | inactive), thumbnail_url, sales_count, rating_avg, rating_count
  • ProductWithDetails — Product with nested files, media, and specifications arrays
  • ProductOrder — id, product_id, buyer_id, seller_id, amount, status (pending | completed | refunded)
  • ProductStats — total_products, published_products, total_sales, total_revenue
ComponentLocation
Product list pagesrc/routes/(app)/business/apps/products/+page.svelte
Create product formsrc/routes/(app)/business/apps/products/new/+page.svelte
Product detail + dialogssrc/routes/(app)/business/apps/products/[id]/+page.svelte

All server-side logic is in $lib/apps/products/services/index.js:

  • getSellerStats(userId) — aggregate stats for the dashboard
  • listMyProducts(userId, filters) — paginated product listing
  • createProduct(userId, data) — create a new product
  • getProduct(id) — fetch product with details (files, media, specs)
  • publishProduct(id) / deleteProduct(id) — lifecycle management
  • addMedia() / removeMedia() / addFile() / removeFile() / addSpecification() / removeSpecification() — sub-resource CRUD
  • listOrders(userId) — fetch seller orders

The [id] detail page exposes multiple SvelteKit form actions: publish, delete, add-media, remove-media, add-file, remove-file, add-spec, and remove-spec. All actions require authentication and use progressive enhancement.