Giter Site home page Giter Site logo

product-management's Introduction

E-commerce Product Management Backend

E-Commerce Express Application with TypeScript and MongoDB

Project Overview

This is a backend server for an e-commerce product management system. It is built using TypeScript, Node.js, Express, Mongoose, and MongoDB. Validation is performed with Zod.

Features:

  • Create Product: Use the api/products endpoint to create a new product.
  • Get Product by ID: Use the api/products/:id endpoint to retrieve a product by its ID.
  • Fetch all Products: Use the api/products endpoint to retrieve all products available.
  • Delete Product by ID: Use the api/products/:id endpoint to delete a product by its ID.
  • Search Products: Use the api/products?searchTerm=searchKeyword endpoint to search for products using a search term.
  • Create Order: Use the api/orders endpoint to create a new product.
  • Fetch all orders: Use the api/orders endpoint to retrieve all orders.
  • Search order for a user: Use the api/orders?email=userEmail endpoint to search for products using a search term.

How to run this project?

Installation

  1. ** Clone the repository:
git clone https://github.com/KaziMdMehediHasan/product-management
cd ecommerce-product-management
  1. ** Install dependencies:
npm install
  1. ** Environment Variables:

Create a .env file in the root directory of the project and add the following environment variables:

PORT=3000
MONGODB_URI=your_mongodb_connection_string
  1. ** Start the server:
npm run start:dev

The server will start on http://localhost:5000.

API Endpoints

Create a new product

  • Endpoint: /api/products
  • Method: POST

  • Sample Request Body:

{
  "name": "Samsung Galaxy S21",
  "description": "High-performance Android smartphone with advanced camera capabilities.",
  "price": 799,
  "category": "Electronics",
  "tags": ["smartphone", "Samsung", "Android"],
  "variants": [
    {
      "type": "Color",
      "value": "Phantom Black"
    },
    {
      "type": "Storage Capacity",
      "value": "128GB"
    }
  ],
  "inventory": {
    "quantity": 29,
    "inStock": true
  }
}

Get a Product by ID

  • Endpoint: /api/products/:id
  • Method: GET

Delete a Product by ID

  • Endpoint: /api/products/:id
  • Method: DELETE

Search Products

  • Endpoint: /api/products?searchTerm=searchKeyword
  • Method: GET

Create a new order

  • Endpoint: /api/orders
  • Method: POST
  • Sample Request Body:
{
  "email": "[email protected]",
  "productId": "664e1210c34873fba7ec0804",
  "price": 299,
  "quantity": 4
}

Find an order using user email

  • Endpoint: /api/orders?email=userEmail
  • Method: GET

product-management's People

Contributors

kazimdmehedihasan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.