A full-stack e-commerce application built with React, Node.js, and MongoDB. This project demonstrates modern web development practices including authentication, real-time cart management, product filtering, and an admin panel.
- Direct Platform Access: Guests can immediately browse the catalog and add products to cart
- User Authentication: Secure JWT login with pre-configured demo credentials
- Product Catalog: Browse products with search and filtering by category/price
- Shopping Cart: Add/remove items, update quantities, persistent storage
- Checkout Process: Complete order flow with order confirmation
- User Dashboard: View order history and manage profile
- Admin Panel: Manage products (with custom image URLs), view orders, and update order status
- Responsive Design: Mobile-first design that works on all devices
- React 19 - UI framework
- Tailwind CSS v4 - Styling
- React Router - Client-side routing
- Context API - State management
- Axios - HTTP client
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- Bcryptjs - Password hashing
- Frontend: Vercel
- Backend: Render/Railway
- Database: MongoDB Atlas
- Node.js (v14+)
- npm or yarn
- MongoDB Atlas account (free at https://www.mongodb.com/cloud/atlas)
- Clone the repository
git clone https://github.com/Friedayy/ecommerce-platform.git
cd ecommerce-platform- Backend Setup
cd backend
npm installCreate a .env file in the backend folder (copy from .env.example):
PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/ecommerce?retryWrites=true&w=majority
JWT_SECRET=your_super_secret_jwt_key_here_change_this_in_production
JWT_EXPIRE=30d
FRONTEND_URL=http://localhost:5173
- Frontend Setup
cd ../frontend
npm installCreate a .env file in the frontend folder (copy from .env.example):
VITE_API_URL=http://localhost:5000/api
cd backend
npm run devBackend will run on http://localhost:5000
cd frontend
npm run devFrontend will run on http://localhost:5173
ecommerce-platform/
โโโ backend/
โ โโโ models/ # MongoDB schemas
โ โโโ routes/ # API routes
โ โโโ controllers/ # Route handlers
โ โโโ middleware/ # Custom middleware
โ โโโ config/ # Configuration files
โ โโโ utils/ # Utility functions
โ โโโ server.js # Main server file
โ โโโ package.json
โ โโโ .env.example
โ
โโโ frontend/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ context/ # Context API setup
โ โ โโโ services/ # API services
โ โ โโโ App.jsx
โ โ โโโ main.jsx
โ โโโ package.json
โ โโโ vite.config.js
โ โโโ tailwind.config.js
โ โโโ .env.example
โ
โโโ .gitignore
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user (protected)
GET /api/products- Get all products with filtersGET /api/products/:id- Get product detailsPOST /api/products- Create product (admin only)PUT /api/products/:id- Update product (admin only)DELETE /api/products/:id- Delete product (admin only)
GET /api/cart- Get user cartPOST /api/cart/add- Add item to cartPUT /api/cart/update- Update cart itemDELETE /api/cart/remove/:itemId- Remove item from cart
POST /api/orders- Create orderGET /api/orders- Get user ordersGET /api/orders/:id- Get order detailsGET /api/admin/orders- Get all orders (admin only)
GET /api/reviews/product/:productId- Get product reviewsPOST /api/reviews- Create reviewPUT /api/reviews/:id- Update reviewDELETE /api/reviews/:id- Delete review
Problem: How to securely manage user sessions across frontend and backend Solution:
- Tokens stored in localStorage on frontend
- Tokens included in request headers via Axios interceptor
- Refresh token mechanism for extended sessions
Problem: User cart data needs to persist across page refreshes and sessions Solution:
- Cart stored in Context API for real-time updates
- Synced with backend database for logged-in users
- LocalStorage backup for guest users
Problem: Product images need to be uploaded and served efficiently Solution:
- Multer middleware for file handling
- Images stored in local uploads folder
- Base64 encoding for small thumbnails
Problem: Prevent overselling when multiple users order simultaneously Solution:
- Database transactions for order creation
- Inventory check before order confirmation
- Stock update on successful payment
- Payment gateway integration (Stripe/Razorpay)
- Email notifications for orders
- Wishlist feature
- Social login (Google, GitHub)
- Product recommendations
- Advanced analytics dashboard
- Real-time order tracking
- Multi-language support
- Dark mode
- Unit and integration tests
Frontend: [Will be deployed to Vercel] Backend: [Will be deployed to Render]
[Screenshots will be added after deployment]
- Password hashing with bcryptjs
- JWT-based authentication
- Protected API routes with middleware
- Input validation and sanitization
- CORS configuration
- Environment variables for sensitive data
- SQL injection prevention (using Mongoose)
# Run backend tests (to be implemented)
cd backend && npm test
# Run frontend tests (to be implemented)
cd frontend && npm testThis project follows conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentationstyle:- Code style changesrefactor:- Code refactoringtest:- Adding tests
This project is licensed under the ISC License.
Mohammad Amaan Bhat
- GitHub: @Friedayy
- Email: amaandev253@gmail.com
- Portfolio: amaandev.me
This is a personal project for learning and portfolio purposes. Feel free to fork and create your own version!
Built with โค๏ธ for Accenture Internship