Skip to content

A feature-rich e-commerce platform offering secure shopping, product management, and order processing. Built for performance with a mobile-first design and seamless payment integration.

Notifications You must be signed in to change notification settings

David-mwendwa/MarketHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

180 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ MarketHub - Your One-Stop E-commerce Solution

πŸ›οΈ MarketHub

Your One-Stop E-commerce Solution

License: MIT PRs Welcome Vite React Node.js MongoDB

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.

✨ Why MarketHub?

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.

πŸš€ Key Features

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 Stack

Frontend

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

Backend

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

Payment & Deployment

Service Purpose
Stripe Secure payment processing
MongoDB Atlas Cloud database hosting
Vercel/Netlify Frontend deployment
Render/Railway Backend deployment

πŸš€ Quick Start

Prerequisites

  • Node.js (v16+ recommended)
  • npm (v8+ recommended) or yarn
  • MongoDB (Atlas or local instance)
  • Stripe account for payments
  • Git for version control

1. Clone & Setup

# Clone the repository
git clone https://github.com/David-mwendwa/MarketHub.git
cd MarketHub

2. Backend Setup

# 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

3. Frontend Setup

# From project root
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

βš™οΈ Environment Configuration

Backend (.env)

Create 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:3000

Frontend (.env)

Create 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

πŸ›  Development

Common Commands

Backend

# 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

Frontend

# 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

Database Seeding

# From backend directory
npm run seeder
# or with custom count
NODE_ENV=development node seeder.js --import [count]

πŸ” Troubleshooting

Common Issues

  1. MongoDB Connection Failed

    • Ensure MongoDB is running locally or your Atlas connection string is correct
    • Check if your IP is whitelisted in MongoDB Atlas
  2. Missing Environment Variables

    • Verify all required .env variables are set
    • Restart the server after making changes to .env
  3. Port Already in Use

    • Check if another process is using port 3000 or 5001
    • Use lsof -i :<port> to find and kill the process
  4. Module Not Found

    • Run npm install in both frontend and backend directories
    • Delete node_modules and package-lock.json then reinstall

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow existing code style and patterns
  • Use meaningful commit messages
  • Update documentation when necessary
  • Add tests for new features

πŸ“‚ Project Structure

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

πŸ“¦ Available Scripts

Backend

  • npm run dev - Start development server with nodemon
  • npm start - Start production server
  • npm run seeder - Seed database with sample data
  • npm test - Run tests

Frontend

  • npm run dev - Start Vite development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint

πŸ”„ Deployment

Backend Deployment

  1. Set up a MongoDB Atlas database
  2. Configure environment variables in production
  3. Deploy to your preferred hosting (Heroku, Render, Railway, etc.)

Frontend Deployment

  1. Update VITE_API_BASE_URL in .env to your production API URL
  2. Build the app: npm run build
  3. Deploy the dist folder to your hosting (Vercel, Netlify, etc.)

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

A feature-rich e-commerce platform offering secure shopping, product management, and order processing. Built for performance with a mobile-first design and seamless payment integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages