Skip to content

Latest commit

Β 

History

347 Commits

Folders and files

Repository files navigation

React Ecommerce Boilerplate

A production-ready, white-label e-commerce boilerplate built on a Turborepo monorepo. Clone it, configure your brand in one file, and deploy. Ships with a full storefront, admin panel, REST API, design system, and Storybook.

Products Product Detail Admin Dashboard


✦ What's included

Area Details
Storefront Home page, product listing with search/filter/sort, product detail with image gallery + variants + reviews, guest cart + authenticated cart, 3-step checkout, account area
Admin panel Dashboard with live stats, products CRUD + multi-image management, categories, orders with status updates, review moderation queue, user list
REST API NestJS β€” auth (login/register/JWT refresh), products, categories, cart, orders, reviews, users + addresses
Design System 30+ Tailwind v4 components in @react-shop/design-system, white-label CSS variables, dark mode
SDK @react-shop/sdk β€” fully typed Axios client + React Query hooks for every endpoint
White-label Edit config/branding.ts + app/brand.css β†’ entire store re-themes with zero component changes
Dark mode Class-based, persisted to localStorage, no FOUC
Guest cart Add to cart without signing in; sign-in only required at checkout
Storybook All DS components documented with live controls

Tech Stack

Frontend

Backend

  • NestJS β€” modular REST API
  • Prisma 7 β€” ORM with full relation support
  • PostgreSQL
  • JWT auth β€” access token + refresh token flow

Tooling


Project Structure

react-ecommerce/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/                    # Next.js storefront + admin panel  (port 3500)
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ (main)/         # Public routes β€” /, /products, /cart, /checkout …
β”‚   β”‚   β”‚   β”œβ”€β”€ (admin)/        # Admin routes β€” /admin, /admin/products …
β”‚   β”‚   β”‚   β”œβ”€β”€ (auth)/         # Auth routes β€” /login, /register
β”‚   β”‚   β”‚   β”œβ”€β”€ modules/        # Feature modules
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ products/   # Product list, detail, filters, image gallery
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ cart/       # Cart (guest + server)
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/   # Multi-step checkout flow
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ account/    # Profile + order history
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ admin/      # Admin screens + components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ layout/     # Header, footer, theme toggle
β”‚   β”‚   β”‚   β”‚   └── static/     # Policy pages
β”‚   β”‚   β”‚   └── providers/      # ThemeProvider, GuestCartProvider
β”‚   β”‚   └── config/
β”‚   β”‚       └── branding.ts     # ← single source of truth for branding
β”‚   β”œβ”€β”€ server/                 # NestJS REST API  (port 5001)
β”‚   β”‚   └── prisma/
β”‚   β”‚       β”œβ”€β”€ schema.prisma
β”‚   β”‚       └── seed.ts
β”‚   └── storybook/              # Component docs  (port 6006)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ design-system/          # @react-shop/design-system
β”‚   β”œβ”€β”€ sdk/                    # @react-shop/sdk
β”‚   β”œβ”€β”€ eslint-config-custom/
β”‚   └── tsconfig/
β”œβ”€β”€ scripts/
β”‚   └── setup-client.ts         # Interactive white-label wizard
└── docker-compose.yml

Quick Start

Prerequisites

  • Node.js 18+
  • pnpm 8+ β€” npm i -g pnpm
  • Docker β€” for the PostgreSQL container

1 Β· Install dependencies

git clone https://github.com/your-username/react-ecommerce.git
cd react-ecommerce
pnpm install

2 Β· Start the database

docker compose up -d

3 Β· Configure environment

The defaults work out of the box with Docker Compose:

cp apps/server/.env.example apps/server/.env
# apps/server/.env
PORT=5001
NODE_ENV=development
SECRET=dev-secret-change-in-production
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/react_ecommerce

4 Β· Run migrations + seed

pnpm --filter @react-shop/api prisma:migrate   # apply schema
pnpm --filter @react-shop/api prisma:seed      # create admin + sample data

5 Β· Start the app

pnpm dev:app
Service URL
πŸ› Storefront http://localhost:3500
βš™οΈ Admin panel http://localhost:3500/admin
πŸ”Œ REST API http://localhost:5001/api
πŸ“– Storybook http://localhost:6006

Default Accounts

Role Email Password
Admin [email protected] admin123
Customer [email protected] customer123

Storefront Pages

Route Description
/ Home β€” editorial hero, featured products, categories, newsletter
/products Listing β€” search, category pills, sort dropdown
/products/[id] Detail β€” image gallery, variant selector, reviews, add-to-cart
/categories Category grid
/new-arrivals 12 newest products
/deals Products with a compare/sale price
/cart Cart β€” guest (localStorage) or server (authenticated)
/checkout Address β†’ review β†’ confirmation
/account Profile (requires login)
/account/orders Order history (requires login)
/contact Contact form
/faq Accordion FAQ
/shipping Shipping info
/returns Returns & refunds policy
/privacy Privacy policy
/terms Terms of service

Admin Panel Pages

Route Description
/admin Dashboard β€” revenue, orders, products, pending reviews
/admin/products Product CRUD β€” create/edit modal with multi-image management
/admin/categories Category CRUD
/admin/orders All orders β€” inline status update
/admin/orders/[id] Order detail + cancel
/admin/reviews Moderation queue β€” approve / reject
/admin/users User list with role badges

