This is the backend server for the Bréw Connect full-stack e-commerce application. It is a RESTful API built with Node.js and Express, connected to a MongoDB database. It handles all data management, user authentication, and business logic.
Live API URL: https://brew-connect-backend.onrender.com
- RESTful API: A complete set of endpoints to manage products, users, carts, and orders.
- User Authentication & Authorization: Secure user registration and login using JSON Web Tokens (JWT). Passwords are encrypted using
bcryptjs. - Middleware Protection: Custom middleware ensures that sensitive routes are only accessible to authenticated users.
- Data Modeling: Mongoose schemas define the structure for products, users, and orders.
- Custom Business Logic: Includes a unique endpoint for filtering products based on "mood" tags.
- Simulated Order Processing: Backend logic to create an order and mark it as paid, simulating a successful transaction.
- Backend: Node.js, Express.js
- Database: MongoDB (with Mongoose)
- Authentication: JSON Web Tokens (JWT), bcrypt.js
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/products |
Get all products | Public |
GET |
/api/products/mood/:mood |
Get products filtered by mood tag | Public |
POST |
/api/users/register |
Register a new user | Public |
POST |
/api/users/login |
Authenticate a user and get a token | Public |
GET |
/api/cart |
Get the logged-in user's cart | Private |
POST |
/api/cart |
Add an item to the user's cart | Private |
DELETE |
/api/cart/:productId |
Remove an item from the user's cart | Private |
DELETE |
/api/cart |
Clear all items from the user's cart | Private |
POST |
/api/orders |
Create a new order | Private |
GET |
/api/orders/myorders |
Get all orders for the logged-in user | Private |
To run this project, you will need to add a .env file in the root of the backend folder with the following variables:
MONGO_URI=
JWT_SECRET=
- Clone the repository:
git clone https://github.com/ishanijdev/Brew-connect-backend.git
- Navigate into the project directory:
cd backend - Install dependencies:
npm install
- Create a
.envfile in the root and add the required variables from the section above. - Run the server:
node server.js
This project is open-source and free to use for educational purposes.
