A modern, full-stack e-commerce platform built with React, Node.js, Express, and MongoDB.
- β JWT-based authentication
- β Google OAuth integration
- β Secure password hashing
- β Protected routes
- β Role-based access control
- User registration and login
- Google Sign-In
- User dashboard
- Profile management
- Order tracking
- Wishlist
- Shopping cart
- Contact Us
- Privacy Policy
- Help Center (with Refund Policy)
- Track Order
- Node.js (v16 or higher)
- MongoDB Atlas account
- Google OAuth credentials (optional)
- Clone the repository
git clone <repository-url>
cd Urban-Thread- Install dependencies
# Backend
cd backend
npm install
# Frontend
cd ../frontend
npm install- Set up environment variables
Backend (.env):
MONGO_URI="your-mongodb-connection-string"
JWT_SECRET="your-jwt-secret"
JWT_EXPIRE="7d"
GOOGLE_CLIENT_ID="your-google-client-id"
PORT=5000Frontend (.env):
# Backend API URL - Change this for production deployment
VITE_API_URL=http://localhost:5000/api
# For production, use your deployed backend URL:
# VITE_API_URL=https://your-backend-url.com/api
VITE_GOOGLE_CLIENT_ID="your-google-client-id"Note: Copy
frontend/.env.exampletofrontend/.envand update the values. The.envfile is gitignored for security.
- Test MongoDB connection
cd backend
node testConnection.js- Start development servers
Option 1: Using the start script (recommended)
./start-dev.shOption 2: Manual start
# Terminal 1 - Backend
cd backend
npm run dev
# Terminal 2 - Frontend
cd frontend
npm run devPOST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/google- Google OAuthGET /api/auth/me- Get current user (protected)POST /api/auth/logout- Logout user (protected)
GET /api/users- Get all users (admin)GET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create product (seller/admin)PUT /api/products/:id- Update product (seller/admin)DELETE /api/products/:id- Delete product (seller/admin)
GET /api/orders- Get user ordersGET /api/orders/:id- Get order by IDPOST /api/orders- Create orderPUT /api/orders/:id- Update order status
GET /api/cart- Get user cartPOST /api/cart- Add to cartPUT /api/cart/:id- Update cart itemDELETE /api/cart/:id- Remove from cart
GET /api/wishlist- Get user wishlistPOST /api/wishlist- Add to wishlistDELETE /api/wishlist/:id- Remove from wishlist
- Go to Google Cloud Console
- Create a new project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized origins:
- Copy Client ID and update .env files
See INTEGRATION_GUIDE.md for detailed instructions.
- React 18
- TypeScript
- Vite
- React Router
- Axios
- Tailwind CSS
- Lucide Icons
- Node.js
- Express
- MongoDB with Mongoose
- JWT for authentication
- Google Auth Library
- bcryptjs for password hashing
Urban-Thread/
βββ backend/
β βββ controllers/
β βββ middleware/
β βββ models/
β βββ routes/
β βββ utils/
β βββ server.js
β βββ .env
βββ frontend/
β βββ src/
β β βββ components/
β β βββ context/
β β βββ services/
β β βββ App.tsx
β β βββ main.tsx
β βββ .env
βββ INTEGRATION_GUIDE.md
βββ README.md
cd backend
node testConnection.js- Register a new user at
/signup - Login at
/signin - Try Google Sign-In
- Access protected routes
MONGO_URI- MongoDB connection string β (Already configured)JWT_SECRET- Secret key for JWT tokensJWT_EXPIRE- Token expiration time
GOOGLE_CLIENT_ID- For Google OAuthGOOGLE_CLIENT_SECRET- For Google OAuthPORT- Server port (default: 5000)
VITE_API_URL- Backend API URLVITE_GOOGLE_CLIENT_ID- For Google Sign-In button
- Check if MONGO_URI is correct
- Verify IP whitelist in MongoDB Atlas
- Run
node testConnection.js
- Ensure backend CORS allows frontend URL
- Check FRONTEND_URL in backend .env
- Verify Client ID is set in both .env files
- Check authorized origins in Google Console
- Ensure Google+ API is enabled
- Integration Guide - Detailed setup instructions
- API Documentation - Complete API reference
- Database Schema - Database structure
β
MongoDB Connected
β
JWT Authentication Implemented
β
Google OAuth Ready (needs credentials)
β
Frontend-Backend Integration Complete
β
User Management Working
β
Protected Routes Configured
For issues or questions, please check:
- INTEGRATION_GUIDE.md
- Troubleshooting section
- Backend logs in terminal
- Set up Google OAuth credentials
- Test all authentication flows
- Add products to database
- Implement payment gateway
- Deploy to production
Happy Coding! π¨