A full-stack e-commerce platform connecting local farmers directly to urban families. Built with Node.js, Express, MongoDB & EJS.
| 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 |
- 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
- 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 β
requireAdminmiddleware blocks unauthorized access
- Node.js v18 or higher
- MongoDB running locally or a free MongoDB Atlas cluster
git clone https://github.com/yourusername/ProjectFarmFresh.git
cd ProjectFarmFreshnpm installcp .env.example .envOpen .env and fill in your values:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/farmfresh
SESSION_SECRET=pick_a_long_random_string_here
NODE_ENV=developmentnpm run seedThis loads 18 products across 6 categories and creates an admin account:
| Field | Value |
|---|---|
admin@farmfresh.in |
|
| Password | admin1234 |
β οΈ Change the admin password after your first login in production.
npm run dev # development β auto-restarts on changes (nodemon)
npm start # productionOpen http://localhost:3000 π
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
| 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 |
| 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 |
| 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 | Description |
|---|---|
| v2.0 | Full-stack rebuild β Express + MongoDB + Admin Panel + Auth + Orders |
| v1.0 | Original college project β static HTML/CSS/JS with EJS templates |
Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
- Fork the repository
- Create your branch:
git checkout -b feature/your-feature-name - Commit your changes:
git commit -m 'Add: your feature description' - Push to branch:
git push origin feature/your-feature-name - Open a Pull Request
This project is licensed under the MIT License.
| Aryan Bhati |
"From the field to your table β fresh, honest, and fairly priced."
β If you found this project useful, give it a star!