Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Megamart — Multi-Vendor E-Commerce Platform

A modern, production-grade multi-vendor marketplace built with a service-oriented architecture. Megamart enables multiple vendors to register, list products, and manage their own stores — while customers enjoy a unified shopping experience across all vendors.


Repositories

Service Description Link
megamart-backend NestJS API with multi-vendor management, event-driven processing, and full RBAC imran-binhasan/megamart-backend
megamart-storefront Next.js 16 customer-facing storefront with full shopping experience imran-binhasan/megamart-storefront
megamart-dashboard Next.js 16 dual-role dashboard for vendors and platform admins imran-binhasan/megamart-dashboard

Architecture

                          ┌─────────────────────────────────────────────┐
                          │              megamart-backend               │
                          │         NestJS 11 · PostgreSQL · RMQ       │
                          │         Redis · JWT · Cloudinary           │
                          │  ┌─────────────────────────────────────┐   │
                          │  │ Auth │ Vendors │ Products │ Orders  │   │
                          │  │ Cart │ Coupons │ Payments │ Notifs  │   │
                          │  └─────────────────────────────────────┘   │
                          └───────────────────┬─────────────────────────┘
                                              │  REST API + WebSockets
                         ┌────────────────────┼────────────────────┐
                         ▼                    ▼                    ▼
          ┌─────────────────────────┐  ┌─────────────────────────┐
          │     megamart-storefront  │  │     megamart-dashboard  │
          │     Next.js 16 · React 19│  │     Next.js 16 · React 19│
          │     Tailwind · TanStack  │  │     Tailwind · ApexCharts│
          │  ┌───────────────────┐   │  │  ┌───────────────────┐  │
          │  │ Browse · Search   │   │  │  │ Vendor Panel      │  │
          │  │ Cart · Checkout   │   │  │  │ Admin Panel       │  │
          │  │ Auth · Account    │   │  │  │ Analytics · CRM   │  │
          │  └───────────────────┘   │  │  └───────────────────┘  │
          └─────────────────────────┘  └─────────────────────────┘

Communication

  • REST API served at /api with global prefix, versioned, and documented via Swagger (/docs)
  • Event-driven via RabbitMQ for async workflows: order processing, inventory sync, notifications
  • JWT auth with access + refresh token pair, role-based guards (admin/customer/vendor)

megamart-backend — Feature Overview

The core of the platform. Fully implemented NestJS API.

Auth & Roles

  • Three user types: Customer, Vendor, Admin
  • JWT access (15m) + refresh (7d) tokens with separate secrets
  • Password hashing via Argon2id with account lockout (10 attempts → 25m lockout)
  • Social OAuth stubs (Google, Facebook)
  • Password reset flow with secure random tokens
  • Admin RBAC: role-based with scoped permissions (own / department / all)
  • Decorator-based guards: @Public(), @Auth(), @AdminOnly(), @VendorOnly(), @CustomerOnly()

Vendor Management

  • Vendor registration with shop slug validation
  • Approval workflow: pending_verificationactive (admin approval)
  • KYC document submission (business license, tax ID, owner ID, etc.)
  • Bank account information management
  • Configurable commission rate (percentage or flat)
  • Vendor dashboard stats: sales, orders, ratings, payouts

Product Management

  • Products with SKU/slug auto-generation, categories (hierarchical), brands, attributes (size/color/etc.)
  • Product images with Cloudinary upload and variant generation (thumbnail, small, medium, large)
  • Product reviews and ratings
  • Wishlist
  • Coupon/discount system with validation
  • Soft delete and restore

Cart

  • Cross-vendor cart (add products from multiple vendors)
  • Price snapshots for change detection at checkout
  • Stock validation on add
  • Redis-cached with 5min TTL

Order Management

  • Full order lifecycle: 11 statuses (pending → delivered/cancelled/returned/refunded)
  • Payment tracking: 9 statuses, 11 payment methods (Stripe, PayPal, SSLCommerz, bKash, Nagad, COD, etc.)
  • Shipping tracking with carriers and ETA
  • Return/refund workflow with reason tracking
  • Order items snapshot product name/price/image at time of purchase

Infrastructure

  • PostgreSQL via TypeORM (auto-migrations in dev)
  • Redis for caching (products, cart, sessions, permissions) and distributed locking
  • RabbitMQ with 6 exchanges, 20 queues for async event processing
  • Cloudinary for file/image upload with rate limiting
  • Swagger docs at /docs
  • Jest tests (unit + E2E config)