REST API Reference

Base URL: http://localhost:5001/api

Auth
Method Endpoint Auth Description
POST /auth/login β€” Login β†’ { user, accessToken, refreshToken }
POST /auth/register β€” Register β†’ { user, accessToken, refreshToken }
GET /users/me βœ“ Current user profile
Products
Method Endpoint Auth Description
GET /products β€” List all products
GET /products/:id β€” Product detail
POST /products βœ“ Create product (with images)
PUT /products/:id βœ“ Update product
DELETE /products/:id βœ“ Delete product
Cart
Method Endpoint Auth Description
GET /cart βœ“ Get cart
POST /cart/items βœ“ Add item
PUT /cart/items/:id βœ“ Update quantity
DELETE /cart/items/:id βœ“ Remove item
DELETE /cart βœ“ Clear cart
Orders
Method Endpoint Auth Description
GET /orders βœ“ User's orders
POST /orders βœ“ Create order
GET /orders/:id βœ“ Order detail
PUT /orders/:id/status βœ“ Update status
PUT /orders/:id/cancel βœ“ Cancel order
GET /orders/admin/all βœ“ Admin All orders
Reviews
Method Endpoint Auth Description
GET /reviews/product/:id β€” Product reviews
POST /reviews βœ“ Submit review
GET /reviews βœ“ Admin All reviews
PUT /reviews/:id/moderate βœ“ Admin Approve / reject
Addresses
Method Endpoint Auth Description
GET /users/me/addresses βœ“ List addresses
POST /users/me/addresses βœ“ Add address

White-Labelling

Option A β€” Interactive wizard

pnpm setup:client

Prompts for store name, primary color, logo, and support email. Writes config/branding.ts, app/brand.css, and .env.local.

Option B β€” Manual

apps/web/config/branding.ts

export const branding: BrandingConfig = {
  store: {
    name: "Acme Store",
    tagline: "Quality goods, fair prices.",
    logoText: "Acme Store",
    logoAbbrev: "AC",
  },
  contact: { email: "[email protected]" },
  social: { instagram: "https://instagram.com/acme" },
  features: { darkMode: true, newsletter: true, reviews: true },
  theme: { primaryColor: "#7c3aed", primaryColorDark: "#a78bfa" },
};

apps/web/app/brand.css

:root {
  --color-primary-600: #7c3aed; /* your brand color */
  /* full primary-50 β†’ primary-900 scale */
}
.dark {
  --color-primary-600: #a78bfa;
}

Every bg-primary-*, text-primary-*, and border-primary-* utility resolves through these variables β€” no component edits needed.


SDK Usage

import { SdkProvider, useProducts, useAddToCart } from "@react-shop/sdk";

// Wrap once at the root
<SdkProvider apiConfig={{ baseURL: "http://localhost:5001" }}>
  <App />
</SdkProvider>

// Use anywhere
function ProductCard({ id }: { id: string }) {
  const { data: product } = useProduct(id);
  const { mutate: addToCart } = useAddToCart();

  return (
    <button onClick={() => addToCart({ productId: id, quantity: 1 })}>
      Add to cart β€” {product?.title}
    </button>
  );
}

Available hooks: useProducts, useProduct, useCategories, useCart, useAddToCart, useUpdateCartItem, useRemoveFromCart, useClearCart, useOrders, useOrder, useCreateOrder, useCancelOrder, useProductReviews, useAllReviews, useCreateReview, useModerateReview, useMe, useLogin, useRegister, useLogout, useAddresses, useCreateAddress, useAllUsers.


Available Scripts

# Development
pnpm dev:app          # API (5001) + storefront/admin (3500)
pnpm dev              # Everything including Storybook

# Build & lint
pnpm build            # Build all packages
pnpm lint             # Lint all packages

# Database (run from repo root)
pnpm --filter @react-shop/api prisma:migrate   # Apply migrations
pnpm --filter @react-shop/api prisma:seed      # Seed database
pnpm --filter @react-shop/api prisma:studio    # Prisma Studio GUI
pnpm --filter @react-shop/api prisma:reset     # Reset and re-seed

# Docker
docker compose up -d   # Start PostgreSQL
docker compose down    # Stop PostgreSQL

# White-label
pnpm setup:client      # Interactive brand setup wizard

Dark Mode

Dark mode is class-based (.dark on <html>). The header includes a sun/moon toggle that persists to localStorage. A blocking inline script applies the class before first paint β€” no flash of light theme on dark-preference browsers.

To change the default, edit apps/web/app/providers/ThemeProvider.tsx.


Environment Variables

apps/server/.env

Variable Default Required
PORT 5001 β€”
NODE_ENV development β€”
SECRET β€” Yes β€” JWT signing secret
DATABASE_URL β€” Yes β€” PostgreSQL connection string

apps/web/.env.local (optional)

Variable Default Description
NEXT_PUBLIC_API_URL http://localhost:5001 API base URL

Contributing

  1. Fork the repo and create a feature branch
  2. pnpm install + docker compose up -d
  3. Run pnpm dev:app and make your changes
  4. pnpm lint must pass before submitting a PR
  5. Follow conventional commits: feat:, fix:, docs:, chore:

License

MIT β€” free to use, modify, and distribute for personal and commercial projects.


Built as a white-label e-commerce boilerplate Β· MIT License

Releases

Packages

Used by

Contributors

Languages