A full-stack eCommerce platform for tech products built with the MERN stack.
- Frontend: React.js + Vite, Redux Toolkit
- Backend: Node.js, Express.js
- Database: MongoDB
- APIs: Unsplash API (product images), Stripe (payments)
- Cloud: Cloudinary (image storage)
npm install
cd frontend && npm installCreate BackEnd/config/.env:
PORT=4001
DB_LOCAL_URI=mongodb://127.0.0.1:27017/gadgetUniverse
JWT_TOKEN=your_jwt_secret
UNSPLASH_ACCESS_KEY=your_unsplash_key
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
STRIPE_SECRET_KEY=your_stripe_key# Fetch category-matched images from Unsplash and seed database
node BackEnd/seed/updateDataWithUnsplash.js && npm run seederThis fetches real images for 12 categories:
- 📷 Cameras (12 products)
- 💻 Laptops (12 products)
- 🎧 Headphones (10 products)
- 📱 Electronics (15 products)
- And 8 more categories...
# Backend
npm run dev
# Frontend (new terminal)
cd frontend && npm run dev- Global error middleware for unhandled promise rejections
- Async error wrapper to catch all async errors
- Custom error handler for Mongoose validation errors
- Environment-specific error responses (dev/prod)
- JWT-based authentication with HTTP-only cookies
- Password encryption using bcrypt
- Email verification with Nodemailer
- Role-based access control (user/admin)
- Forgot password with secure token generation
- RESTful API design
- Advanced filtering, sorting, and pagination
- Product search with multiple criteria
- Image upload with Cloudinary integration
- Order processing and tracking
- Secure payment with Stripe
GadgetUniverse/
├── BackEnd/
│ ├── config/ # Database & environment config
│ ├── controllers/ # Route controllers
│ ├── middlewares/ # Auth, error handling
│ ├── models/ # Mongoose schemas
│ ├── routes/ # API routes
│ ├── seed/ # Database seeder with Unsplash
│ └── utils/ # Helper functions
├── frontend/
│ └── src/
│ ├── actions/ # Redux actions & API calls
│ ├── components/ # React components
│ └── constants/ # App constants
GET /api/v1/products- Get all products (with filters)GET /api/v1/products/:id- Get product detailsPOST /api/v1/admin/products/new- Create product (admin)PUT /api/v1/admin/products/:id- Update product (admin)DELETE /api/v1/admin/products/:id- Delete product (admin)
POST /api/v1/register- Register userPOST /api/v1/login- Login userPOST /api/v1/logout- Logout userPOST /api/v1/password/forgot- Forgot passwordPUT /api/v1/password/reset/:token- Reset password
POST /api/v1/orders/new- Create orderGET /api/v1/orders/:id- Get order detailsGET /api/v1/me/orders- Get my ordersGET /api/v1/admin/orders- Get all orders (admin)
Contributions are welcome! Fork the repository and create a pull request.