Skip to content

shoriful-dev/Babymart_eCommerce_Client

Repository files navigation

BabyMart

🍼 BabyMart β€” Full-Stack E-Commerce Platform

A modern, production-ready e-commerce platform for baby & children's products
Built with Next.js 16, Express 5, MongoDB, and a dedicated Admin Dashboard

BabyMart Homepage


πŸ“‹ Table of Contents


🌟 Overview

BabyMart is a complete, full-stack e-commerce solution specifically designed for baby and children's products. The platform consists of three independently deployable applications:

Application Technology Purpose
Client (Storefront) Next.js 16 + React 19 Customer-facing shopping experience
Admin Dashboard Vite + React 19 Business management & analytics
API Server Express 5 + MongoDB RESTful API backend with Swagger docs

The platform supports the complete e-commerce lifecycle β€” from product browsing and cart management to checkout via Stripe, order tracking, and administrative oversight.


πŸ”— Live Demo

App URL
πŸ›’ Client Store babymart-e-commerce-client.vercel.app
πŸ“Š Admin Dashboard babymart-e-commerce-dashboard.vercel.app
πŸ”Œ API Server https://babymart-e-commerce-server.vercel.app
πŸ“š API Docs https://babymart-e-commerce-server.vercel.app/api/docs (Swagger UI)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        DEPLOYMENT (Vercel)                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                β”‚                β”‚                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Client  β”‚  β”‚  β”‚  Admin   β”‚  β”‚  β”‚     API Server        β”‚    β”‚
β”‚  β”‚ Next.js  │──┼──│  Vite    │──┼──│  Express 5            β”‚    β”‚
β”‚  β”‚  16.2    β”‚  β”‚  β”‚  React   β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚
β”‚  β”‚          β”‚  β”‚  β”‚          β”‚  β”‚  β”‚  β”‚   MongoDB Atlas  β”‚  β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β”‚   Cloudinary     β”‚  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β”‚   Stripe API     β”‚  β”‚    β”‚
β”‚                β”‚                β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚
β”‚                β”‚                β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Client (Storefront)

Category Technology
Framework Next.js 16 (App Router + Turbopack)
Language TypeScript 5.9
UI Library React 19
Styling Tailwind CSS 4
State Management Zustand 5
Forms React Hook Form + Zod validation
Animations Framer Motion
Icons Lucide React
Payments Stripe.js
UI Components Radix UI Primitives (Dialog, Select, Tabs, etc.)
Notifications Sonner
Auth JWT (custom implementation)

Admin Dashboard

Category Technology
Build Tool Vite 7
Language TypeScript 5.8
UI Library React 19
Styling Tailwind CSS 4
Routing React Router 7
State Management Zustand 5
Charts Recharts 3
HTTP Client Axios
Forms React Hook Form + Zod
File Upload React Dropzone
Printing React To Print

API Server (Backend)

Category Technology
Runtime Node.js
Framework Express 5.1
Database MongoDB (Mongoose 8)
Authentication JWT + bcryptjs
File Storage Cloudinary
Payments Stripe
Email Nodemailer
API Docs Swagger (swagger-jsdoc + swagger-ui-express)
Compression gzip (compression middleware)

✨ Features

πŸ›’ Customer Storefront

Shopping Experience

  • Dynamic Homepage β€” Hero banners, trending products, new arrivals, best deals, seasonal promotions, and stock clearance sections
  • Smart Search β€” Real-time autocomplete with debounced API calls and trending search suggestions
  • Product Catalog β€” Advanced filtering by category, brand, and price range with pagination
  • Product Details β€” Full product pages with image zoom, ratings, descriptions, and related products
  • Category Sidebar β€” Featured categories, hot categories, quick links, shop-by-age groups, and special offers

Cart & Checkout

  • Persistent Cart β€” Add/remove items with quantity management (syncs with backend for logged-in users)
  • Wishlist β€” Save products for later with heart icon toggle
  • Stripe Checkout β€” Secure payment processing via Stripe integration
  • Order Success β€” Post-checkout confirmation with order ID and tracking info
  • Order History β€” View all past orders with detailed order breakdown

User Account

  • Registration & Login β€” JWT-based authentication with form validation
  • Profile Management β€” Update personal information and profile image
  • Address Book β€” Manage multiple shipping addresses with default selection
  • Order Tracking β€” Monitor order status from processing to delivery

Customer Support Hub

  • Help Center (/help) β€” Central FAQ page with category navigation cards
  • Shipping Info (/help/shipping) β€” Tiered shipping options, process flow, and tracking guide
  • Returns & Exchanges (/help/returns) β€” 30-day return policy, step-by-step return process, non-returnable items
  • Contact Us (/help/contact) β€” Contact info cards with validated contact form and toast notifications

