Skip to content

Repository files navigation

🍯 Organic Honey E-Commerce - Full Stack MERN Application

A production-ready, full-stack e-commerce platform for selling organic honey with complete authentication, cart management, checkout flow, and admin dashboard.

✨ Features

🔐 Authentication (Fully Functional)

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

🛒 Cart Management (Fully Functional)

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

🛍️ Product Features

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

💳 Checkout & Orders (Fully Functional)

  • ✅ 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 Dashboard (Fully Functional)

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

🌿 Trust & Transparency Features

  • ✅ Lab test report links
  • ✅ Organic certification badges
  • ✅ Purity guarantee information
  • ✅ Adulteration testing details
  • ✅ Origin & harvest information

🛠️ Tech Stack

Backend

  • 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

Frontend

  • 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

📁 Project Structure

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

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or MongoDB Atlas)
  • npm or yarn

Installation

  1. Clone the repository
cd /home/sama/Desktop/assesement
  1. Setup Backend
cd backend
npm install

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

Create .env file in frontend directory:

VITE_API_URL=http://localhost:5000
  1. Start MongoDB
# If using local MongoDB
mongod
  1. 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
  1. Run the Application

Open two terminal windows:

Terminal 1 - Backend:

cd backend
npm run dev

Terminal 2 - Frontend:

cd frontend
npm run dev

The application will be available at:

🔑 Default Credentials

Admin Account

  • Email: admin@organichoney.com
  • Password: admin123

Test User

You can register a new user or create one manually.

📋 API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/profile - Get user profile (Protected)
  • PUT /api/auth/profile - Update user profile (Protected)

Products

  • GET /api/products - Get all products
  • GET /api/products/:id - Get product by ID
  • 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 (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)

Orders

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

🧪 Testing the Application

User Flow

  1. Visit http://localhost:3000
  2. Click "Sign Up" and create an account
  3. Browse products
  4. Click on a product to view details
  5. Select size and quantity, click "Add to Cart"
  6. View cart from navbar
  7. Update quantities or remove items
  8. Proceed to checkout
  9. Fill shipping information
  10. Place order
  11. View order confirmation
  12. Check "My Orders" to see order history

Admin Flow

  1. Login with admin credentials
  2. Go to /admin
  3. Add/Edit/Delete products
  4. View and manage all orders
  5. Update order status

✅ Features Checklist

Authentication ✅

  • User registration works
  • User login works
  • Logout works and clears session
  • Protected routes redirect to login
  • Auth persists after refresh
  • Admin role verification

Cart ✅

  • 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 & Orders ✅

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

  • Admin login works
  • Product CRUD operations
  • Order management
  • Status updates

🎨 UI/UX Features

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

🔒 Security Features

  • Password hashing with bcrypt
  • JWT token authentication
  • Protected API routes
  • Input validation
  • CORS configuration
  • XSS protection via React
  • SQL injection prevention via Mongoose

📦 Deployment

Backend (Render/Railway)

  1. Push code to GitHub
  2. Connect to Render/Railway
  3. Add environment variables
  4. Deploy

Frontend (Vercel/Netlify)

  1. Build the app: npm run build
  2. Deploy dist folder
  3. Add environment variables
  4. Configure redirects for SPA

Database (MongoDB Atlas)

  1. Create cluster
  2. Get connection string
  3. Update MONGODB_URI in backend .env

🤝 Contributing

This is a portfolio/assessment project.

📄 License

MIT License

👨‍💻 Developer

Built with ❤️ for organic honey lovers


💼 Resume One-Liner

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)


🎯 Project Highlights

  • 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

simran

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages