tomper-wear-ecommerce-backend
E-commerce web-application for selling clothing essentials
tomper-wear-server.onrender.com
This is the backend of TomperWear build with MERN stack and deployed with Render
Video demo
π₯ Link to πΎ 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
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
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
shippingPrice
Number
True
False
totalPrice
Number
True
False
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
- Node.js
- Express.js
- MongoDB
- JWT
- Cloudinary
- Bcrypt.js
- Stripe
π Installation and setup
- Clone the repo to your local machine.
-
Install the required dependency for server using :
npm install
-
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>
-
Start the dev server using :
npm start
π€ Test user credentials
Client
E-mail
Password
bob@tomperwear.com
bob1212
test@tomperwear.com
test1212
Admin
Username
E-mail
Password
Test Super
test.super@tomperwear.com
testsuper1212
Test Moderate
test.moderate@tomperwear.com
testmoderate1212
Test Low
test.low@tomperwear.com
testlow1212
π Team Members
- Varun Kumar Tiwar – 2020IMT-112
(If you liked the project, give it star π)