Information Pages

  • About Us (/about) β€” Company story, mission, and value propositions
  • Privacy Policy (/privacy) β€” Data collection and usage policies
  • Terms of Service (/terms) β€” Legal terms and conditions

πŸ“Š Admin Dashboard

  • Analytics Dashboard β€” Revenue charts, order statistics, and KPI cards (Recharts)
  • Product Management β€” Full CRUD with Cloudinary image upload, discount percentages, stock tracking
  • Category Management β€” Create/edit categories with image upload and category types (Featured / Hot)
  • Brand Management β€” Create/edit brands with logo upload
  • Banner Management β€” Manage promotional banners with type classification
  • Order Management β€” View all orders, update order status, track fulfillment
  • User Management β€” View registered users, manage roles (admin/user)
  • Invoice Generation β€” Print-ready invoices via React To Print
  • Account Settings β€” Admin profile management
  • Responsive Sidebar β€” Collapsible sidebar with active route highlighting

πŸ”Œ API Server

  • RESTful Architecture β€” Clean separation of routes, controllers, and models
  • 12 API Modules β€” Auth, Users, Products, Categories, Brands, Banners, Orders, Cart, Wishlist, Stats, Analytics, Payments
  • JWT Authentication β€” Bearer token with role-based access control (user / admin)
  • Swagger Documentation β€” Interactive API docs at /api/docs
  • Database Indexing β€” Optimized indexes on product fields (category, brand, price, text search)
  • Gzip Compression β€” Response compression for reduced bandwidth
  • CORS Configuration β€” Environment-aware origin whitelisting
  • Error Handling β€” Centralized error middleware with async handler

πŸ“ Project Structure

babyshop-ecommerce/
β”œβ”€β”€ client/                          # Next.js 16 Storefront
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                     # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx             # Homepage (Server Component)
β”‚   β”‚   β”‚   β”œβ”€β”€ shop/                # Product catalog with filters
β”‚   β”‚   β”‚   β”œβ”€β”€ product/[id]/        # Dynamic product details
β”‚   β”‚   β”‚   β”œβ”€β”€ search/              # Search page
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                # Sign in / Sign up
β”‚   β”‚   β”‚   β”œβ”€β”€ user/                # Cart, Checkout, Orders, Profile, Wishlist
β”‚   β”‚   β”‚   β”œβ”€β”€ help/                # Help Center, Shipping, Returns, Contact
β”‚   β”‚   β”‚   β”œβ”€β”€ success/             # Post-checkout confirmation
β”‚   β”‚   β”‚   β”œβ”€β”€ about/               # About page
β”‚   β”‚   β”‚   β”œβ”€β”€ privacy/             # Privacy policy
β”‚   β”‚   β”‚   β”œβ”€β”€ terms/               # Terms of service
β”‚   β”‚   β”‚   └── api/                 # API routes (Stripe checkout)
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                # Login/Register forms
β”‚   β”‚   β”‚   β”œβ”€β”€ common/              # ProductCard, PriceContainer, etc.
β”‚   β”‚   β”‚   β”œβ”€β”€ header/              # TopHeader, MainHeader, Sidebar, Search
β”‚   β”‚   β”‚   β”œβ”€β”€ footer/              # Footer with nav links
β”‚   β”‚   β”‚   β”œβ”€β”€ home/                # Homepage sections (10 components)
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/               # Page-specific client components
β”‚   β”‚   β”‚   β”œβ”€β”€ providers/           # Context providers
β”‚   β”‚   β”‚   β”œβ”€β”€ skeleton/            # Loading skeletons
β”‚   β”‚   β”‚   └── ui/                  # Radix-based UI primitives
β”‚   β”‚   β”œβ”€β”€ lib/                     # API config, stores, utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ store.ts             # Zustand stores (cart, user, currency)
β”‚   β”‚   β”‚   β”œβ”€β”€ config.ts            # API base URL + fetch wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ authApi.ts           # Auth API functions
β”‚   β”‚   β”‚   β”œβ”€β”€ cartApi.ts           # Cart sync API
β”‚   β”‚   β”‚   β”œβ”€β”€ orderApi.ts          # Order management API
β”‚   β”‚   β”‚   β”œβ”€β”€ wishlistApi.ts       # Wishlist API
β”‚   β”‚   β”‚   └── stripe.ts            # Stripe client config
β”‚   β”‚   β”œβ”€β”€ types/                   # TypeScript interfaces
β”‚   β”‚   └── constants/               # Static data & navigation
β”‚   └── package.json
β”‚
β”œβ”€β”€ admin/                           # Vite + React Admin Dashboard
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/                   # Dashboard, Products, Categories, etc.
β”‚   β”‚   β”œβ”€β”€ components/              # Sidebar, Header, shared components
β”‚   β”‚   β”œβ”€β”€ store/                   # Zustand auth store
β”‚   β”‚   β”œβ”€β”€ hooks/                   # Custom hooks
β”‚   β”‚   └── lib/                     # Utilities
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                          # Express 5 API Server
β”‚   β”œβ”€β”€ index.js                     # Server entry point
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ db.js                    # MongoDB connection
β”‚   β”‚   β”œβ”€β”€ cloudinary.js            # Cloudinary config
β”‚   β”‚   └── swagger.js               # Swagger/OpenAPI setup
β”‚   β”œβ”€β”€ models/                      # Mongoose schemas (7 models)
β”‚   β”‚   β”œβ”€β”€ userModel.js
β”‚   β”‚   β”œβ”€β”€ productModel.js
β”‚   β”‚   β”œβ”€β”€ categoryModel.js
β”‚   β”‚   β”œβ”€β”€ brandModel.js
β”‚   β”‚   β”œβ”€β”€ bannerModel.js
β”‚   β”‚   β”œβ”€β”€ orderModel.js
β”‚   β”‚   └── cartModel.js
β”‚   β”œβ”€β”€ controllers/                 # Business logic (12 controllers)
β”‚   β”œβ”€β”€ routes/                      # API route definitions (12 routes)
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js         # JWT protect + admin guard
β”‚   β”‚   └── errorMiddleware.js        # Global error handler
β”‚   β”œβ”€β”€ utils/                       # Helper utilities
β”‚   └── package.json

