Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

117 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ProShop - MERN eCommerce Platform (Nest backend)

ProShop Cover

Full-featured eCommerce platform built with MongoDB, React, and a NestJS (Express) backend in TypeScript. Features include product catalog, shopping cart, user authentication, admin panel, order management, PayPal integration, and dark/light theme support.

πŸš€ Features

Customer Features

  • Product Catalog - Browse products with search, pagination, and top products carousel
  • Product Reviews & Ratings - Customer reviews and 5-star rating system
  • Shopping Cart - Add/remove items, quantity management, persistent cart
  • User Authentication - Register, login, logout with JWT tokens
  • User Profile - Manage personal information and view order history
  • Checkout Process - Multi-step checkout with shipping and payment
  • PayPal Integration - Secure payment processing
  • Order Tracking - View order status and details
  • Theme Support - Dark/light mode toggle

Admin Features

  • Admin Dashboard - Comprehensive admin panel
  • Product Management - Create, edit, delete products with image upload
  • User Management - View, edit, delete user accounts
  • Order Management - View all orders, mark as delivered
  • Inventory Control - Stock management and product categorization

Technical Features

  • TypeScript - Full TypeScript implementation for type safety
  • Responsive Design - Mobile-first responsive UI with Bootstrap
  • State Management - Redux Toolkit for efficient state management
  • API Integration - RESTful API with proper error handling
  • File Upload - Multer integration for product images
  • Security - JWT authentication, password hashing, input validation
  • SEO Optimized - React Helmet for meta tags and SEO

πŸ› οΈ Tech Stack

Frontend

  • React 18.3 - Modern React with hooks and functional components
  • TypeScript 5.2 - Type-safe JavaScript development
  • Redux Toolkit 1.9 - State management with RTK Query
  • React Router 6.10 - Client-side routing
  • Bootstrap 5.2 - Responsive UI framework
  • React Bootstrap 2.7 - Bootstrap components for React
  • Vite - Fast build tool and development server
  • PayPal React SDK - PayPal payment integration
  • React Helmet Async - SEO and meta tag management
  • React Toastify - Toast notifications
  • Moment.js - Date formatting and manipulation

Backend

  • Node.js - JavaScript runtime environment
  • NestJS (Express) - Structured API framework
  • TypeScript 5.5 - Type-safe server development
  • MongoDB + Mongoose 7 - NoSQL database & ODM
  • JWT - JSON Web Token authentication (HttpOnly cookie)
  • bcryptjs - Password hashing
  • Multer - File upload handling
  • Morgan - HTTP request logger
  • Cookie Parser - Cookie parsing middleware

Development Tools

  • Nodemon - Development server auto-restart
  • Concurrently - Run multiple commands simultaneously
  • ESLint - Code linting and formatting
  • Prettier - Code formatting
  • ts-node / ts-node-dev - TypeScript execution for Node.js

πŸ“‹ Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local installation or MongoDB Atlas)
  • npm or yarn package manager

πŸš€ Installation & Setup

  1. Clone the repository

    git clone <repository-url>
    cd proshop
  2. Install dependencies

    npm install
  3. Environment Configuration Create a .env file in the root directory (also used by Nest backend):

    NODE_ENV=development
    PORT=3000
    MONGODB_URL=mongodb://localhost:27017/proshop
    MONGO_URI=mongodb://localhost:27017/proshop
    MONGO_DB=proshop
    JWT_SECRET=your_jwt_secret_key
    PAYPAL_CLIENT_ID=your_paypal_client_id
  4. Database Setup

    # Import sample data (optional)
    npm run data:import
    
    # Destroy sample data (if needed)
    npm run data:destroy

πŸƒβ€β™‚οΈ Running the Application

Development Mode

# Client (Vite)
npm run client

# Server (Nest)
npm run server:dev

Production Mode

# Build client + server
npm run build   # builds server and client

# Start production server (serves /api and client dist)
npm run server:start

The application will be available at:

πŸ“ Project Structure

