A modern, full-stack e-commerce application for premium bags built with Node.js, Express, MongoDB, and EJS templating.
- User Authentication: Secure login/signup with JWT and bcrypt
- Product Browsing: View premium bag collections with detailed product information
- Shopping Cart: Add/remove products, view cart summary with pricing breakdown
- User Account: Personalized account page with order history
- Flash Messages: Real-time feedback for user actions
- Admin Dashboard: Comprehensive product management interface
- Product Management: Create, view, and delete products
- Image Upload: Multer integration for product image handling
- Inventory Control: Bulk delete functionality
- Protected Routes: Secure admin-only access with middleware
- Session Management: Express-session for persistent user sessions
- Cookie-based Auth: JWT tokens stored in HTTP-only cookies
- File Upload: Memory storage for product images
- Flash Messages: Connect-flash for user notifications
- Responsive UI: Modern Tailwind CSS design
- MongoDB Integration: Mongoose ODM for database operations
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT, bcrypt
- View Engine: EJS
- File Upload: Multer
- Styling: Tailwind CSS
- Icons: Remix Icon
- Session: Express-session
- Environment: dotenv
- Clone the repository
git clone <repository-url>
cd premium_bag_shop- Install dependencies
npm install- Environment Setup
Create a .env file in the root directory:
MONGODB_URI=mongodb://localhost:27017/scatch
SECRET=your-jwt-secret-key
PORT=4000- Start MongoDB
Make sure MongoDB is running on your system.
- Run the application
node app.jsThe app will run on http://localhost:4000
premium_bag_shop/
├── config/
│ ├── db.js # MongoDB connection
│ └── multer-config.js # File upload configuration
├── controller/
│ └── authController.js # Authentication logic
├── middlewares/
│ ├── isAdmin.js # Admin authentication
│ └── isLoggedin.js # User authentication
├── models/
│ ├── admin-model.js # Admin schema
│ ├── product-model.js # Product schema
│ └── user-model.js # User schema
├── routes/
│ ├── adminRoute.js # Admin routes
│ ├── index.js # Main routes
│ ├── productsRoute.js # Product routes
│ └── usersRoute.js # User routes
├── utils/
│ └── generateToken.js # JWT token generation
├── views/
│ ├── partials/
│ │ ├── header.ejs
│ │ └── footer.ejs
│ ├── account.ejs
│ ├── admin.ejs
│ ├── cart.ejs
│ ├── createproducts.ejs
│ ├── index.ejs
│ ├── owner-login.ejs
│ ├── shop.ejs
│ └── signup.ejs
├── app.js # Main application file
├── package.json
└── .gitignore
To create the first admin account, send a POST request to:
POST /admin/create
Content-Type: application/json
{
"fullname": "Admin Name",
"email": "admin@scatch.com",
"password": "securepassword"
}Note: Only one admin account can be created for security.
GET /- Login pageGET /signup- Registration pagePOST /users/register- Register new userPOST /users/login- User loginGET /users/logout- User logout
GET /shop- Browse products (protected)GET /cart- View shopping cart (protected)GET /account- User account page (protected)GET /addtocart/:id- Add product to cart (protected)GET /removefromcart/:id- Remove from cart (protected)
GET /admin/owner- Admin login pagePOST /admin/login- Admin loginGET /admin/logout- Admin logoutGET /admin/dashboard- Admin dashboard (protected)GET /admin/create-product- Product creation page (protected)GET /admin/delete/:id- Delete product (protected)GET /admin/delete-all- Delete all products (protected)
POST /products/create- Create new product (admin)
- Modern glassmorphism navigation
- Responsive grid layouts
- Smooth hover animations
- Product cards with dynamic colors
- Shopping cart with price calculations
- Flash message notifications
- Custom Tailwind styling
- Password hashing with bcrypt
- JWT token authentication
- HTTP-only cookies
- Protected routes with middleware
- Session management
- Admin-only access control
- fullname
- password (hashed)
- cart (array of product references)
- orders (array)
- contact
- picture
- image (Buffer)
- name
- price
- discount
- bgcolor
- panelcolor
- textcolor
- fullname
- password (hashed)
- products (array)
- picture
- gstin
Contributions are welcome! Please feel free to submit a Pull Request.
Created with ❤️ by Shahid Ansari
- Twitter: @Shahid_310_
- GitHub: @shahidansari310
- LinkedIn: shahidansari-/
ISC License
- Express.js team for the amazing framework
- MongoDB for the database
- Tailwind CSS for the styling framework
- Remix Icon for beautiful icons
Made with precision and care ✨