Skip to content

Demo data

Fill an empty MongoDB with the demo catalogue, CMS pages and an admin account, and test the API with the Postman collection.

A fresh database has no products, so the storefront home page is empty. The repository ships a snapshot of the demo store’s catalogue that you can import with one command. Optional scripts in the API add CMS pages and more products.

flowchart LR
  J["scripts/data/seed_data.json"] -->|node scripts/seed-data.js| DB[(MongoDB)]
  DB -->|node scripts/export-data.js| J
  P["apps/api/scripts/*.ts"] -->|pnpm seed:pages / seed:catalog| DB
  1. Set MONGO_URI in apps/api/.env. The script reads that file, not the root .env. See Environment variables.

  2. From the repository root, run:

    Terminal window
    node scripts/seed-data.js
  3. Check the output. Each collection prints an “Importing…” line, and the run ends with a success message.

The script reads scripts/data/seed_data.json. It turns 24-character _id strings back into ObjectIds, then writes every document with an upsert (replaceOne with upsert: true). Running it twice is safe: the second run replaces the same documents and creates no duplicates.

Collection Documents What it gives you
products 34 The demo catalogue, with images and prices
categories 17 The category tree used by the shop filters and menus
brands 12 Brand filter and brand pages
producttypes 7 The product-type sections on the home page
adsbanners 3 Promotional banners
banners 2 The home-page hero slides
websiteicons 2 Logo and favicon records

scripts/export-data.js does the reverse. It reads the same collections from MONGO_URI, cleans the image fields, and overwrites scripts/data/seed_data.json:

Terminal window
node scripts/export-data.js

Use it to share a curated catalogue with your team.

Run these from apps/api. They connect with the API’s own .env.

Command Script What it does
pnpm seed:pages apps/api/scripts/seedPages.ts Creates the CMS pages and their sections (home page included). Skips any page whose slug already exists.
pnpm seed:catalog apps/api/scripts/seed-catalog-enrich.ts Ensures the product types exist, spreads products across types, adds baby and mom-care products, and refreshes banners from the root images/ folder. Needs Cloudinary keys.
pnpm reimage:dry / pnpm reimage apps/api/scripts/reimage-assets.ts Re-uploads product, brand, banner and category images to your Cloudinary account and saves the new URLs. The dry run only lists what would change.
pnpm exec tsx scripts/seed-landing-pages.ts apps/api/scripts/seed-landing-pages.ts Adds the /baby-care, /baby-food and /baby-clothing landing pages and journal posts.

collection/POSTMAN_COLLECTION.json is a ready-made Postman collection called “Turbo BabyMart API”. It has 86 requests in 18 folders: Authentication, Users, User Roles, Products, Orders, Order Workflow, Cart, Categories, Brands, Wishlist, Payments, Upload, Banners, Ads Banners, Stats & Analytics, Cash Collection, Website Config and Vendors. Import it into Postman. {{base_url}} defaults to http://localhost:8000. The login request saves the returned token into {{token}}, and the protected requests then send it for you. The full list of routes is on API endpoints.