This project is an E-commerce API built using Node.js, Express.js, and MongoDB. It provides endpoints for buyers and sellers to register, login, manage their profiles, and interact with products.
- Registration, login, and logout.
- Update buyer profile information.
- Purchase products from sellers.
- Registration, login, and logout.
- Update seller profile information.
- Add, update, and delete products.
- View products listed by the seller.
- Uses JSON Web Tokens (JWT) for buyer and seller authentication.
- Middleware for authenticating buyers and sellers.
- Node.js: JavaScript runtime environment.
- Express.js: Web application framework for Node.js.
- MongoDB: NoSQL database for storing user and product data.
- Mongoose: MongoDB object modeling for Node.js.
- JSON Web Tokens (JWT): Token-based authentication mechanism.
- dotenv: Environment variable management.
- Clone the repository:
git clone https://github.com/TusharPachouri/E-commerce-API.git
- Install dependencies:
npm install
- Set up environment variables:
- Create a
.env
file based on the provided.env.example
template - Update the variables with your MongoDB connection string, Cloudinary credentials, and other necessary configurations
- Create a
- Start the application:
npm start
POST /buyer/register
: Register a new buyer.POST /buyer/login
: Login as a buyer.GET /buyer/me
: Get buyer profile.PATCH /buyer/me
: Update buyer profile.DELETE /buyer/me
: Delete buyer account.POST /buyer/logout
: Logout buyer.POST /buyer/buy/:id
: Purchase a product by ID.
POST /seller/register
: Register a new seller.POST /seller/login
: Login as a seller.GET /seller/me
: Get seller profile.PATCH /seller/me
: Update seller profile.DELETE /seller/me
: Delete seller account.POST /seller/logout
: Logout seller.POST /seller/product/add
: Add a new product.PATCH /seller/product/:id
: Update product by ID.DELETE /seller/product/:id
: Delete product by ID.GET /seller/products
: Get all products listed by the seller.GET /seller/product/:id
: Get details of a specific product.
A transaction model is implemented to manage transactions between buyers and sellers. Below is the schema definition: