- Introduction
- Features
- Technologies Used
- Project Structure
- Setup and Installation
- Endpoints
- Admin Dashboard
- License
This project is an E-Commerce Food Delivery Platform built using the MERN stack (MongoDB, Express, React, Node.js) (well for now we opted to use EJS in place of REACT to meet our deadline!). The platform allows users to browse, select, and order various food items. It includes features like user authentication, product management, order placement, and an admin dashboard for managing products.
- User Authentication: Secure sign-up, sign-in, and role-based access control.
- Product Management: Add, update, delete, and view products with image upload functionality.
- Cart and Checkout: Users can add items to their cart and proceed to checkout.
- Order Management: Users can place orders, and admin users can manage these orders.
- Admin Dashboard: A visually appealing and functional dashboard for admins to manage the platform.
- Backend: Node.js, Express.js, MongoDB, Mongoose
- Frontend: EJS (Embedded JavaScript), Css for styling
- Authentication: JWT (JSON Web Token)
- File Upload: Multer
- Database: MongoDB
- Other: REST API, Postman for API testing
.
├── controllers
│ ├── authController.js
│ ├── cartController.js
│ ├── productController.js
│ ├── orderController.js
├── models
│ ├── user.js
│ ├── product.js
│ ├── order.js
│ ├── cart.js
├── routes
│ ├── authRoutes.js
│ ├── productRoutes.js
│ ├── cartRoutes.js
│ ├── orderRoutes.js
├── views
│ ├── admin
│ │ ├── dashboard.ejs
│ │ ├── products.ejs
│ │ ├── orders.ejs
│ ├── auth
│ │ ├── signin.ejs
│ │ ├── signup.ejs
│ ├── cart.ejs
│ ├── checkout.ejs
├── public
│ ├── css
│ ├── js
│ ├── images
├── server.js
├── README.md
└── .env
-
Clone the repository:
git clone https://github.com/yourusername/chefDomain.git cd chefDomain
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add your environment variables:PORT=5000 MONGO_URI=your_mongo_db_connection_string JWT_SECRET=your_jwt_secret
-
Run the server:
npm start
-
Access the application: Open your browser and go to
http://localhost:5000
.
- POST
/auth/signup
- Register a new user - POST
/auth/signin
- Sign in a user
- POST
/api/products
- Create a new product (Admin only) - GET
/api/products
- Get all products - GET
/api/products/:id
- Get product by ID - PUT
/api/products/:id
- Update a product by ID (Admin only) - DELETE
/api/products/:id
- Delete a product by ID (Admin only) - POST
/api/products/:id/upload
- Upload product images (Admin only)
- POST
/api/orders
- Place a new order (User) - GET
/api/orders/:id
- Get order by ID (Admin) - GET
/api/orders
- Get all orders (Admin)
- GET
/cart
- View cart items - POST
/cart
- Add item to cart - DELETE
/cart/:id
- Remove item from cart
- GET
/checkout
- View the checkout page
The admin dashboard provides a clean interface for managing products and orders.
- Dashboard: Overview of the platform.
- Products: List of all products with options to add, edit, or delete.
- Orders: List of all orders placed by users.
dashboard.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<link rel="stylesheet" href="/static/css/admin.css">
</head>
<body>
<div class="dashboard">
<h1>Welcome, Admin</h1>
<div class="stats">
<div>Total Products: <%= totalProducts %></div>
<div>Total Orders: <%= totalOrders %></div>
</div>
</div>
</body>
</html>
products.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product Management</title>
<link rel="stylesheet" href="/static/css/admin.css">
</head>
<body>
<div class="products">
<h1>Manage Products</h1>
<a href="/admin/products/new">Add New Product</a>
<ul>
<% products.forEach(product => { %>
<li><%= product.name %> - <%= product.price %></li>
<% }) %>
</ul>
</div>
</body>
</html>
This project is licensed under the MIT License. See the LICENSE file for details.