This README.md
provides documentation for the web API functions in this project.
- Vercel for frontend and Backend
- MongoDb Atlas for database
- Deployed Link : https://shopkart-project.vercel.app
- Github repo: https://github.com/jayantrohila57/shopkart
- Next.js for React, React-Router.
- Typescript, Eslint, prettier for best practices and code organization.
- TailwindCSS for CSS.
- Github for version control.
- Next.js inbuild node.js for server
- Next.js API folder for route and api
- Mongodb for database
- Typescript, Eslint, prettier for best practices and code organization.
The run the command in the integrated terminal inside the code editor.
- Install npm packages after clone first.
pnpm install
- Add
.env.local
your project using the below keys.
NEXT_PUBLIC_MONGODB_URI=mongodb+srv://jrohila55:lm1Uzv0SqxIMAuiO@shopkrtdb.6nezayt.mongodb.net/?retryWrites=true&w=majority
NEXT_PUBLIC_MONGODB_DB=shopkrtdb
NEXT_PUBLIC_URL=http://localhost:3000
- Run your project using the below command.
pnpm dev
-
Frontend will be running on http://localhost:3000
-
API can be accessed using http://localhost:3000/api
Here, we provide detailed information on the available routes, HTTP methods, and payload structures for each API function.
- Route:
/api/product
- HTTP Method:
GET
- Description: This function is used to fetch a list of products from the API.
- Route:
/api/cart
- HTTP Method:
GET
- Description: Use this function to retrieve cart data from the API.
- Route:
/api/cart
- HTTP Method:
GET
- Description: This function is equivalent to
getCartData
and can be used to refresh cart data.
- Route:
/api/product/{_id}
- HTTP Method:
GET
- Description: This function fetches product data by its ID.
- Route:
/api/cart
- HTTP Method:
DELETE
- Description: Use this function to delete a product from the cart.
- Payload:
{ _id: string, productId: string }
- Route:
/api/cart
- HTTP Method:
PUT
- Description: This function adds a product to the cart with the specified details.
- Payload:
{ _id: string, product: string, quantity: number }
- Route:
/api/cart
- HTTP Method:
PUT
- Description: This function is used to decrease the quantity of a product in the cart.
- Payload:
{ _id: string, product: string, quantity: number }
- Route:
/api/cart
- HTTP Method:
PUT
- Description: This function increases the quantity of a product in the cart.
- Payload:
{ _id: string, product: string, quantity: number }
Thses are ome configuration used in this project.
- .prettierignore
- .prettierrc.js
- .npmrc
- .editorconfig
- .eslintrc.js
- lint-staged.config.ts
- next.config.js
- tailwind.config.ts