wget https://raw.githubusercontent.com/collinskramp/ecommerce/main/deploy-ubuntu.sh && chmod +x deploy-ubuntu.sh && ./deploy-ubuntu.sh./dev.sh# Start all services
./pm2.sh start
# Restart services
./pm2.sh restart
# Check status
./pm2.sh status
# View logs
./pm2.sh logs- Frontend (Customer):
http://your-server:3000 - Dashboard (Admin):
http://your-server:3001 - Backend API:
http://your-server:5001
- Frontend (Customer):
http://localhost:3000 - Dashboard (Admin):
http://localhost:3001 - Backend API:
http://localhost:5001
- Email: admin@admin.com
- Password: secret
- Email: seller1@techstore.com
- Password: secret
- Email: customer@example.com
- Password: secret
- Frontend: React.js (Port 3000)
- Dashboard: React.js (Port 3001)
- Backend: Node.js/Express (Port 5001)
- Database: MongoDB
- Process Manager: PM2
- Authentication: JWT
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
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- Database: ec
- Authentication: Disabled (for simplified development setup)
- Connection: Direct connection without credentials
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.
If you encounter Node.js or MongoDB dependency issues:
./fix-nodejs.shIf you get "Authentication failed" errors when running populate_database.js:
-
Check if admin user exists:
mongosh --eval "use admin; db.getUsers()" -
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' } ] }) "
-
Test authentication:
mongosh ec --authenticationDatabase admin -u admin -p password --eval "db.runCommand({ping: 1})" -
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
# 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# Check MongoDB status
sudo systemctl status mongod
# Restart MongoDB
sudo systemctl restart mongod
# View MongoDB logs
sudo journalctl -u mongodTo repopulate the database with demo data:
cd /path/to/ecommerce
node populate_database.jsFor external access, configure your firewall:
sudo ufw allow 3000 # Frontend
sudo ufw allow 3001 # Dashboard
sudo ufw allow 5001 # Backend APIIf you prefer manual installation, follow these steps:
-
Install Dependencies
sudo apt update sudo apt install -y nodejs npm mongodb git npm install -g pm2
-
Clone Repository
git clone https://github.com/collinskramp/ecommerce.git cd ecommerce -
Install Project Dependencies
cd backend && npm install && cd .. cd frontend && npm install && cd .. cd dashboard && npm install && cd ..
-
Configure Environment
cp backend/.env.example backend/.env # Edit backend/.env with your credentials -
Setup MongoDB
sudo systemctl start mongod sudo systemctl enable mongod -
Populate Database
node populate_database.js
-
Start Services
pm2 start ecosystem.config.js pm2 save pm2 startup
- β 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
If you encounter issues:
- Check PM2 logs:
pm2 logs - Verify MongoDB is running:
sudo systemctl status mongod - Check firewall settings:
sudo ufw status - Ensure all ports are accessible
- Verify environment variables in
backend/.env
This project is licensed under the MIT License.