Skip to content

About

โ”‚ ๐Ÿ›’ A modern, full-stack e-commerce platform โ”‚ authentication, dynamic cart management, order processingโ”‚ role-based admin dashboard.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›’ E-Commerce Platform

React 19 Node.js Express.js MongoDB Atlas Tailwind CSS v4 Vite JWT

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.

โœจ Features

  • 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

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 19 - UI framework
  • Tailwind CSS v4 - Styling
  • React Router - Client-side routing
  • Context API - State management
  • Axios - HTTP client

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • MongoDB - NoSQL database
  • Mongoose - ODM for MongoDB
  • JWT - Authentication
  • Bcryptjs - Password hashing

Deployment

  • Frontend: Vercel
  • Backend: Render/Railway
  • Database: MongoDB Atlas

๐Ÿ“ฆ Installation

Prerequisites

Setup

  1. Clone the repository
git clone https://github.com/Friedayy/ecommerce-platform.git
cd ecommerce-platform
  1. Backend Setup
cd backend
npm install

Create 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
  1. Frontend Setup
cd ../frontend
npm install

Create a .env file in the frontend folder (copy from .env.example):

VITE_API_URL=http://localhost:5000/api

๐Ÿš€ Running Locally

Start the Backend

cd backend
npm run dev

Backend will run on http://localhost:5000

Start the Frontend

cd frontend
npm run dev

Frontend will run on http://localhost:5173

๐Ÿ“ Project Structure

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

๐Ÿ”‘ API Endpoints (Core)

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user (protected)

Products

  • GET /api/products - Get all products with filters
  • GET /api/products/:id - Get product details
  • POST /api/products - Create product (admin only)
  • PUT /api/products/:id - Update product (admin only)
  • DELETE /api/products/:id - Delete product (admin only)

Cart

  • GET /api/cart - Get user cart
  • POST /api/cart/add - Add item to cart
  • PUT /api/cart/update - Update cart item
  • DELETE /api/cart/remove/:itemId - Remove item from cart

Orders

  • POST /api/orders - Create order
  • GET /api/orders - Get user orders
  • GET /api/orders/:id - Get order details
  • GET /api/admin/orders - Get all orders (admin only)

Reviews

  • GET /api/reviews/product/:productId - Get product reviews
  • POST /api/reviews - Create review
  • PUT /api/reviews/:id - Update review
  • DELETE /api/reviews/:id - Delete review

๐ŸŽฏ Key Challenges & Solutions

Challenge 1: JWT Token Management

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

Challenge 2: Cart State Persistence

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

Challenge 3: Image Upload & Storage

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

Challenge 4: Real-time Inventory Management

Problem: Prevent overselling when multiple users order simultaneously Solution:

  • Database transactions for order creation
  • Inventory check before order confirmation
  • Stock update on successful payment

๐Ÿ”ฎ Future Enhancements

  • 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

๐ŸŒ Live Demo

Frontend: [Will be deployed to Vercel] Backend: [Will be deployed to Render]

๐Ÿ“ธ Screenshots

[Screenshots will be added after deployment]

๐Ÿ” Security Features

  • 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)

๐Ÿงช Testing

# Run backend tests (to be implemented)
cd backend && npm test

# Run frontend tests (to be implemented)
cd frontend && npm test

๐Ÿ“ Git Workflow

This project follows conventional commits:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation
  • style: - Code style changes
  • refactor: - Code refactoring
  • test: - Adding tests

๐Ÿ“„ License

This project is licensed under the ISC License.

๐Ÿ‘จโ€๐Ÿ’ป Author

Mohammad Amaan Bhat

๐Ÿค Contributing

This is a personal project for learning and portfolio purposes. Feel free to fork and create your own version!


Built with โค๏ธ for Accenture Internship

About

โ”‚ ๐Ÿ›’ A modern, full-stack e-commerce platform โ”‚ authentication, dynamic cart management, order processingโ”‚ role-based admin dashboard.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages