A modern, full-stack dropshipping marketplace built with the MERN stack (MongoDB, Express, React, Node.js) and Vite. ShopHub empowers users to both buy and sell products without inventory - a complete dual-role e-commerce platform.
- Smart Shopping: Browse 30+ products with real images from Pexels API
- Intelligent Checkout: Auto-fill city, state, and country using OpenStreetMap
- Secure Payments: Stripe integration + Cash on Delivery
- Order Tracking: Real-time order status and history
- Google Sign-In: Fast authentication with Firebase OAuth
- Become a Seller: Upgrade any user account to seller status
- Product Management: Add products with auto-fetched images from Pexels
- Sales Dashboard: Track total sales and revenue
- Smart Pricing: Built-in pricing calculator
- No Inventory: True dropshipping model
- Product Management: Full CRUD operations
- Order Management: Update status and track deliveries
- User Management: View and manage all users
- Analytics Dashboard: Revenue charts and statistics
- Dual Authentication: JWT + Firebase (Google OAuth)
- Profile Protection: Email locked, password change for non-Google users
- Role-based Access: User, Seller, Admin roles
- React 18.2.0 - UI library with lazy loading
- Vite 5.0.8 - Lightning-fast build tool
- Redux Toolkit 2.0.1 - State management
- React Router v6.20.1 - Client-side routing
- Tailwind CSS 3.4.0 - Utility-first styling
- Firebase 10.7.1 - Google OAuth authentication
- Stripe Elements - Secure payment UI
- Pexels API - Real product images
- OpenStreetMap Nominatim - Location auto-fill
- React Hot Toast - Beautiful notifications
- Node.js + Express - REST API server
- MongoDB + Mongoose - Database and ODM
- JWT - Token-based auth
- bcryptjs - Password hashing
- Stripe - Payment processing
- Cloudinary - Image hosting
- Multer - File upload handling
- Node.js (v16 or higher)
- MongoDB (local installation or MongoDB Atlas)
- Stripe Account (for payments)
- Pexels API Key (free at pexels.com/api)
- Firebase Project (for Google OAuth)
- Cloudinary Account (optional, for custom image uploads)
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile in the backend directory:
NODE_ENV=development
PORT=5000
MONGO_URI=mongodb://localhost:27017/ecommerce
JWT_SECRET=your_super_secret_jwt_key_change_this
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
FRONTEND_URL=http://localhost:5173- Seed the database with sample products (optional):
node seedProducts.js- Start the backend server:
npm run devThe backend will run on http://localhost:5000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Configure Firebase:
- Create a Firebase project at console.firebase.google.com
- Enable Google Authentication
- Copy your Firebase config to
src/config/firebase.js:
const firebaseConfig = {
apiKey: "your_api_key",
authDomain: "your_project.firebaseapp.com",
projectId: "your_project_id",
storageBucket: "your_project.appspot.com",
messagingSenderId: "your_sender_id",
appId: "your_app_id"
};- Add Pexels API Key:
- Get free API key from pexels.com/api
- Update in
src/pages/seller/SellerAddProductPage.jsx:
const PEXELS_API_KEY = 'your_pexels_api_key';- Update Stripe Publishable Key in
src/pages/CheckoutPage.jsx:
const stripePromise = loadStripe('pk_test_your_stripe_publishable_key');- Start the development server:
npm run devThe frontend will run on http://localhost:5173
# Terminal 1 - Backend
cd backend
npm install
npm run dev
# Terminal 2 - Frontend
cd frontend
npm install
npm run devecommerce-platform/
βββ backend/
β βββ config/
β β βββ db.js
β β βββ cloudinary.js
β βββ controllers/
β β βββ userController.js
β β βββ productController.js
β β βββ orderController.js
β βββ middleware/
β β βββ authMiddleware.js
β β βββ errorMiddleware.js
β β βββ uploadMiddleware.js
β βββ models/
β β βββ User.js
β β βββ Product.js
β β βββ Order.js
β βββ routes/
β β βββ userRoutes.js
β β βββ productRoutes.js
β β βββ orderRoutes.js
β βββ utils/
β β βββ generateToken.js
β βββ .env.example
β βββ package.json
β βββ server.js
β
βββ frontend/
β βββ public/
β βββ src/
β β βββ components/
β β β βββ Header.jsx
β β β βββ Footer.jsx
β β β βββ ProductCard.jsx
β β β βββ Loader.jsx
β β β βββ Message.jsx
β β β βββ PrivateRoute.jsx
β β β βββ AdminRoute.jsx
β β βββ pages/
β β β βββ HomePage.jsx
β β β βββ ProductsPage.jsx
β β β βββ ProductDetailPage.jsx
β β β βββ LoginPage.jsx
β β β βββ RegisterPage.jsx
β β β βββ CartPage.jsx
β β β βββ CheckoutPage.jsx
β β β βββ OrderPage.jsx
β β β βββ OrdersPage.jsx
β β β βββ admin/
β β β βββ AdminDashboard.jsx
β β βββ redux/
β β β βββ slices/
β β β β βββ authSlice.js
β β β β βββ cartSlice.js
β β β β βββ productSlice.js
β β β β βββ orderSlice.js
β β β βββ store.js
β β βββ index.css
β β βββ main.jsx
β βββ index.html
β βββ package.json
β βββ vite.config.js
β βββ tailwind.config.js
β
βββ README.md
POST /api/users/register- Register new userPOST /api/users/login- Login userGET /api/users/profile- Get user profile (Protected)PUT /api/users/profile- Update user profile (Protected)
GET /api/products- Get all products (with filters)GET /api/products/:id- Get single productPOST /api/products- Create product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)POST /api/products/:id/reviews- Create product review (Protected)
POST /api/orders- Create new order (Protected)GET /api/orders/:id- Get order by ID (Protected)GET /api/orders/myorders- Get user orders (Protected)GET /api/orders- Get all orders (Admin)PUT /api/orders/:id/pay- Update order to paid (Protected)PUT /api/orders/:id/deliver- Update order to delivered (Admin)POST /api/orders/create-payment-intent- Create Stripe payment intent (Protected)
- Create, read, update, and delete products
- Upload multiple product images
- Categorize products
- Set discount prices
- Track inventory/stock
- Advanced product filtering (category, price range)
- Product search functionality
- Product reviews and ratings
- Responsive image carousel
- Real-time cart updates
- Multi-step checkout process
- Shipping address management
- Multiple payment methods (Stripe, COD)
- Order status tracking
- Email notifications (can be added)
- Dashboard with statistics
- Revenue analytics with charts
- Product management interface
- Order management and status updates
- User management
- Password hashing with bcrypt
- JWT authentication
- Protected routes
- Role-based access control (User/Admin)
- Input validation
- CORS configuration
-
Create MongoDB Atlas Cluster (Free Tier)
- Go to mongodb.com/cloud/atlas
- Create free cluster
- Get connection string
- Whitelist all IPs (0.0.0.0/0) for serverless
-
Deploy Backend to Vercel
cd backend npm install -g vercel vercel- Set environment variables in Vercel dashboard
- Add
vercel.jsonin backend folder:
{ "version": 2, "builds": [{ "src": "server.js", "use": "@vercel/node" }], "routes": [{ "src": "/(.*)", "dest": "/server.js" }] } -
Environment Variables (Vercel Dashboard):
NODE_ENV=production MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/shophub JWT_SECRET=your_production_secret STRIPE_SECRET_KEY=sk_live_your_key STRIPE_PUBLISHABLE_KEY=pk_live_your_key CLOUDINARY_CLOUD_NAME=your_name CLOUDINARY_API_KEY=your_key CLOUDINARY_API_SECRET=your_secret FRONTEND_URL=https://your-frontend.vercel.app
-
Deploy Frontend
cd frontend vercel -
Update API URL
- In
vite.config.js, update proxy target to your backend URL - Or use environment variable:
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000';
- In
-
Build & Deploy
npm run build vercel --prod
- Go to render.com
- Create New Web Service
- Connect GitHub repository
- Settings:
- Build Command:
cd backend && npm install - Start Command:
cd backend && node server.js - Environment: Node
- Add all environment variables
- Build Command:
- Create New Static Site
- Settings:
- Build Command:
cd frontend && npm install && npm run build - Publish Directory:
frontend/dist
- Build Command:
- Add environment variable:
VITE_API_URL= your backend URL
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Deploy Backend
cd backend
railway init
railway up
# Deploy Frontend
cd ../frontend
railway init
railway up-
SSH into your server
-
Install dependencies:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt-get install -y mongodb sudo npm install -g pm2 -
Clone repository:
git clone https://github.com/Rakshi2609/ShopHub.git cd ShopHub -
Setup Backend:
cd backend npm install # Create .env file with production values pm2 start server.js --name shophub-api pm2 startup pm2 save
-
Setup Frontend:
cd ../frontend npm install npm run build -
Setup Nginx (reverse proxy):
sudo apt install nginx
Create
/etc/nginx/sites-available/shophub:server { listen 80; server_name your-domain.com; # Frontend location / { root /path/to/ShopHub/frontend/dist; try_files $uri $uri/ /index.html; } # Backend API location /api { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }
sudo ln -s /etc/nginx/sites-available/shophub /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
-
SSL Certificate (Let's Encrypt):
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d your-domain.com
cd backend
heroku create shophub-api
git push heroku main
heroku config:set NODE_ENV=production MONGO_URI=... JWT_SECRET=...- Build:
npm run build - Drag
distfolder to netlify.com/drop - Or use CLI:
npm install -g netlify-cli netlify deploy --prod --dir=dist
β Update CORS settings in backend for your frontend URL β Set all environment variables in production β Update Firebase authorized domains β Update Stripe webhook endpoints (if using webhooks) β Test Google Sign-In with production URL β Verify Pexels API calls work β Test payment flow end-to-end β Monitor application logs
- Enable GZIP compression
- Use CDN for static assets (Cloudinary, AWS S3)
- Enable HTTP/2
- Set proper cache headers
- Use PM2 cluster mode for Node.js
- Add database indexes for MongoDB queries
Make sure to set all required environment variables in your hosting platform.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
- β 31 Seeded Products with real images
- β Dual-Role System - Users can buy AND sell
- β Smart Location - Auto-fill on Enter key
- β Sales Tracking - Updates on payment
- β Image Search - Real Pexels API integration
- β Responsive Design - Mobile-first approach
- β Profile Management - Email protection, password security
- β 404 Page - Custom error handling
- β Dropshipping Theme - Complete marketplace UI
Issue: CORS errors in production
Solution: Update FRONTEND_URL in backend .env
Issue: Google Sign-In fails Solution: Add production URL to Firebase authorized domains
Issue: Images not loading Solution: Verify Pexels API key and rate limits
Issue: Payment fails in production Solution: Use Stripe live keys, not test keys
(Add your screenshots here)
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
ISC License - feel free to use for learning and portfolio projects
Rakshith - LinkedIn
- Pexels - Free stock photos API
- Stripe - Payment processing
- Firebase - Google OAuth authentication
- OpenStreetMap - Geocoding API
- Cloudinary - Image hosting
- MongoDB Atlas - Cloud database
- Tailwind CSS - Styling framework
- Vite - Build tool
For issues, questions, or suggestions:
- Open an issue on GitHub
- Contact via LinkedIn
π Star this repo if you find it helpful!
Built with β€οΈ by Rakshith & AI