Skip to content

AryanBhati02/ProjectFarmFresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 FarmFresh β€” Farm to Table, Delivered Fresh

A full-stack e-commerce platform connecting local farmers directly to urban families. Built with Node.js, Express, MongoDB & EJS.

FarmFresh Banner Node.js MongoDB Express License


πŸ“Έ Preview

Page Description
🏠 Homepage Hero section, featured products, testimonials
πŸ›’ Explore Filter by category, tags, search & sort
πŸ“¦ Cart Live drawer cart + dedicated cart page
βœ… Checkout COD / Online payment, order saved to DB
πŸ‘€ Profile User details + full order history
πŸ›‘οΈ Admin Dashboard, product CRUD, order management

✨ Features

πŸ§‘β€πŸ’» Customer Side

  • Dynamic Homepage β€” hero with live product cards, featured picks, new arrivals & testimonials
  • Smart Explore Page β€” search, filter by category, filter by tag (Organic, Best Seller, Seasonal, New), sort by price / name
  • Live Cart β€” localStorage-powered cart drawer available on every page, with quantity controls
  • Full Cart Page β€” editable cart with order summary and delivery threshold tracker (free above β‚Ή499)
  • Checkout β€” auto-fills details for logged-in users, supports COD & Online payment, saves order to MongoDB
  • Order Confirmation β€” dedicated success page with full order breakdown
  • Authentication β€” register, login, logout with bcrypt-hashed passwords & secure sessions
  • User Profile β€” update name, phone, address; view complete order history with status badges

πŸ›‘οΈ Admin Panel (/admin)

  • Dashboard β€” real-time stats: total products, orders, users, and cumulative revenue
  • Product Management β€” full CRUD (add, edit, delete) with image upload via Multer
  • Order Management β€” view all orders, update statuses (Pending β†’ Confirmed β†’ Shipped β†’ Delivered β†’ Cancelled)
  • Protected routes β€” requireAdmin middleware blocks unauthorized access

πŸš€ Getting Started

Prerequisites

1. Clone the repository

git clone https://github.com/yourusername/ProjectFarmFresh.git
cd ProjectFarmFresh

2. Install dependencies

npm install

3. Configure environment variables

cp .env.example .env

Open .env and fill in your values:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/farmfresh
SESSION_SECRET=pick_a_long_random_string_here
NODE_ENV=development

4. Seed the database

npm run seed

This loads 18 products across 6 categories and creates an admin account:

Field Value
Email admin@farmfresh.in
Password admin1234

⚠️ Change the admin password after your first login in production.

5. Start the server

npm run dev     # development β€” auto-restarts on changes (nodemon)
npm start       # production

Open http://localhost:3000 πŸŽ‰


πŸ“ Project Structure