πŸš€ Getting Started

Prerequisites

Installation

# 1. Clone the repository
git clone https://github.com/your-username/babyshop-ecommerce.git
cd babyshop-ecommerce

# 2. Install server dependencies
cd server
npm install

# 3. Install client dependencies
cd ../client
npm install

# 4. Install admin dependencies
cd ../admin
npm install

Running Locally

Open three terminal windows:

# Terminal 1 β€” API Server (port 8000)
cd server
npm run dev

# Terminal 2 β€” Client Storefront (port 3000)
cd client
npm run dev

# Terminal 3 β€” Admin Dashboard (port 5173)
cd admin
npm run dev

Building for Production

# Client
cd client
npm run build    # Outputs to .next/

# Admin
cd admin
npm run build    # Outputs to dist/

# Server (no build step β€” runs directly with Node.js)
cd server
npm start

πŸ” Environment Variables

Server (server/.env)

# Database
MONGO_URI=mongodb+srv://<user>:<pass>@cluster.mongodb.net/babymart

# Authentication
JWT_SECRET=your_jwt_secret_key

# Cloudinary (Image uploads)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# Stripe (Payments)
STRIPE_SECRET_KEY=sk_test_xxxx

# CORS Origins
CLIENT_URL=http://localhost:3000
ADMIN_URL=http://localhost:5173

# Environment
NODE_ENV=development
PORT=8000

Client (client/.env)

# API Endpoint
NEXT_PUBLIC_API_URL=http://localhost:8000/api

# Stripe Public Key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxx

Admin (admin/.env)

# API Endpoint
VITE_API_URL=http://localhost:8000/api

πŸ“‘ API Reference

The API is fully documented with Swagger. After starting the server, visit:

http://localhost:8000/api/docs

Core Endpoints

Method Endpoint Auth Description
Auth
POST /api/auth/register ❌ Register a new user
POST /api/auth/login ❌ Login and receive JWT
Products
GET /api/products ❌ List products (paginated, filterable)
GET /api/products/:id ❌ Get single product
POST /api/products πŸ”’ Admin Create product
PUT /api/products/:id πŸ”’ Admin Update product
DELETE /api/products/:id πŸ”’ Admin Delete product
Categories
GET /api/categories ❌ List all categories
POST /api/categories πŸ”’ Admin Create category
Brands
GET /api/brands ❌ List all brands
POST /api/brands πŸ”’ Admin Create brand
Cart
GET /api/cart πŸ”’ User Get user's cart
POST /api/cart/add πŸ”’ User Add item to cart
DELETE /api/cart/remove πŸ”’ User Remove from cart
Orders
POST /api/orders πŸ”’ User Place a new order
GET /api/orders/user/:id πŸ”’ User Get user's orders
PUT /api/orders/:id πŸ”’ Admin Update order status
Wishlist
GET /api/wishlist πŸ”’ User Get wishlist
POST /api/wishlist πŸ”’ User Toggle wishlist item
Payments
POST /api/payment πŸ”’ User Create Stripe payment intent
Analytics
GET /api/analytics πŸ”’ Admin Dashboard analytics data
GET /api/stats πŸ”’ Admin Summary statistics

