A modern, fully-featured e-commerce web application built with vanilla JavaScript that includes product management, shopping cart functionality, and persistent data storage.
- Product Management - Complete CRUD operations (Create, Read, Update, Delete)
- Shopping Cart System - Add products, adjust quantities, view totals
- Product Search - Real-time search and filtering capabilities
- Persistent Storage - All data saved using localStorage
- Order Summary - Dynamic price calculation and item count
- Edit Mode - Seamlessly edit existing products
- Responsive Design - Mobile-first approach, works on all devices
- Dynamic Rendering - Efficient DOM manipulation without page reloads
- Local Storage Integration - Complete data persistence across sessions
- State Management - Centralized product and cart state
- Event Delegation - Optimized event handling for dynamic elements
- Modular Architecture - Clean, maintainable code structure
- Form Validation - Ensures all product details are provided
- Navigation System - Smooth page transitions between sections
- Product Management β Add new products with details (name, category, price, description, image)
- Browse Products β View all products in a grid layout with search functionality
- Shopping Cart β Add items, adjust quantities, view order summary
- Edit Products β Update existing product information
- Persistence β All data saved automatically and restored on page reload
- HTML5 - Semantic markup structure
- CSS3 - Modern styling with Tailwind CSS 4.0
- JavaScript (ES6+) - Vanilla JS, no frameworks required
- LocalStorage API - Client-side data persistence
- Tailwind CSS - Utility-first CSS framework
- Font Awesome - Icon library
- A modern web browser (Chrome, Firefox, Safari, Edge)
- Basic understanding of HTML/CSS/JavaScript (for modifications)
- Clone the repository
git clone https://github.com/yourusername/PR-E-COMMERCE-JS.git
cd PR-E-COMMERCE-JS- Open in browser
# Option 1: Direct file open
open index.html
# Option 2: Using a local server (recommended)
# Python 3
python -m http.server 8000
# Node.js with http-server
npx http-server
# VS Code Live Server extension
# Right-click index.html β Open with Live Server- Access the app
http://localhost:8000
That's it! No build process or dependencies required. π
PR-E-COMMERCE-JS/
β
βββ index.html # Main product listing page
βββ products.html # Add/Edit product form page
βββ add_to_cart.html # Shopping cart page
βββ JS/
β βββ script.js # Application logic
βββ img/ # Product images folder
βββ README.md # Documentation
βββ .gitignore # Git ignore rules
index.html
- Product grid display
- Search functionality
- Product cards with actions (Edit, Delete, Add to Cart)
products.html
- Product form (Add/Edit mode)
- Input fields for product details
- Form validation
add_to_cart.html
- Shopping cart table
- Quantity controls (+/-)
- Order summary
- Place order button
script.js
- Product and cart state management
- CRUD operations
- LocalStorage integration
- Event handlers
- Dynamic rendering functions
-
Add New Product
- Navigate to "Add Product" page
- Fill in product details (Name, Category, Price, Description, Image URL)
- Click "Add Product"
-
Browse Products
- View all products on main page
- Use search bar to filter products
- Click on product cards to interact
-
Edit Product
- Click "Edit" button on any product card
- Modify product details in form
- Click "Save Changes"
-
Delete Product
- Click "Delete" button on product card
- Product removed immediately
-
Shopping Cart
- Click "Add to Cart" on any product
- Navigate to cart page
- Use +/- buttons to adjust quantities
- View order summary with totals
- Click "Place Order" (functionality coming soon)
-
Search Products
- Type in search box on main page
- Products filter in real-time
Extend the productDetails object structure in script.js:
productDetails = {
id: 1234,
pName: "Product Name",
pCategory: "Category",
pPrice: 999,
pDescription: "Description",
pUrl: "image-url.jpg",
// Add new properties here
};Update the renderProduct() function in script.js:
function renderProduct(data) {
cardContent.innerHTML = `
<!-- Customize HTML structure here -->
<img src="${data.pUrl}" alt="${data.pName}" />
<h3>${data.pName}</h3>
<!-- Add more elements -->
`;
}Modify the cart table structure in the renderCart() function:
cartRow.innerHTML = `
<td>${cProduct.pName}</td>
<td>${cProduct.quantity}</td>
<!-- Add more columns -->
`;To reset application state:
localStorage.removeItem("products");
localStorage.removeItem("cartProducts");
location.reload();products- Array of all product objectscartProducts- Array of cart items with quantitieseditProductID- Temporary storage for product being edited
{
id: 1234, // Unique identifier
pName: "Product Name", // Product name
pCategory: "Electronics", // Product category
pPrice: 999, // Product price (number)
pDescription: "...", // Product description
pUrl: "image.jpg" // Product image URL
}{
id: 1234, // Product ID
pName: "Product Name",
pPrice: 999,
pUrl: "image.jpg",
quantity: 2 // Number of items in cart
}Current theme colors:
Background: #ffffff (white)
Cards: border-[#e6e9ee]
Buttons:
- Blue: bg-blue-500, hover:bg-blue-600
- Red: bg-red-500, hover:bg-red-600
- Green: bg-green-500, hover:bg-green-600
- Gray: bg-gray-200, hover:bg-gray-300
Text:
- Primary: text-gray-900
- Secondary: text-gray-600
Price: text-blue-600- Mobile: < 640px
- Tablet: 640px - 1024px
- Desktop: > 1024px
- Place Order button is placeholder (functionality pending)
- No backend integration for persistent storage
- Random ID generation may produce duplicates (low probability)
- No image upload functionality (uses URL input)
- No pagination for large product lists
- Backend API integration (Node.js/Express)
- User authentication and authorization
- Payment gateway integration
- Product categories filtering
- Image upload functionality
- Product reviews and ratings
- Order history tracking
- Email notifications
- Pagination for products
- Advanced search filters
- Wishlist feature
- Product recommendations
- Invoice generation
- Admin dashboard
- Analytics and reporting
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style and structure
- Add comments for complex logic
- Test on multiple browsers
- Update README for new features
- Use semantic commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: rudra2609-06
- LinkedIn: Rudra Thakkar
- Email: rudra22822@gmail.com
- Tailwind CSS - For the utility-first CSS framework
- Font Awesome - For the icon library
- MDN Web Docs - For JavaScript documentation
- LocalStorage API - For data persistence
If you have any questions or need help, feel free to:
- Open an issue on GitHub
- Send an email to your rudra22822@gmail.com
- Reach out on LinkedIn
Made with β€οΈ and JavaScript
β Star this repo if you found it helpful!


