A modern, scalable, and performant e-commerce platform built with the MERN stack (MongoDB, Express.js, React, Node.js) and enhanced with Tailwind CSS for a beautiful, responsive design.
MarketHub is designed to provide a seamless shopping experience with powerful features for both customers and administrators. Whether you're building an online store or learning full-stack development, MarketHub offers a robust foundation with modern best practices.
| Feature | Description |
|---|---|
| β‘ Lightning Fast | Built with Vite for instant hot module replacement and optimized production builds |
| π¨ Beautiful UI | Stunning, responsive design powered by Tailwind CSS |
| οΏ½ Secure | JWT authentication, protected routes, and secure payment processing |
| π Full E-commerce | Product catalog, search, filters, cart, and checkout |
| οΏ½ Mobile-First | Fully responsive design that works on all devices |
| οΏ½ Admin Dashboard | Manage products, orders, and users with ease |
| π Real-time Updates | Instant UI updates with Redux state management |
| Technology | Purpose |
|---|---|
| React 18 | Frontend library for building user interfaces |
| Vite | Next-generation frontend tooling |
| Tailwind CSS | Utility-first CSS framework |
| Redux Toolkit | State management |
| React Router | Navigation and routing |
| Axios | HTTP client for API requests |
| React Icons | Popular icon library |
| React Hot Toast | Beautiful toast notifications |
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime |
| Express.js | Web application framework |
| MongoDB | NoSQL database |
| Mongoose | MongoDB object modeling |
| JWT | Authentication tokens |
| Bcrypt | Password hashing |
| Multer | File uploads |
| Nodemailer | Email notifications |
| Service | Purpose |
|---|---|
| Stripe | Secure payment processing |
| MongoDB Atlas | Cloud database hosting |
| Vercel/Netlify | Frontend deployment |
| Render/Railway | Backend deployment |
- Node.js (v16+ recommended)
- npm (v8+ recommended) or yarn
- MongoDB (Atlas or local instance)
- Stripe account for payments
- Git for version control
# Clone the repository
git clone https://github.com/David-mwendwa/MarketHub.git
cd MarketHub# Navigate to backend
cd backend
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start development server
npm run dev# From project root
cd frontend
# Install dependencies
npm install
# Start development server
npm run devCreate a .env file in the backend directory with these variables:
# Server Configuration
PORT=5001
NODE_ENV=development
# Database
MONGO_URI=mongodb://localhost:27017/markethub
# For MongoDB Atlas use:
# MONGO_URI=mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/markethub?retryWrites=true&w=majority
# Authentication
JWT_SECRET=your_secure_jwt_secret
JWT_EXPIRE=30d
COOKIE_EXPIRE=30
# Stripe Payments
STRIPE_API_KEY=sk_test_your_stripe_secret_key
STRIPE_API_VERSION=2022-11-15
# Email Configuration (for password reset, etc.)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_EMAIL=your_email@gmail.com
SMTP_PASSWORD=your_app_specific_password # Use App Password for Gmail
SMTP_FROM_EMAIL=noreply@markethub.com
# Frontend URL (for CORS and redirects)
FRONTEND_URL=http://localhost:3000Create a .env file in the frontend directory:
# API Configuration
VITE_API_BASE_URL=http://localhost:5001/api/v1
# Stripe
VITE_STRIPE_PUBLIC_KEY=pk_test_your_stripe_public_key
# Environment
VITE_NODE_ENV=development# Run in development mode with hot-reload
npm run dev
# Run production server
npm start
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run format# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint
# Format code
npm run format# From backend directory
npm run seeder
# or with custom count
NODE_ENV=development node seeder.js --import [count]-
MongoDB Connection Failed
- Ensure MongoDB is running locally or your Atlas connection string is correct
- Check if your IP is whitelisted in MongoDB Atlas
-
Missing Environment Variables
- Verify all required
.envvariables are set - Restart the server after making changes to
.env
- Verify all required
-
Port Already in Use
- Check if another process is using port 3000 or 5001
- Use
lsof -i :<port>to find and kill the process
-
Module Not Found
- Run
npm installin both frontend and backend directories - Delete
node_modulesandpackage-lock.jsonthen reinstall
- Run
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style and patterns
- Use meaningful commit messages
- Update documentation when necessary
- Add tests for new features
MarketHub/
βββ backend/ # Backend server
β βββ config/ # Configuration files
β βββ controllers/ # Route controllers
β βββ middleware/ # Custom middleware
β βββ models/ # Database models
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ .env # Environment variables
β βββ server.js # Server entry point
β
βββ frontend/ # Frontend application
βββ public/ # Static files
βββ src/
β βββ assets/ # Images, fonts, etc.
β βββ components/ # Reusable UI components
β β βββ cart/ # Cart components
β β βββ layout/ # Layout components
β β βββ product/ # Product components
β β βββ user/ # User components
β βββ redux/ # Redux store and slices
β βββ utils/ # Utility functions
β βββ App.jsx # Main App component
β βββ main.jsx # Entry point
βββ .env # Frontend environment variables
βββ index.html # HTML template
βββ vite.config.js # Vite configuration
npm run dev- Start development server with nodemonnpm start- Start production servernpm run seeder- Seed database with sample datanpm test- Run tests
npm run dev- Start Vite development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- Set up a MongoDB Atlas database
- Configure environment variables in production
- Deploy to your preferred hosting (Heroku, Render, Railway, etc.)
- Update
VITE_API_BASE_URLin.envto your production API URL - Build the app:
npm run build - Deploy the
distfolder to your hosting (Vercel, Netlify, etc.)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Vite - Next Generation Frontend Tooling
- Tailwind CSS - A utility-first CSS framework
- React Icons - Popular icons for React
- Redux Toolkit - Official Redux toolset
- Stripe - Online payment processing
- MongoDB - NoSQL database