A Flipkart-inspired e-commerce application built with Node.js, Express, MySQL, and vanilla JavaScript.
ecommerce/
├── backend/ # Backend API server
│ ├── config/ # Database configuration
│ ├── controllers/ # Route controllers
│ ├── middlewares/ # Authentication middleware
│ ├── models/ # Database models
│ ├── routes/ # API routes
│ ├── app.js # Main server file
│ └── package.json # Backend dependencies
├── frontend/ # Frontend application
│ ├── assets/ # Product images and static files
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
│ ├── index.html # Home page
│ ├── login.html # Login page
│ ├── register.html # Registration page
│ ├── products.html # Products page
│ └── cart.html # Shopping cart page
├── database/ # Database setup files
│ └── setup.sql # Database schema and sample data
└── package.json # Root package.json
backend/modules/user.js
- Added password hashing in create methodbackend/modules/user.js
- Added password comparison methoddatabase/setup.sql
- Removed hardcoded hashed passwordauthController.js
was trying to import a non-existent user modelbackend/models/user.js
- Created User model with password hashingbackend/controllers/authController.js
- Fixed import pathdatabase/setup.sql
- Fixed cart table structurebackend/modules/product.js
- Updated field namesbackend/modules/order.js
- Fixed column namesbackend/controllers/productController.js
- Updated parameter names../modules/
pathbackend/controllers/authController.js
backend/controllers/productController.js
backend/controllers/cartController.js
backend/controllers/orderController.js
backend/middlewares/auth.js
backend/env.example
- Environment variables templatecd backend
npm install
cp env.example .env
# Edit .env with your database credentials and JWT secret
mysql -u root -p < ../database/setup.sql
npm run dev
frontend/assets/
smartphone.jpg
, laptop.jpg
, headphones.jpg
, smartwatch.jpg
, speaker.jpg
frontend/index.html
python -m http.server 8000
POST /api/auth/register
- User registrationPOST /api/auth/login
- User loginGET /api/auth/me
- Get current user (protected)GET /api/products
- Get all productsGET /api/products/:id
- Get product by IDPOST /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’s cartPOST /api/cart
- Add item to cartPUT /api/cart/:productId
- Update cart itemDELETE /api/cart/:productId
- Remove item from cartDELETE /api/cart
- Clear cartPOST /api/orders
- Create orderGET /api/orders
- Get user’s ordersGET /api/orders/:id
- Get order by IDThis project is licensed under the ISC License.