Thanks to visit codestin.com
Credit goes to github.com

Skip to content

E-Dukaan is a Node.js e-commerce backend API built with Express and MongoDB. Features JWT auth, Stripe payments, shopping cart, order management, email verification, and production-ready security middleware for scalable online stores.

Notifications You must be signed in to change notification settings

faizan-ahmad5/e-dukaan-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ E-Dukaan: Enterprise E-Commerce Backend API

A robust, scalable, and secure e-commerce backend built with modern Node.js & MongoDB stack.


🌟 Overview

E-Dukaan is an enterprise-grade e-commerce backend API designed for modern web applications. Built with Node.js and Express, it provides comprehensive functionality for online stores, marketplaces, and e-commerce platforms with production-ready security, monitoring, and scalability features.

✨ Key Highlights

  • πŸ”’ Enterprise Security: Multi-layer security with rate limiting, input validation, and XSS protection
  • πŸ“Š Production Monitoring: Logging, health checks, and performance metrics
  • πŸš€ High Performance: Optimized database queries and scalable architecture
  • πŸ“± Frontend Ready: Standardized REST APIs for React, Vue, Angular, or mobile apps
  • 🌍 Flexible Environments: Dev/staging/production configs with validation
  • πŸ“§ Email Integration: Verification, password reset, and marketing emails

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • MongoDB Atlas account (or local MongoDB)
  • Git

Installation

# Clone the repository
git clone https://github.com/faizan-ahmad5/e-dukaan-backend.git
cd e-dukaan-backend

# Install dependencies
npm install

# Copy environment file
cp .env.example .env

# Configure your environment variables in .env
# (MongoDB URI, JWT secret, email, Stripe keys, etc.)

# Setup categories (recommended)
npm run setup:categories

# Seed the database with sample data (optional)
npm run seed:database

# Start development server
npm run dev

# Or start in production mode
npm start

πŸͺ Core Features

🏷️ Dynamic Category Management

  • Database-driven categories instead of fixed enums
  • Hierarchical parent-child relationships
  • SEO-friendly slugs
  • Specialized endpoints for navigation menus
  • Ultra-simple setup with Men, Women, Kids categories

πŸ” Authentication & Authorization

  • JWT-based auth
  • Role-based access control (Admin, User)
  • Email verification & password reset
  • Rate limiting & brute-force protection

πŸ‘₯ User Management

  • Registration & profile updates
  • Secure password hashing (bcrypt)
  • Role-based permissions

πŸ“¦ Product Management

  • CRUD operations
  • Product search & filtering
  • Inventory management
  • Image upload & processing (Sharp)

πŸ›’ Shopping Cart

  • Add/remove items, manage quantities
  • Persistent carts with price calculations

πŸ“ Order Management

  • Order creation, status updates, and history
  • Invoice generation

πŸ’³ Payment Integration

  • Stripe checkout & payment intents
  • Refunds & webhook handling

⭐ Reviews & Ratings

  • Review submission & moderation
  • Rating aggregation

❀️ Wishlist

  • Add/remove items
  • Move wishlist items to cart
  • Wishlist statistics

πŸ“Š API Documentation

Base URLs

Development: http://localhost:5000/api
Production: https://your-domain.com/api

Core Endpoints

System

GET    /                            # API welcome message
GET    /health                      # Health check endpoint
GET    /docs                        # API documentation

Authentication

POST   /api/auth/register            # Register user
POST   /api/auth/login               # Login
GET    /api/auth/verify-email/:token # Email verification
POST   /api/auth/resend-verification # Resend verification email
POST   /api/auth/forgot-password     # Request password reset
POST   /api/auth/reset-password/:token # Reset password

Products

GET    /api/products                 # List products
GET    /api/products/:id             # Get product by ID
POST   /api/products                 # Create product (Admin)
PUT    /api/products/:id             # Update product (Admin)
DELETE /api/products/:id             # Delete product (Admin)

Categories

GET    /api/categories               # All categories
GET    /api/categories/tree          # Category tree
GET    /api/categories/menu          # Menu categories
POST   /api/categories               # Create category (Admin)
PUT    /api/categories/:id           # Update category (Admin)
DELETE /api/categories/:id           # Delete category (Admin)

Cart & Orders

GET    /api/cart                     # Get user cart
POST   /api/cart                     # Add to cart
DELETE /api/cart/remove/:productId   # Remove item
DELETE /api/cart/clear               # Clear cart

POST   /api/orders                   # Create order
GET    /api/orders                   # Get orders
PUT    /api/orders/:id/status        # Update status (Admin)

Payments

POST   /api/payment                  # Stripe checkout

Users

GET    /api/users                    # All users (Admin)
GET    /api/users/profile/me         # Current profile
PUT    /api/users/profile            # Update profile

Reviews

POST   /api/reviews                  # New review
GET    /api/reviews/product/:id      # Reviews for product

Wishlist

GET    /api/wishlist                 # User wishlist
POST   /api/wishlist                 # Add to wishlist
DELETE /api/wishlist/remove/:id      # Remove product

πŸ”’ Security Features

  • JWT auth + role-based access
  • Multi-tier rate limiting
  • Express-validator + sanitization
  • XSS & Mongo injection protection
  • Helmet, CORS, secure headers
  • Password hashing with bcrypt
  • Email verification required
  • Audit logging for sensitive actions

🌍 Environment Configuration

NODE_ENV=development
PORT=5000

# Database
MONGODB_URI=mongodb+srv://user:[email protected]/e-dukaan

# JWT
JWT_SECRET=your_super_secure_secret
JWT_EXPIRE=30d

# Email
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
[email protected]
EMAIL_PASS=your_app_password
[email protected]

# Frontend
FRONTEND_URL=http://localhost:3000

# Stripe
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_PUBLISHABLE_KEY=pk_test_xxx

πŸ“‹ Available Scripts

# Development
npm run dev              # Start dev server with nodemon
npm run dev:debug        # Start with debugger
npm start                # Start production server

# Database
npm run setup:categories # Create default categories
npm run seed:database    # Seed sample data
npm run reset:database   # Reset DB (dev only)

πŸ“ Project Structure

e-dukaan-backend/
β”œβ”€β”€ config/                 # Config files
β”œβ”€β”€ controllers/            # Route logic
β”œβ”€β”€ middleware/             # Auth & security
β”œβ”€β”€ models/                 # Mongoose schemas
β”œβ”€β”€ routes/                 # API routes
β”œβ”€β”€ utils/                  # Helpers (logger, email, etc.)
β”œβ”€β”€ scripts/                # Seed/reset scripts
β”œβ”€β”€ uploads/                # Uploaded files
└── server.mjs              # App entry

πŸ“ˆ Performance & Monitoring

  • Indexed DB queries
  • Response compression
  • /health endpoint
  • Sentry integration ready
  • Uptime monitoring support
  • Order/user/revenue metrics

🀝 Contributing

  1. Fork repo
  2. Create feature branch (git checkout -b feature/new)
  3. Commit changes (git commit -m "feat: new feature")
  4. Push & open PR

Code Style

  • Clean & readable
  • Follow conventional commits

πŸ“ž Contact

Developer: Faizan Ahmad


πŸ“„ License

MIT Β© Faizan Ahmad

About

E-Dukaan is a Node.js e-commerce backend API built with Express and MongoDB. Features JWT auth, Stripe payments, shopping cart, order management, email verification, and production-ready security middleware for scalable online stores.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published