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
- Overview
- Live Demo
- Architecture
- Tech Stack
- Features
- Project Structure
- Getting Started
- Environment Variables
- API Reference
- Performance Optimizations
- Deployment
- Screenshots
- Author
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.
| 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) |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DEPLOYMENT (Vercel) β
ββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββββββββββββββββββ€
β β β β
β ββββββββββββ β ββββββββββββ β βββββββββββββββββββββββββ β
β β Client β β β Admin β β β API Server β β
β β Next.js ββββΌβββ Vite ββββΌβββ Express 5 β β
β β 16.2 β β β React β β β βββββββββββββββββββ β β
β β β β β β β β β MongoDB Atlas β β β
β ββββββββββββ β ββββββββββββ β β βββββββββββββββββββ β β
β β β β βββββββββββββββββββ β β
β β β β β Cloudinary β β β
β β β β βββββββββββββββββββ β β
β β β β βββββββββββββββββββ β β
β β β β β Stripe API β β β
β β β β βββββββββββββββββββ β β
β β β βββββββββββββββββββββββββ β
ββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββββββββββββββββββ
| 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) |
| 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 |
| Category | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express 5.1 |
| Database | MongoDB (Mongoose 8) |
| Authentication | JWT + bcryptjs |
| File Storage | Cloudinary |
| Payments | Stripe |
| Nodemailer | |
| API Docs | Swagger (swagger-jsdoc + swagger-ui-express) |
| Compression | gzip (compression middleware) |
- 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
- 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
- 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
- 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
- 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
- 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
- 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
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
- Node.js β₯ 18.x
- MongoDB (local instance or MongoDB Atlas)
- Cloudinary account (cloudinary.com)
- Stripe account (stripe.com)
# 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 installOpen 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# 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# 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# API Endpoint
NEXT_PUBLIC_API_URL=http://localhost:8000/api
# Stripe Public Key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxx# API Endpoint
VITE_API_URL=http://localhost:8000/apiThe API is fully documented with Swagger. After starting the server, visit:
http://localhost:8000/api/docs
| 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 |
GET /api/products?page=1&limit=10&search=stroller&category=<id>&brand=<id>&priceMin=10&priceMax=50&sortOrder=desc
- Gzip Compression β
compressionmiddleware reduces JSON response sizes by ~80% - MongoDB Indexes β Compound indexes on
category,brand,price, andcreatedAtfields - Text Search Index β Full-text index on
name+descriptionfor fast search - Lean Queries β
.lean()on all read queries skips Mongoose hydration for faster responses - Parallel Queries β
Promise.all()for concurrentcount+findoperations
- 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 appropriatewidth/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
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)
All three apps are deployed on Vercel:
cd client
vercel --prodcd admin
vercel --prodNote:
admin/vercel.jsonincludes SPA rewrite rules for client-side routing.
cd server
vercel --prodNote:
server/vercel.jsonconfigures the Express app as a serverless function.
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
}
| 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 |
| 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 |
shoriful-dev
This project is licensed under the ISC License.
Made with β€οΈ for parents and babies everywhere
