The E-Commerce Website Backend is the server-side component of an e-commerce platform. It provides the functionality for both sellers and buyers, allowing sellers to manage their products and orders and buyers to browse products and place orders.
-
Authentication: Register and log in users. Generate authentication tokens for secure access to the system.
-
Buyer Features:
- View a list of all sellers.
- Access a seller's catalog of products.
- Place orders for products from a selected seller.
-
Seller Features:
- Register products for sale.
- View and manage orders received from buyers.
Before you begin, ensure you have met the following requirements:
- Node.js
- MongoDB
- Git (for cloning the repository)
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo npm install
2.Create a .env file :
MONGODB_URI=mongodb://localhost:27017/your-database-name
JWT_SECRET=your-secret-key
3.Run the backend:
npm run server
-
POST /api/auth/register
-
Register a user. Provide username, password, and type (buyer/seller) in the request body.
-
POST /api/auth/login
-
Log in with a registered user and receive an authentication token.
-
GET /api/buyer/list-of-sellers
-
Get a list of all sellers.
-
GET /api/buyer/seller-catalog/:seller_id
-
Get the catalog of a seller by seller_id.
-
POST /api/buyer/create-order/:seller_id
-
Create an order for a seller with id = seller_id. Send a list of items in the request body.
-
POST /api/seller/create-catalog
-
Create a catalog for a seller. Send a list of items in the request body.
-
GET /api/seller/orders
-
Retrieve the list of orders received by a seller.