proshop/
β”œβ”€β”€ backend/                 # Legacy Express backend (kept for reference; Nest replaces it)
β”‚   β”œβ”€β”€ controllers/         # Route controllers
β”‚   β”œβ”€β”€ data/               # Sample data and seeder
β”‚   β”œβ”€β”€ dtos/               # Data Transfer Objects
β”‚   β”œβ”€β”€ middlewares/        # Custom middleware
β”‚   β”œβ”€β”€ models/             # Mongoose models
β”‚   β”œβ”€β”€ routes/             # API routes
β”‚   β”œβ”€β”€ start/              # App configuration
β”‚   β”œβ”€β”€ types/              # TypeScript type definitions
β”‚   └── server.ts           # Entry point
β”œβ”€β”€ server/                 # NestJS backend (current API)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/           # Auth guards/decorators
β”‚   β”‚   β”œβ”€β”€ common/         # Filters
β”‚   β”‚   β”œβ”€β”€ config/         # Config controller (e.g., PayPal)
β”‚   β”‚   β”œβ”€β”€ order/          # Orders module
β”‚   β”‚   β”œβ”€β”€ product/        # Products module
β”‚   β”‚   β”œβ”€β”€ upload/         # Upload controller/module
β”‚   β”‚   └── user/           # Users module
β”‚   β”œβ”€β”€ tsconfig*.json
β”‚   └── dist/               # Compiled output
β”œβ”€β”€ client/                 # Frontend React application
β”‚   β”œβ”€β”€ public/             # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/            # API service layer
β”‚   β”‚   β”œβ”€β”€ app/            # Redux slices
β”‚   β”‚   β”œβ”€β”€ components/     # Reusable components
β”‚   β”‚   β”œβ”€β”€ layout/         # Layout components
β”‚   β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”‚   β”œβ”€β”€ store/          # Redux store configuration
β”‚   β”‚   β”œβ”€β”€ theme/          # Theme management
β”‚   β”‚   β”œβ”€β”€ types/          # TypeScript interfaces
β”‚   β”‚   └── utils/          # Utility functions
β”‚   └── vite.config.ts      # Vite configuration
β”œβ”€β”€ uploads/                # File upload directory
└── package.json           # Root package configuration

πŸ”Œ API Endpoints (Nest)

Authentication

  • POST /api/users/register - User registration
  • POST /api/users/auth - User login
  • POST /api/users/logout - User logout

Products

  • GET /api/products - Get all products (with pagination & search)
  • GET /api/products/top - Get top-rated products
  • GET /api/products/:id - Get single product
  • POST /api/products/:id/review - Create product review (Protected)
  • POST /api/products - Create product (Admin)
  • PATCH /api/products/:id - Update product (Admin)
  • DELETE /api/products/:id - Delete product (Admin)

Orders

  • GET /api/orders/myorders - Get current user's orders (Protected)
  • POST /api/orders - Create order (Protected)
  • GET /api/orders/:id - Get order by id (Protected)
  • PATCH /api/orders/:id/pay - Mark order as paid (Protected)
  • GET /api/orders - Get all orders (Admin)
  • PATCH /api/orders/:id/deliver - Mark order as delivered (Admin)

Uploads

  • POST /api/upload - Upload product image (Admin, form-data field image)

Config

  • GET /api/config/paypal - PayPal client id

Orders

  • POST /api/orders - Create new order (Protected)
  • GET /api/orders/myorders - Get user orders (Protected)
  • GET /api/orders/:id - Get order by ID (Protected)
  • PATCH /api/orders/:id/pay - Update order to paid (Protected)
  • GET /api/orders - Get all orders (Admin)
  • PATCH /api/orders/:id/deliver - Mark order as delivered (Admin)

Users

  • GET /api/users/profile - Get user profile (Protected)
  • PATCH /api/users/profile - Update user profile (Protected)
  • GET /api/users - Get all users (Admin)
  • GET /api/users/:id - Get user by ID (Admin)
  • PATCH /api/users/:id - Update user (Admin)
  • DELETE /api/users/:id - Delete user (Admin)

File Upload

  • POST /api/upload - Upload product image (Admin)

🎨 Features in Detail

Theme System

The application includes a sophisticated theme system supporting both light and dark modes with persistent user preferences.

State Management

Redux Toolkit with RTK Query provides efficient state management and API caching, reducing unnecessary network requests.

Authentication & Authorization

JWT-based authentication with role-based access control. Admin users have additional privileges for managing products, users, and orders.

Payment Integration

Secure PayPal integration for payment processing with order status tracking.

File Upload

Multer-based file upload system for product images with proper validation and storage management.

πŸš€ Deployment

The application is configured for deployment on Liara (Iranian cloud platform) with disk mounting for file uploads. Configuration is available in liara.json.

Build for Production

npm run build

This will:

  1. Install client dependencies
  2. Compile TypeScript backend code
  3. Build optimized client bundle
  4. Prepare for production deployment

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ‘¨β€πŸ’» Author

Hossein Rezaei


Built with ❀️ using the MERN stack and TypeScript

About

A full-featured eCommerce platform built with the MERN stack (MongoDB, Express.js, React, Node.js) and TypeScript. Features include product catalog, shopping cart, user authentication, admin panel, order management, PayPal integration, and dark/light theme support.

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages