Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ ShopHub E-Commerce Platform

A modern, full-stack e-commerce web application built with React, Node.js, Express, and PostgreSQL.

image

✨ Features

  • πŸ›οΈ Product Browsing - Search, filter by category, view detailed product information
  • πŸ›’ Shopping Cart - Add/remove items, adjust quantities, persistent cart storage
  • πŸ” User Authentication - Secure JWT-based login and registration with bcrypt password hashing
  • πŸ’³ Payment Processing - Integrated Stripe Checkout for secure transactions
  • πŸ“± Responsive Design - Mobile-first UI built with Tailwind CSS
  • 🎨 Modern UI/UX - Clean, professional interface with smooth animations

πŸ› οΈ Tech Stack

Frontend

  • React 18 - Component-based UI library
  • Vite - Fast build tool and dev server
  • React Router - Client-side routing
  • Zustand - Lightweight state management
  • Tailwind CSS - Utility-first styling
  • Axios - HTTP client
  • Lucide React - Icon library

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • PostgreSQL - Relational database
  • JWT - Token-based authentication
  • bcrypt - Password hashing
  • Stripe API - Payment processing
  • express-validator - Input validation

πŸ“‚ Project Structure

shophub-complete/
β”œβ”€β”€ backend/                 # Node.js/Express backend
β”‚   β”œβ”€β”€ routes/             # API route handlers
β”‚   β”œβ”€β”€ middleware/         # Auth & validation middleware
β”‚   β”œβ”€β”€ db.js              # Database connection
β”‚   β”œβ”€β”€ server.js          # Server entry point
β”‚   └── schema.sql         # Database schema
β”‚
└── frontend/               # React frontend
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/    # Reusable components
    β”‚   β”œβ”€β”€ pages/        # Page components
    β”‚   β”œβ”€β”€ services/     # API services
    β”‚   └── store/        # Zustand stores
    └── public/           # Static assets

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • PostgreSQL (v12 or higher)
  • npm or yarn
  • Stripe account (for payments)

Installation

1. Clone the repository

git clone https://github.com/Munun/shophub.git
cd shophub

2. Set up the database

# Create PostgreSQL database
createdb shophub

# Run schema
psql shophub < backend/schema.sql

3. Configure environment variables

Backend (.env):

cd backend
cp .env.example .env

Edit .env:

PORT=5001
DB_USER=your_db_user
DB_HOST=localhost
DB_NAME=shophub
DB_PASSWORD=your_db_password
DB_PORT=5432
JWT_SECRET=your_super_secret_jwt_key_change_this
STRIPE_SECRET_KEY=your_stripe_secret_key
CLIENT_URL=http://localhost:5173

Frontend (.env):

cd frontend
cp .env.example .env

Edit .env:

VITE_API_URL=http://localhost:5001/api
VITE_STRIPE_PUBLIC_KEY=your_stripe_public_key

4. Install dependencies

Backend:

cd backend
npm install

Frontend:

cd frontend
npm install

5. Start the application

Backend (Terminal 1):

cd backend
npm run dev

Server runs on http://localhost:5001

Frontend (Terminal 2):

cd frontend
npm run dev

App runs on http://localhost:5173

🎯 Usage

  1. Register/Login - Create an account or use demo credentials:

    • Email: test@example.com
    • Password: password123
  2. Browse Products - Search and filter by category

  3. Add to Cart - Select size (if applicable) and quantity

  4. Checkout - Complete purchase with Stripe test card:

    • Card: 4242 4242 4242 4242
    • Expiry: Any future date
    • CVC: Any 3 digits

πŸ“Š Database Schema

users
β”œβ”€β”€ id (PRIMARY KEY)
β”œβ”€β”€ email (UNIQUE)
β”œβ”€β”€ password_hash
β”œβ”€β”€ full_name
└── created_at

products
β”œβ”€β”€ id (PRIMARY KEY)
β”œβ”€β”€ name
β”œβ”€β”€ description
β”œβ”€β”€ price
β”œβ”€β”€ category
β”œβ”€β”€ stock_quantity
└── sizes (ARRAY)

orders
β”œβ”€β”€ id (PRIMARY KEY)
β”œβ”€β”€ user_id (FOREIGN KEY)
β”œβ”€β”€ total_amount
β”œβ”€β”€ status
└── stripe_payment_id

order_items
β”œβ”€β”€ id (PRIMARY KEY)
β”œβ”€β”€ order_id (FOREIGN KEY)
β”œβ”€β”€ product_id (FOREIGN KEY)
β”œβ”€β”€ quantity
└── price_at_purchase

πŸ” Security Features

  • βœ… Password hashing with bcrypt (10 salt rounds)
  • βœ… JWT authentication with HTTP-only recommendations
  • βœ… SQL injection prevention with parameterized queries
  • βœ… Input validation with express-validator
  • βœ… CORS configuration
  • βœ… Stripe handles all sensitive payment data

πŸ“Έ Screenshots

Products Page

image

Shopping Cart

image

Checkout

image

πŸ‘€ Author

Munun Patel

πŸ™ Acknowledgments

  • Stripe for payment processing
  • Tailwind CSS for styling
  • Lucide for icons
  • PostgreSQL community

⭐ If you found this project helpful, please give it a star!

About

Full-stack e-commerce platform built with React, Node.js, Express, and PostgreSQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages