Our E-Commerce Website Backend is the backbone of our application, handling critical operations and ensuring smooth functionality. It serves as the engine that powers product management, user authentication, order processing, and more. With its robust architecture and scalable design, our backend ensures a seamless experience for both customers and administrators. The Backend API is designed to manage the Product and User. It allows clients to read the products through HTTP requests.
The backend follows a three-tier architecture:
-
Product Management: Effortlessly add, update, and remove products from the catalog. Categorize and organize products for easy discovery.
-
User Authentication: Secure user registration and authentication to ensure a safe environment. Allow customers to manage their profiles and track their produc history.
-
Favorite and Checkout: Enable customers to add products to their favorite list, proceed to checkout, and complete their purchases securely.
-
Order Processing: Efficiently handle order fulfillment, and payment processing for a seamless customer experience.
-
Inventory Management: Track product availability, stock levels, and handle restocking processes.
-
Discounts and Promotions: Implement special offers, discounts, and promotional campaigns to attract and retain customers.
-
Reporting and Analytics: Generate valuable insights through data-driven reports, helping administrators make informed decisions and optimize business strategies.
Our backend leverages cutting-edge technologies to deliver exceptional performance and maintainability:
-
Node.js: A versatile and efficient JavaScript runtime that powers our server-side logic.
-
Express.js: A flexible and lightweight web application framework that facilitates the development of robust APIs.
-
MongoDB: A powerful NoSQL database for efficient data storage and retrieval.
-
Mongoose: An elegant MongoDB object modeling tool that simplifies data manipulation and validation.
-
JSON Web Tokens (JWT): Securely manage user authentication and authorization.
-
Bcrypt: Securely manage user-sensitive data.
-
RESTful API: We follow REST principles to build an intuitive and predictable API.
-
Custom middleware: A user authentication middleware for Node.js that ensures secure and customizable authentication.
To get started with our E-Commerce Website Backend, follow our easy installation instructions.
-
Install Node.js and npm.
-
Clone the repository from the URL.
-
Run npm install to install the required dependencies.
-
Create a PostgreSQL database named your choose.
-
Set environment variables for database connection: PORT, MONGODB_URL, SECRET_KEY.
-
Run npm start to start the backend server.
- Environment variables
For detailed information on the available endpoints, request parameters, and responses, refer to our API Documentation.
PORT: The port on which the server listens (default: 8080).
Base URL: http://localhost:8080/
- POST:- /user/register
Note:- Now while registration you have to check that password should contain all the following things, otherwise user cannot register.
-
Description: Create a new user.
-
Request Body: JSON object with properties firstname, lastname, email & password.
-
Response: JSON object with the newly registered user & success message.
-
POST:- /user/login
-
Description: Log in to the registered user.
-
Request Body: JSON object with properties email & password.
-
Response: JSON object with the username, token & success message.
-
POST:- /user/logout
-
Description: Logged out the user.
-
Request Body: Need token to be Logged.
-
Response: Success message.
- GET:- /product/getproducts
Note:- You can use this route also for search based on title, sort based on price, and pagination. Please use these keys to access these functionality title, sortbyprice, pageno, pagelimit.
- category: gardening_inputs, type: fertilizers
- category: gardening_inputs, type: grow_bags
- category: gardening_inputs, type: grow_beds
- category: gardening_inputs, type: pots
- category: gardening_inputs, type: potting_medium
- category: hydroponics, type: accessorie_hydroponics
- category: hydroponics, type: diy_kits_hydroponics
- category: hydroponics, type: growing_media_hydroponics
- category: hydroponics, type: instrument_hydroponics
- category: hydroponics, type: nutrient_hydroponics
- category: organic_farming,type: bio_fertilizers
- category: organic_farming,type: bio_pesticides
- category: organic_farming,type: organic_fertilizers
- category: seeds, type: flower_seeds
- category: seeds, type: fruit_seeds
- category: seeds, type: herb_seeds
- category: seeds, type: microgreens_seeds
- category: seeds, type: vegetable_seeds
-
Description: Get a list of all products or according to params.
-
Response: Array of task objects with properties _id, primary_image, alternative_image, title, price, description, old_price, category & type.
-
GET:- /product/getproduct/:productID
-
Description: Get details of a specific product by its _id.
-
Request Body: Product _id as a string.
-
Response: JSON object with the specific product.
-
POST:- /product/addproduct
-
Description: Create a new product.
-
Request Body: JSON object with properties _id, primary_image, alternative_image, title, price, description, old_price, category & type.
-
Response: JSON object with the newly created product & success message.
-
PATCH:- /product/update/:productID
-
Description: Update the propertie of a product by its _id.
-
Request Body: JSON object with properties _id, primary_image, alternative_image, title, price, description, old_price, category & type.
-
Response: JSON object with the updated product & success message.
-
DELETE:- /product/delete/:productID
-
Description: Delete a product by its _id.
-
Response: Success message.
-
GET:- /cart/cartproducts
-
Description: Get a list of logging user cart products.
-
Response: Array of task objects with properties _id, primary_image, alternative_image, title, price, description, old_price, category & type.
-
POST:- /cart/addtocart/:_id
-
Description: Add a new cart product in the logging user cart lists.
-
Request Body: JSON object with properties _id, primary_image, alternative_image, title, price, description, old_price, category & type.
-
Response: JSON object with the newly created cart product in the logging user cart lists & success message.
-
DELETE:- /cart/delete/:_id
-
Description: Delete a cart product in the logging user cart lists by its _id.
-
Response: Success message.
- User example:- { firstname: { type: String, required: true }, lastname: { type: String, required: true }, email: { type: String, required: true }, password: { type: String, required: true }, },
- Product & cart example:- { primary_image: { type: String, required: true }, alternative_image: { type: String, required: true }, title: { type: String, required: true }, price: { type: Number, required: true }, description: { type: String, required: true }, old_price: { type: String, required: false }, category: { type: String, required: true }, type: { type: String, required: true }, },
- HTTP status codes 400, 404, and 500 are used for error responses.
- Error responses include a message field with a description of the error.
- Authentication is implemented in this backend.
- Do not use this backend in a production environment without proper security measures.