Query Parameters (Products)

GET /api/products?page=1&limit=10&search=stroller&category=<id>&brand=<id>&priceMin=10&priceMax=50&sortOrder=desc

⚑ Performance Optimizations

Backend

  • Gzip Compression β€” compression middleware reduces JSON response sizes by ~80%
  • MongoDB Indexes β€” Compound indexes on category, brand, price, and createdAt fields
  • Text Search Index β€” Full-text index on name + description for fast search
  • Lean Queries β€” .lean() on all read queries skips Mongoose hydration for faster responses
  • Parallel Queries β€” Promise.all() for concurrent count + find operations

Frontend

  • Server Components β€” Homepage sections fetched and rendered on the server (zero client JS for product lists)
  • React Suspense Streaming β€” Sections stream to the browser as data becomes available
  • Turbopack β€” Next.js dev server uses Turbopack for instant HMR
  • Optimized Images β€” Next.js <Image> with lazy loading and appropriate width/height
  • Debounced Search β€” 300ms debounce on search input prevents excessive API calls
  • Zustand β€” Lightweight state management (~1KB) with persistence via localStorage
  • Code Splitting β€” Automatic route-based code splitting via Next.js App Router

Build Output

Route (app)                       Revalidate  Expire
β”Œ β—‹ /                                    β‰ˆ2m      1y    ← ISR cached
β”œ β—‹ /shop                                β‰ˆ2m      1y    ← ISR cached
β”œ Ζ’ /product/[id]                                       ← Dynamic SSR
β”œ β—‹ /help                                               ← Static
β”œ β—‹ /help/shipping                                      ← Static
β”œ β—‹ /help/returns                                       ← Static
β”œ β—‹ /help/contact                                       ← Static
β”” β—‹ /about                                              ← Static

β—‹ = Static (prerendered at build)
Ζ’ = Dynamic (rendered on demand)

🚒 Deployment

All three apps are deployed on Vercel:

Client (Next.js)

cd client
vercel --prod

Admin (Vite SPA)

cd admin
vercel --prod

Note: admin/vercel.json includes SPA rewrite rules for client-side routing.

Server (Serverless)

cd server
vercel --prod

Note: server/vercel.json configures the Express app as a serverless function.


πŸ—„ Database Schema

erDiagram
    USER ||--o{ ORDER : places
    USER ||--o{ CART : has
    USER ||--o{ WISHLIST : saves
    ORDER ||--|{ PRODUCT : contains
    PRODUCT }o--|| CATEGORY : belongs_to
    PRODUCT }o--|| BRAND : manufactured_by
    BANNER ||--o{ BANNER : displays

    USER {
        string name
        string email
        string password
        string role
        string avatar
        array addresses
    }

    PRODUCT {
        string name
        string description
        number price
        number discountPercentage
        number stock
        number averageRating
        string image
        ref category
        ref brand
        array ratings
    }

    CATEGORY {
        string name
        string image
        string categoryType
    }

    BRAND {
        string name
        string image
    }

    ORDER {
        ref user
        array items
        number totalAmount
        string status
        object shippingAddress
        string paymentMethod
    }
Loading

πŸ–Ό Screenshots

Client Pages

Page Route Description
🏠 Homepage / Hero banners, trending products, new arrivals, vendor promo
πŸ›οΈ Shop / Catalog /shop Product grid with category, brand, price filters
πŸ“¦ Product Details /product/:id Full product page with ratings and related items
πŸ›’ Cart /user/cart Itemized cart with quantity controls
πŸ’³ Checkout /user/checkout Stripe-powered secure checkout
πŸ“‹ Order History /user/orders Past orders with status tracking
❓ Help Center /help FAQ, category cards for support navigation
🚚 Shipping Info /help/shipping Shipping tiers and delivery process
↩️ Returns /help/returns 30-day return policy and step-by-step guide
πŸ“ž Contact Us /help/contact Contact form with validation

Admin Pages

Page Route
Dashboard Analytics /
Product Management /products
Category Management /categories
Brand Management /brands
Banner Management /banners
Order Management /orders
User Management /users
Invoice Viewer /invoices

πŸ‘€ Author

shoriful-dev


πŸ“„ License

This project is licensed under the ISC License.


Made with ❀️ for parents and babies everywhere

Releases

No releases published

Packages

 
 
 

Contributors

Languages