This repository hosts the source code for a feature-rich eCommerce application built with NestJS. It includes user authentication, product management, order processing, and role-based access control. The application uses JWT for authentication, Bcrypt for password hashing, Mysql for database, TypeORM, Nest Access Control, and Swagger for API documentation.
- Live Preview: https://ecommerce-apis-nestjs.onrender.com
- User and Admin roles
- JWT Authentication
- Password Hashing with Bcrypt
- CRUD Operations for Products, Categories, and Orders
- Login/Signup/Logout/Status
- Swagger API Documentation
- Role-Based Access Control
- Admin: Can create, edit, delete products and categories, and manage orders.
- User: Can browse products, add to cart, and place orders.
- Authenticated APIs for secured access
- REST APIs for interaction with the application
- Database: MySQL with TypeORM
You can access the full API documentation via Swagger at the root URL of the deployed application:
- User to Cart: One-to-One relationship (A user can have one cart).
- User to Order: One-to-Many relationship (One user can place multiple orders).
- User to Review: One-to-Many relationship (One user can write multiple reviews).
- Cart to CartItem: One-to-Many relationship (One cart can contain multiple cart items).
- Category to Product: One-to-Many relationship (One category can contain multiple products).
- Product to CartItem: One-to-Many relationship (One product can be added to multiple cart items).
- Product to OrderItem: One-to-Many relationship (One product can be included in multiple order items).
- Product to Review: One-to-Many relationship (One product can have multiple reviews).
- Order to OrderItem: One-to-Many relationship (One order can include multiple order items).
-
User
- One cart
- Many orders
- Many reviews
-
Cart
- One user
- Many cart items
-
Category
- Many products
-
Product
- Many cart items
- Many order items
- Many reviews
- One category
-
CartItem
- One cart
- One product
-
Order
- One user
- Many order items
-
OrderItem
- One order
- One product
-
Review
- One user
- One product
- User Apis
- Categories, Product And Cart Apis
- Orders, Reviews And Auth Apis
Clone the project
git clone https://github.com/Mshandev/Ecommerce-Apis-Nestjs.git
Go to the project directory
cd Ecommerce-Apis-Nestjs
Install dependencies
npm install
Setup Environment Vaiables
DB_TYPE=mysql
DB_HOST=YOUR_DB_HOST
DB_PORT=YOUR_DB_PORT
DB_USERNAME=YOUR_DB_USER
DB_PASSWORD=YOUR_DB_PASSWORD
DB_DATABASE=DB_NAME
JWT_SECRET=secretkey
Start the server
npm run start:dev
The application is deployed on Render.
Contributions are always welcome! Just raise an issue, and we will discuss it.
If you have any feedback, please reach out to me here