A production-ready, full-stack e-commerce platform for selling organic honey with complete authentication, cart management, checkout flow, and admin dashboard.
- ✅ User registration with password hashing (bcrypt)
- ✅ User login with JWT token-based authentication
- ✅ Logout functionality with session clearing
- ✅ Protected routes (cart, checkout, orders require login)
- ✅ Admin role-based access control
- ✅ Persistent authentication (survives page refresh)
- ✅ Add products to cart (login required)
- ✅ Update item quantities
- ✅ Remove items from cart
- ✅ Cart persists in database
- ✅ Cart syncs with backend API
- ✅ Real-time cart count in navbar
- ✅ Cart clears after successful checkout
- ✅ Browse all products
- ✅ Filter by honey type (Forest, Raw, Tulsi, Mustard)
- ✅ Detailed product pages with:
- Multiple size options (250g, 500g, 1kg)
- Lab test reports
- Health benefits
- Origin & harvest information
- Purity certifications
- Stock availability
- ✅ Complete checkout flow
- ✅ Shipping address collection
- ✅ Cash on Delivery payment option
- ✅ Order placement with validation
- ✅ Stock management (automatic deduction)
- ✅ Order confirmation page
- ✅ View all user orders
- ✅ Order detail pages with status tracking
- ✅ Admin login with role verification
- ✅ Product management (CRUD operations):
- Create new products
- Edit existing products
- Delete products
- Update stock levels
- ✅ Order management:
- View all orders
- Update order status
- Track customer information
- ✅ Protected admin routes
- ✅ Lab test report links
- ✅ Organic certification badges
- ✅ Purity guarantee information
- ✅ Adulteration testing details
- ✅ Origin & harvest information
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Token-based authentication
- bcryptjs - Password hashing
- CORS - Cross-origin resource sharing
- express-validator - Input validation
- React 18 - UI library
- Vite - Build tool
- React Router v6 - Routing
- Axios - HTTP client
- Tailwind CSS - Styling
- React Icons - Icon library
- React Toastify - Toast notifications
- Context API - State management
organic-honey-ecommerce/
├── backend/
│ ├── config/
│ │ └── db.js # MongoDB connection
│ ├── controllers/
│ │ ├── authController.js # Auth logic
│ │ ├── cartController.js # Cart logic
│ │ ├── orderController.js # Order logic
│ │ └── productController.js # Product logic
│ ├── middleware/
│ │ ├── auth.js # JWT authentication
│ │ └── errorHandler.js # Error handling
│ ├── models/
│ │ ├── User.js # User schema
│ │ ├── Product.js # Product schema
│ │ ├── Cart.js # Cart schema
│ │ └── Order.js # Order schema
│ ├── routes/
│ │ ├── authRoutes.js # Auth endpoints
│ │ ├── cartRoutes.js # Cart endpoints
│ │ ├── orderRoutes.js # Order endpoints
│ │ └── productRoutes.js # Product endpoints
│ ├── seeders/
│ │ └── seed.js # Database seeder
│ ├── utils/
│ │ └── generateToken.js # JWT token generator
│ ├── .env.example
│ ├── package.json
│ └── server.js # Entry point
│
├── frontend/
│ ├── src/
│ │ ├── api/
│ │ │ └── api.js # API configuration
│ │ ├── components/
│ │ │ ├── Navbar.jsx # Navigation bar
│ │ │ ├── Footer.jsx # Footer
│ │ │ └── ProtectedRoute.jsx
│ │ ├── context/
│ │ │ ├── AuthContext.jsx # Auth state
│ │ │ └── CartContext.jsx # Cart state
│ │ ├── pages/
│ │ │ ├── Home.jsx
│ │ │ ├── Products.jsx
│ │ │ ├── ProductDetail.jsx
│ │ │ ├── Login.jsx
│ │ │ ├── Register.jsx
│ │ │ ├── Cart.jsx
│ │ │ ├── Checkout.jsx
│ │ │ ├── Orders.jsx
│ │ │ ├── OrderDetail.jsx
│ │ │ ├── Admin.jsx
│ │ │ └── About.jsx
│ │ ├── App.jsx # Main app component
│ │ ├── main.jsx # Entry point
│ │ └── index.css # Global styles
│ ├── index.html
│ ├── package.json
│ ├── tailwind.config.js
│ └── vite.config.js
│
└── README.md
- Node.js (v16 or higher)
- MongoDB (local or MongoDB Atlas)
- npm or yarn
- Clone the repository
cd /home/sama/Desktop/assesement- Setup Backend
cd backend
npm installCreate .env file in backend directory:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/organic-honey
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
NODE_ENV=development- Setup Frontend
cd ../frontend
npm installCreate .env file in frontend directory:
VITE_API_URL=http://localhost:5000- Start MongoDB
# If using local MongoDB
mongod- Seed Database (Important!)
cd backend
# The server has a seed endpoint
# After starting the server, run:
curl -X POST http://localhost:5000/api/seed
# Or use any API client like Postman- Run the Application
Open two terminal windows:
Terminal 1 - Backend:
cd backend
npm run devTerminal 2 - Frontend:
cd frontend
npm run devThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Email:
admin@organichoney.com - Password:
admin123
You can register a new user or create one manually.
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/profile- Get user profile (Protected)PUT /api/auth/profile- Update user profile (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 cart (Protected)POST /api/cart- Add item to cart (Protected)PUT /api/cart/:itemId- Update cart item (Protected)DELETE /api/cart/:itemId- Remove item from cart (Protected)DELETE /api/cart- Clear cart (Protected)
POST /api/orders- Create order (Protected)GET /api/orders/myorders- Get user orders (Protected)GET /api/orders/:id- Get order by ID (Protected)GET /api/orders- Get all orders (Admin only)PUT /api/orders/:id/status- Update order status (Admin only)
- Visit http://localhost:3000
- Click "Sign Up" and create an account
- Browse products
- Click on a product to view details
- Select size and quantity, click "Add to Cart"
- View cart from navbar
- Update quantities or remove items
- Proceed to checkout
- Fill shipping information
- Place order
- View order confirmation
- Check "My Orders" to see order history
- Login with admin credentials
- Go to /admin
- Add/Edit/Delete products
- View and manage all orders
- Update order status
- User registration works
- User login works
- Logout works and clears session
- Protected routes redirect to login
- Auth persists after refresh
- Admin role verification
- Add to cart requires login
- Cart data stored in database
- Cart persists after refresh
- Update quantity works
- Remove item works
- Cart count in navbar updates
- Stock validation
- Checkout requires login
- Order placement works
- Stock reduces after order
- Cart clears after order
- Order confirmation shown
- Orders page shows user orders
- Order detail page works
- Admin login works
- Product CRUD operations
- Order management
- Status updates
- Responsive design (mobile, tablet, desktop)
- Toast notifications for user feedback
- Loading states
- Error handling
- Smooth transitions
- Intuitive navigation
- Clean organic theme (honey gold + natural green)
- Password hashing with bcrypt
- JWT token authentication
- Protected API routes
- Input validation
- CORS configuration
- XSS protection via React
- SQL injection prevention via Mongoose
- Push code to GitHub
- Connect to Render/Railway
- Add environment variables
- Deploy
- Build the app:
npm run build - Deploy dist folder
- Add environment variables
- Configure redirects for SPA
- Create cluster
- Get connection string
- Update MONGODB_URI in backend .env
This is a portfolio/assessment project.
MIT License
Built with ❤️ for organic honey lovers
Built a full-stack organic honey e-commerce platform with secure JWT authentication, persistent cart system, real-time order management, admin dashboard, and lab-verified product transparency using MERN stack (MongoDB, Express, React, Node.js)
- ✅ 100% Functional - No dummy features, everything works
- ✅ Database Persistent - All data stored in MongoDB
- ✅ Secure Authentication - JWT + bcrypt
- ✅ Real Cart System - Synced with backend
- ✅ Complete Checkout - From cart to order confirmation
- ✅ Admin Dashboard - Full CRUD operations
- ✅ Production Ready - Error handling, validation, security
- ✅ Responsive Design - Works on all devices
- ✅ Clean Code - Well-organized and documented
This project demonstrates proficiency in:
- Full-stack development
- RESTful API design
- Database modeling
- Authentication & Authorization
- State management
- Responsive UI/UX
- E-commerce workflows