megamart-storefront — Feature Overview

A fully featured customer-facing storefront built with Next.js 16.

Pages & Routes

  • Home — Featured products, trending items, categories showcase
  • Product Listing — Multi-vendor catalog with search, category/brand/price filters, and pagination
  • Product Detail — Full product info, image gallery, attributes selection, reviews & ratings
  • Vendor Store — Browse products by a specific vendor/shop
  • Cart — Cross-vendor cart with quantity controls, price summaries, and coupon application
  • Checkout — Address selection, payment method, order summary, and place order flow
  • Auth — Login, register, forgot/reset password pages
  • Account — Profile, order history, wishlist, address management

Features

  • Multi-vendor product discovery with search and advanced filtering
  • User authentication with JWT (access + refresh token flow)
  • Social login (Google, Facebook)
  • Cross-vendor shopping cart with Redis-backed persistence
  • Coupon/discount code application at checkout
  • Responsive mobile-first design with Tailwind CSS v4
  • Server-side rendering for SEO and performance
  • Image optimization via Cloudinary with responsive image variants
  • TanStack Query for server state management with caching and optimistic updates
  • Axios HTTP client with automatic token refresh and 401 retry queue
  • Custom 404 and error pages

megamart-dashboard — Feature Overview

A dual-role dashboard serving both vendors and platform administrators, fully integrated with the backend API.

Vendor Panel

  • Store Management — Edit shop name, description, logo, banner, and return policy
  • Products — Add/edit/delete products, manage inventory stock, track sales
  • Orders — View incoming orders, update fulfillment status, manage cancellations and returns
  • Analytics — Revenue, sales trends, top products, customer insights
  • KYC & Bank — Submit verification documents, manage payout bank account
  • Payouts — Track earnings, commission deductions, and payout history

Admin Panel

  • Platform Overview — Key metrics, revenue charts, vendor growth, order volume
  • Vendor Management — Approve/reject vendor registrations, review KYC documents, suspend vendors
  • User Management — List, search, lock/unlock, and manage all platform users
  • Order Management — Full order lifecycle oversight, payment status tracking
  • Commission Management — Configure vendor commission rates
  • Analytics & Reports — ApexCharts-powered dashboards with revenue, orders, and vendor performance

Shared Features

  • JWT-based authentication with role-based routing (vendor vs admin views)
  • Interactive calendar (FullCalendar) for scheduling and events
  • Data tables with sorting, filtering, and pagination
  • Complete form toolkit (inputs, selects, date pickers, file uploads, drag-and-drop)
  • Dark mode with persistence
  • Responsive sidebar navigation with collapsible menus
  • Notification dropdown with real-time updates
  • User profile management with editable modals

Tech Stack

Layer Technologies
Backend NestJS 11, TypeORM, PostgreSQL, RabbitMQ, Redis, JWT (Passport), Argon2, Cloudinary, Nodemailer, Stripe/PayPal/SSLCommerz, Jest, Swagger
Storefront Next.js 16 (App Router), React 19, TanStack Query, Axios, Tailwind CSS v4, Vitest, Playwright
Dashboard Next.js 16 (App Router), React 19, Tailwind CSS v4, ApexCharts, FullCalendar, Flatpickr, react-dnd, jVectorMap

Getting Started

Each service lives in its own repository. Clone and run individually:

# Backend (http://localhost:5000)
git clone https://github.com/imran-binhasan/megamart-backend.git
cd megamart-backend
npm install
# Configure .env (PostgreSQL, Redis, RabbitMQ URLs)
npm run start:dev

# Storefront (http://localhost:3000)
git clone https://github.com/imran-binhasan/megamart-storefront.git
cd megamart-storefront
npm install
npm run dev

# Dashboard (http://localhost:3001)
git clone https://github.com/imran-binhasan/megamart-dashboard.git
cd megamart-dashboard
npm install
npm run dev

Refer to each repository's README for detailed setup instructions, environment variables, and configuration.

About

A full-stack e-commerce platform featuring a production-grade NestJS REST API (RBAC, 3 payment gateways, Redis caching, RabbitMQ async events, PostgreSQL 16, Docker Compose) paired with a modern frontend — demonstrating end-to-end architecture, clean code, and real-world engineering practices.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors