BrewBytes is a backend system built to manage the online presence of a coffee shop, handling products, orders, user profiles, loyalty points, and payments. The backend is built using Node.js, Express, and MongoDB. It supports features for both customers and admins, including product management, order processing, user authentication, payment handling, and review system.
- Node.js: Backend runtime environment.
- Express: Web framework for Node.js.
- MongoDB: NoSQL database for storing user, product, and order data.
- Mongoose: ODM for MongoDB.
- Razorpay: Payment gateway integration.
- JWT: JSON Web Tokens for user authentication.
- Nodemailer: For sending order-related emails.
-
Clone the repository:
git clone https://github.com/your-repo/brewbytes-backend.git
-
Navigate to the project directory:
cd brewbytes-backend -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add the following:MONGO_URI=your_mongo_connection_string JWT_SECRET=your_jwt_secret RAZORPAY_KEY_ID=your_razorpay_key_id RAZORPAY_KEY_SECRET=your_razorpay_key_secret EMAIL_HOST=smtp.your-email.com EMAIL_PORT=587 EMAIL_USER=your_email@example.com EMAIL_PASS=your_email_password
-
Run the server:
npm run dev
The backend will be running at
http://localhost:5000.
POST /api/v1/auth/login- Log in a user.POST /api/v1/auth/signup- Register a new user.POST /api/v1/auth/sendotp- Send an OTP to the user's email for verification.POST /api/v1/auth/changepassword- Change the password of the logged-in user.POST /api/v1/auth/reset-password-token- Request a password reset token.POST /api/v1/auth/reset-password- Reset the user's password.POST /api/v1/auth/contact-us- Contact form submission.
DELETE /api/v1/profile/deleteProfile- Delete the logged-in user's account.PUT /api/v1/profile/updateProfile- Update the user's profile information.GET /api/v1/profile/getUserDetails- Get the details of the logged-in user.GET /api/v1/profile/getAllOrdersOfUser- Get all orders made by the logged-in user.PUT /api/v1/profile/updateDisplayPicture- Update the user's display picture.
GET /api/v1/product/getAvailableProducts- Get all available products for sale.GET /api/v1/product/getProductAllDetails- Get detailed information for a specific product.GET /api/v1/product/getMenuItems- Get the menu items available for customers.
GET /api/v1/admin/getAllProducts- View all products.POST /api/v1/admin/addProduct- Add a new product to the inventory.PUT /api/v1/admin/updateProduct- Update an existing product.DELETE /api/v1/admin/deleteProduct- Delete a product from the inventory.PUT /api/v1/admin/updateOrderStatus- Update the status of an order (Pending, Delivered, Canceled).GET /api/v1/admin/logs- View admin activity logs.POST /api/v1/admin/addMenuItem- Add an item to the menu.DELETE /api/v1/admin/removeMenuItem- Remove an item from the menu.
POST /api/v1/payment/capturePayment- Capture payment for an order using Razorpay.POST /api/v1/payment/verifyPayment- Verify the payment after capture.POST /api/v1/payment/sendPaymentSuccessEmail- Send an email confirming successful payment.
POST /api/v1/rating/createRating- Add a rating and review for a product.PUT /api/v1/rating/updateRating- Update an existing rating and review.DELETE /api/v1/rating/deleteRating- Delete a rating and review.GET /api/v1/rating/getRatings- Get all ratings and reviews for a product.
auth: Ensures that the user is authenticated using JWT.isAdmin: Checks if the authenticated user has admin privileges.isCustomer: Ensures the authenticated user is a customer.
name: Stringemail: Stringpassword: String (hashed)loyaltyPoints: Numberpurchase: Array of order references
name: Stringdescription: Stringprice: Numberstock: Numbercategory: StringmenuItem: Boolean
customer: User referenceitems: Array of ordered items (product reference, quantity, price)totalAmount: NumberorderDate: Datestatus: String (Pending, Delivered, Canceled)loyaltyPointsEarned: NumberpaymentStatus: String (Paid, Unpaid)
order: Order referencecustomer: User referenceamount: NumberpaymentStatus: String (Completed, Failed)
This backend for BrewBytes provides a robust API for managing users, products, orders, and payments. The admin has full control over product inventory, while customers can seamlessly browse, order, and review products. Payment integration with Razorpay ensures secure transactions, and loyalty points are rewarded based on customer activity.