ProjectFarmFresh/
β”‚
β”œβ”€β”€ app.js                        # Express server entry point
β”œβ”€β”€ seed.js                       # Database seeder (products + admin)
β”œβ”€β”€ .env.example                  # Environment variable template
β”‚
β”œβ”€β”€ data/
β”‚   └── products.json             # 18 seed products
β”‚
β”œβ”€β”€ middleware/
β”‚   └── auth.js                   # requireLogin & requireAdmin guards
β”‚
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ User.js                   # User schema (bcrypt, sessions)
β”‚   β”œβ”€β”€ Product.js                # Product schema (category, tags, image, stock)
β”‚   └── Order.js                  # Order schema (items, status, guest support)
β”‚
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ productRoutes.js          # /, /explore, /cart, /checkout, /api/products
β”‚   β”œβ”€β”€ authRoutes.js             # /login, /register, /logout, /profile
β”‚   β”œβ”€β”€ contactRoutes.js          # /contact
β”‚   └── adminRoutes.js            # /admin/**
β”‚
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ partials/
β”‚   β”‚   β”œβ”€β”€ header.ejs            # Sticky nav, cart drawer, flash messages
β”‚   β”‚   └── footer.ejs            # Footer, cart drawer HTML, toast
β”‚   β”‚
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ _sidebar.ejs
β”‚   β”‚   β”œβ”€β”€ dashboard.ejs
β”‚   β”‚   β”œβ”€β”€ manageProducts.ejs
β”‚   β”‚   β”œβ”€β”€ addProduct.ejs
β”‚   β”‚   β”œβ”€β”€ editProduct.ejs
β”‚   β”‚   └── orders.ejs
β”‚   β”‚
β”‚   β”œβ”€β”€ index.ejs                 # Homepage
β”‚   β”œβ”€β”€ explore.ejs               # Browse + filter products
β”‚   β”œβ”€β”€ cart.ejs                  # Full cart page
β”‚   β”œβ”€β”€ checkout.ejs              # Checkout form
β”‚   β”œβ”€β”€ order-success.ejs         # Order confirmation
β”‚   β”œβ”€β”€ login.ejs                 # Login + Register (tabbed)
β”‚   β”œβ”€β”€ profile.ejs               # User profile + order history
β”‚   β”œβ”€β”€ about.ejs
β”‚   β”œβ”€β”€ contact.ejs
β”‚   β”œβ”€β”€ 404.ejs
β”‚   └── 403.ejs
β”‚
└── public/
    β”œβ”€β”€ css/
    β”‚   β”œβ”€β”€ style.css             # Global styles
    β”‚   └── admin.css             # Admin panel styles
    β”œβ”€β”€ js/
    β”‚   └── main.js               # Cart logic (localStorage), toast, drawer
    └── images/                   # Product images uploaded via admin

πŸ”§ Environment Variables

Variable Description Default
PORT Port the server runs on 3000
MONGODB_URI MongoDB connection string mongodb://localhost:27017/farmfresh
SESSION_SECRET Secret key for session encryption (change in production!)
NODE_ENV development or production development

πŸ›  Tech Stack

Layer Technology Purpose
Runtime Node.js v18+ JavaScript server runtime
Framework Express.js 4.19 HTTP routing & middleware
Database MongoDB + Mongoose 8 Data persistence & ODM
Templating EJS Server-side HTML rendering
Auth bcryptjs + express-session Password hashing & session management
Sessions connect-mongo Persistent sessions stored in MongoDB
File Upload Multer Product image uploads
Dev Tool Nodemon Auto-restart on file changes
Fonts Google Fonts Playfair Display + DM Sans

🌐 Routes Overview

Method Route Access Description
GET / Public Homepage
GET /explore Public Browse & filter products
GET /api/products Public JSON product API
GET /cart Public Cart page
GET /checkout Public Checkout page
POST /checkout Public Place order β†’ {success, orderId}
GET /order-success/:id Public Order confirmation
GET/POST /login Guest Login
GET/POST /register Guest Register
GET /logout β€” Destroy session
GET/POST /profile πŸ”’ Login Profile & orders
GET /admin πŸ›‘οΈ Admin Dashboard
GET/POST /admin/products/add πŸ›‘οΈ Admin Add product
GET/POST /admin/products/edit/:id πŸ›‘οΈ Admin Edit product
POST /admin/products/delete/:id πŸ›‘οΈ Admin Delete product
GET /admin/orders πŸ›‘οΈ Admin All orders
POST /admin/orders/status/:id πŸ›‘οΈ Admin Update order status

πŸ”„ Version History

Version Description
v2.0 Full-stack rebuild β€” Express + MongoDB + Admin Panel + Auth + Orders
v1.0 Original college project β€” static HTML/CSS/JS with EJS templates

🀝 Contributing

Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.

  1. Fork the repository
  2. Create your branch: git checkout -b feature/your-feature-name
  3. Commit your changes: git commit -m 'Add: your feature description'
  4. Push to branch: git push origin feature/your-feature-name
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.


πŸ‘¨β€πŸ’» Author

| Aryan Bhati |

"From the field to your table β€” fresh, honest, and fairly priced."


⭐ If you found this project useful, give it a star!

About

Scalable full-stack grocery e-commerce platform built with Node.js, Express, and MongoDB, featuring MVC architecture, authentication, admin dashboard, order processing, and email integration.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors