Skip to content

varunKT001/tomper-wear-ecommerce-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-commerce web-application for selling clothing essentials

tomper-wear-server.onrender.com (cloud-based)
tw-backend.varuntiwari.com (self-hosted)


This is the backend of TomperWear build with MERN stack and deployed with Render

πŸš€ Link to Client, Admin panel

πŸŽ₯ Link to Video demo

πŸ’Ύ Database schemas

Admin schema

Field Type Required Unique Default
name String True False -
email String True True -
password String True False -
privilege String False False low

Product schema

Field Type Required Unique Default
name String True False -
description String True False -
price Number True False -
rating Number False False 0
images Object.<{
public_id: String,
url: String,
}>
True False -
colors Array.<{String}> True False -
sizes Array.<{String}> True False -
company String True False -
stock Number True False -
numberOfReviews Number False False 0
reviews Object.<{
name: String,
email: String,
rating: Number,
comment: String
}>
False False -
shipping Boolean False False True
featured Boolean False False False
admin Schema.Admin True False -
createdAt Date False False Date.now()

Order schema

Field Type Required Unique Default
shippingInfo Object.<{
address: String,
city: String,
state: String,
country: String,
pinCode: Number,
phoneNumber: Number
}>
True False -
orderItems Object.<{
name: String,
price: String,
quantity: Number,
image: String,
color: String,
size: String,
product: Schema.Product
}>
True False -
user Object.<{
name: String,
email: String
}>
True False -
paymentInfo Object.<{
id: String,
status: String
}>
True False -
paidAt Date True False -
itemsPrice Number True False 0
shippingPrice Number True False 0
totalPrice Number True False 0
orderStatus String True False processing
createdAt Date False False Date.now()
deliveredAt Date False False -

🌍 APIs

Products

Method Route Parameters Body Description
GET /api/products/ - - Get list of all available products
POST /api/products/ id - Get details of a single product
POST /api/admin/product/new - {
name: String,
price: Number,
description: String,
category: String,
images: Array,
colors: Array,
sizes: Array,
company: String,
shipping: Boolean,
featured: Boolean
}
Creates a new product
PUT /api/admin/product/ id {
name: String,
price: Number,
description: String,
category: String,
images: Array,
colors: Array,
sizes: Array,
company: String,
shipping: Boolean,
featured: Boolean
}
Update existing products detail
DELETE /api/admin/product/ id - Deletes an existing product
GET /api/products/reviews/ id - Get list of reviews of an existing product.
POST /api/products/reviews/ - {
name: String,
email: String,
rating: Number,
comment: String,
productId: String,
}
- Creates a product review.
- Updates and already existing review.
DELETE /api/admin/product/review/ id {
reviewId: String
}
Delete a review for an existing product.

Orders

Method Route Parameters Body Description
GET /api/admin/order/ - - Get all orders
POST /api/orders/ - {
email: String
}
Get orders of a single user
GET /api/orders/ id - Get a single order
POST /api/orders/new/ - {
name: String,
email: String,
shippingInfo: Object,
orderItems: Array.,
paymentInfo: Object,
itemsPrice: Number,
shippingPrice: Number,
totalPrice: Number
}
Creates a new order
PUT /api/admin/order/ id {
status: String
}
Update existing order's status
DELETE /api/admin/order/ id - Delete an existing order

Admin

Method Route Parameters Body Description
POST /api/admin/register/ - {
name: String,
email: String,
password: String,
privilege: String
}
Creates a new admin user
POST /api/admin/login/ - {
email: String,
password: String
}
Login to admin dashboard
GET /api/admin/users/ - - Get list of all admin users
GET /api/admin/users/ id - Get single admin details
PUT /api/admin/users/ id {
privilege: String
}
Update an admin user's privilege
DELETE /api/admin/users/ id - Delete an existing admin user

🧾 Description

TomperWear is an E-commerce platform for small bussiness owners who want to expand their bussiness by providing an online purchase solution to their customers.

✨ Features

Client

Users shopping through this platform enjoys following features:

  • User authentication using google firebase.
  • Secure payments via stripe.
  • Users can change their username and display image.
  • Users can filter products on various parameters.
  • Users can sort products according to price and name.
  • Users can add products to cart.
  • Users can order products by providing their shipping information and card details for payments.
  • Users can view their order's status and their previous orders.
  • Users can review the products (or update their previous reviews) and benefit other customers.
  • Users can send feedbacks to the owner.
  • Responsive for all screen sizes.

Admin

The admin panel of TomperWear contains three classes of admins:

1. Super privileged admin Super privileged admins are the topmost in the hierarchy. They have the following permissions:

  • Can view, create, update, and delete admin users.
  • Can view, create, update, and delete products.
  • Can view orders and update their status.
  • Can delete orders.

This is privilege is ideal for the owner(s) of the bussiness.

2. Moderate privileged admin Moderate privileged admins comes below Super privileged admins. They have the following permissions:

  • Can view, create, update, and delete admin users.
  • Can view, create, update, and delete products.
  • Can view orders and update their status.
  • Can delete orders.

This is privilege is ideal for the manager(s).

3. Low privileged admin Low privileged admins are the lowermost in the hierarchy and have the least amount of privileges. The have the following permission:

  • Can view, create, update, and delete admin users.
  • Can view, create, update, and delete products.
  • Can view orders and update their status.
  • Can delete orders.

This is privilege is ideal for the delivery-agent(s).

Here is a table dipicting the admin privileges for better clarity

Admins Product Orders
view create update delete view create update delete view update delete
Super βœ” βœ” βœ” βœ” βœ” βœ” βœ” βœ” βœ” βœ” βœ”
Moderate - - - - βœ” βœ” βœ” βœ” βœ” βœ” βœ”
Low - - - - - - - - βœ” βœ” -

βš™ Tools and Technologies used

  1. React.js
  2. React-icons
  3. Styled-Components
  4. Firebase
  5. Stripe
  6. Formspree
  1. React.js
  2. Chakra-ui
  3. React-icons
  1. Node.js
  2. Express.js
  3. MongoDB
  4. JWT
  5. Cloudinary
  6. Bcrypt.js
  7. Stripe

πŸ›  Installation and setup

  1. Clone the repo to your local machine.

  2. Install the required dependency for server using :

    npm install
  3. Create a .env file inside the root folder and provide the following environment variables:

    STRIPE_SECRET_KEY=<stripe_secret_key>
    DB_URI=<mongo_uri>
    JWT_SECRET=<your_jwt_secret>
    JWT_EXPIRE=5d
    COOKIE_EXPIRE=5
    CLOUDINARY_CLOUD_NAME=<cloudinary_cloud_name>
    CLOUDINARY_API_KEY=<cloudinary_api_key>
    CLOUDINARY_API_SECRET=<cloudinary_api_secret>
  4. Start the dev server using :

    npm start

🀝 Test user credentials

Client

E-mail Password
[email protected] bob1212
[email protected] test1212

Admin

I'm disabling test admin credentials due to malicious activities.

😎 Team Members

  1. Varun Kumar Tiwar - 2020IMT-112



(If you liked the project, give it star πŸ˜ƒ)