Skip to content

DivdevTech/multivendor

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MERN Multi-Vendor Ecommerce - Deployment Guide

πŸš€ Quick Deployment

Ubuntu Server Deployment

wget https://raw.githubusercontent.com/collinskramp/ecommerce/main/deploy-ubuntu.sh && chmod +x deploy-ubuntu.sh && ./deploy-ubuntu.sh

Local Development

./dev.sh

PM2 Process Management

# Start all services
./pm2.sh start

# Restart services
./pm2.sh restart

# Check status
./pm2.sh status

# View logs
./pm2.sh logs

πŸ“Š Application URLs

Production (Ubuntu)

  • Frontend (Customer): http://your-server:3000
  • Dashboard (Admin): http://your-server:3001
  • Backend API: http://your-server:5001

Development (Local)

  • Frontend (Customer): http://localhost:3000
  • Dashboard (Admin): http://localhost:3001
  • Backend API: http://localhost:5001

πŸ” Demo Login Credentials

Admin Dashboard

Seller Account

Customer Account

πŸ› οΈ Technical Stack

  • Frontend: React.js (Port 3000)
  • Dashboard: React.js (Port 3001)
  • Backend: Node.js/Express (Port 5001)
  • Database: MongoDB
  • Process Manager: PM2
  • Authentication: JWT

βš™οΈ Configuration

PM2 Ecosystem Configuration

The project includes an ecosystem.config.js file for PM2 process management:

  • Backend: Node.js server (Port 5001)
  • Frontend: React development server (Port 3000)
  • Dashboard: React development server (Port 3001)
  • Logging: Centralized logs in ./logs/ directory
  • Auto-restart: Enabled for all services
  • Memory limits: 1GB per service

Environment Variables

Edit backend/.env with your credentials:

DB_URL=mongodb://localhost:27017/ec
JWT_SECRET=your_jwt_secret
STRIPE_SECRET=your_stripe_secret_key
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret

MongoDB Setup

  • Database: ec
  • Authentication: Disabled (for simplified development setup)
  • Connection: Direct connection without credentials

πŸ”§ Troubleshooting

Port Conflicts

The frontend runs on the standard React development port 3000. If you have port conflicts, you can modify the PORT environment variable in the deployment scripts.

Node.js Dependency Conflicts (Ubuntu 22.04+)

If you encounter Node.js or MongoDB dependency issues:

./fix-nodejs.sh

MongoDB Authentication Issues

If you get "Authentication failed" errors when running populate_database.js:

  1. Check if admin user exists:

    mongosh --eval "use admin; db.getUsers()"
  2. Create admin user if missing:

    mongosh --eval "
    use admin
    db.createUser({
      user: 'admin',
      pwd: 'password',
      roles: [
        { role: 'userAdminAnyDatabase', db: 'admin' },
        { role: 'readWriteAnyDatabase', db: 'admin' },
        { role: 'dbAdminAnyDatabase', db: 'admin' }
      ]
    })
    "
  3. Test authentication:

    mongosh ec --authenticationDatabase admin -u admin -p password --eval "db.runCommand({ping: 1})"
  4. Quick MongoDB setup script:

    # Create and run MongoDB setup script
    cat > setup-mongodb.sh << 'EOF'
    #!/bin/bash
    echo "Setting up MongoDB admin user..."
    mongosh --eval "
    use admin
    db.dropUser('admin')
    db.createUser({
      user: 'admin',
      pwd: 'password',
      roles: [
        { role: 'userAdminAnyDatabase', db: 'admin' },
        { role: 'readWriteAnyDatabase', db: 'admin' },
        { role: 'dbAdminAnyDatabase', db: 'admin' }
      ]
    })
    print('Admin user created successfully')
    "
    EOF
    chmod +x setup-mongodb.sh
    ./setup-mongodb.sh

PM2 Management

# Using the PM2 management script (recommended)
./pm2.sh start           # Start all services
./pm2.sh restart         # Restart all services
./pm2.sh stop            # Stop all services
./pm2.sh status          # Show status
./pm2.sh logs            # View all logs
./pm2.sh logs frontend   # View specific service logs

# Start specific services
./pm2.sh start frontend
./pm2.sh restart backend
./pm2.sh stop dashboard

# Traditional PM2 commands
pm2 start ecosystem.config.js    # Start all services
pm2 restart all                  # Restart all services
pm2 stop all                     # Stop all services
pm2 status                       # Check status
pm2 logs                         # View logs
pm2 monit                        # Monitor services

MongoDB Issues

# Check MongoDB status
sudo systemctl status mongod

# Restart MongoDB
sudo systemctl restart mongod

# View MongoDB logs
sudo journalctl -u mongod

Demo Data

To repopulate the database with demo data:

cd /path/to/ecommerce
node populate_database.js

πŸ”₯ Firewall Configuration

For external access, configure your firewall:

sudo ufw allow 3000  # Frontend
sudo ufw allow 3001  # Dashboard
sudo ufw allow 5001  # Backend API

πŸ—οΈ Manual Installation

If you prefer manual installation, follow these steps:

  1. Install Dependencies

    sudo apt update
    sudo apt install -y nodejs npm mongodb git
    npm install -g pm2
  2. Clone Repository

    git clone https://github.com/collinskramp/ecommerce.git
    cd ecommerce
  3. Install Project Dependencies

    cd backend && npm install && cd ..
    cd frontend && npm install && cd ..
    cd dashboard && npm install && cd ..
  4. Configure Environment

    cp backend/.env.example backend/.env
    # Edit backend/.env with your credentials
  5. Setup MongoDB

    sudo systemctl start mongod
    sudo systemctl enable mongod
  6. Populate Database

    node populate_database.js
  7. Start Services

    pm2 start ecosystem.config.js
    pm2 save
    pm2 startup

πŸ“ Features

  • βœ… Multi-vendor marketplace
  • βœ… Customer shopping interface
  • βœ… Admin management dashboard
  • βœ… Seller management system
  • βœ… Product catalog with categories
  • βœ… Shopping cart and wishlist
  • βœ… Order management
  • βœ… Payment integration (Stripe)
  • βœ… Image upload (Cloudinary)
  • βœ… User authentication
  • βœ… Real-time chat
  • βœ… Review and rating system

πŸ†˜ Support

If you encounter issues:

  1. Check PM2 logs: pm2 logs
  2. Verify MongoDB is running: sudo systemctl status mongod
  3. Check firewall settings: sudo ufw status
  4. Ensure all ports are accessible
  5. Verify environment variables in backend/.env

πŸ“„ License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 92.3%
  • Shell 7.3%
  • Other 0.4%