Skip to content

Latest commit

 

History

History
196 lines (147 loc) · 4.28 KB

File metadata and controls

196 lines (147 loc) · 4.28 KB

🛒 E-Commerce App (Client + Server)

📸 Screenshots

Home Page Product Page Cart Page Admin Dashboard
Home Product Cart Admin

✅ Overview

This repository includes both the client (React + Vite + Tailwind CSS) and the server (Node.js + Express + MongoDB) for a full e-commerce application.

Key backend features:

  • JWT authentication
  • MongoDB with Mongoose
  • File uploads via Cloudinary
  • Stripe payments
  • Cart & order management

🧩 Tech Stack

Client: React, Vite, Tailwind CSS
Server: Node.js, Express
Database: MongoDB (Mongoose)
Auth: JWT
Payments: Stripe
File Storage: Cloudinary


📦 Prerequisites

  • Node.js v18+
  • npm or yarn
  • MongoDB connection URI
  • Cloudinary credentials:
    • CLOUDINARY_CLOUD_NAME
    • CLOUDINARY_API_KEY
    • CLOUDINARY_API_SECRET
  • Stripe secret key

🔐 Environment Variables

server/.env

PORT=4000
MONGODB_URI=<your-mongodb-uri>
JWT_SECRET=<strong-jwt-secret>
CLOUDINARY_CLOUD_NAME=<cloud_name>
CLOUDINARY_API_KEY=<api_key>
CLOUDINARY_API_SECRET=<api_secret>
STRIPE_SECRET_KEY=<stripe_secret_key>
STRIPE_WEBHOOK_SECRET=<stripe_webhook_secret>  # optional
COOKIE_SECRET=<cookie-secret>                  # optional

client/.env (optional)

VITE_API_BASE_URL=http://localhost:4000

⚙️ Local Setup

1️⃣ Install dependencies

# Server
cd server
npm install

# Client
cd ../client
npm install

2️⃣ Run the server

cd server
npm run serve    # development with nodemon
# or
npm start        # production

Default port: 4000

3️⃣ Run the client

cd client
npm run dev

Default Vite port: http://localhost:5173


🔄 Scripts

Server

  • npm run serve — dev mode with nodemon
  • npm start — production

Client

  • npm run dev — Vite dev server
  • npm run build — production build
  • npm run preview — preview build

📡 API Routes (server)

  • GET / — health check
  • /api/user/* — user auth & profile
  • /api/seller/* — seller functionality
  • /api/product/* — products CRUD
  • /api/cart/* — cart actions
  • /api/address/* — addresses
  • /api/order/* — orders & Stripe webhook

Auth header format:

Authorization: Bearer <token>

☁️ Cloudinary & Stripe

  • Cloudinary config via configs/cloudinary.js
  • Stripe integration for payment + optional webhook handling with STRIPE_WEBHOOK_SECRET

🚀 Deployment Notes

Server: Set production environment variables for MongoDB, Stripe, Cloudinary, JWT, etc.

Client: Deploy /dist to services like Netlify, Vercel, Surge, or serve statically via Express.


🛠 Common Issues

Issue Fix
MongoDB connection fails Ensure valid URI (mongodb+srv:// or mongodb://)
Cloudinary not working Check env variables
CORS/cookies broken Update CORS settings in Express
Wrong DB name Update in server .connect() if needed

📂 Project Structure

root/
├── client/                 # Frontend (React + Vite)
│   ├── src/
│   ├── public/
│   └── ...
├── server/                 # Backend (Express + MongoDB)
│   ├── routes/
│   ├── models/
│   ├── controllers/
│   ├── configs/
│   ├── middleware/
│   └── ...
└── README.md

📜 License: Proprietary – Permission Required


If you’d like extra sections (setup screenshots, Docker support, or contribution guidelines), just say the word!