Tech Vault (E-Commerce App)

#Description
Tech Vault is a backend API for an ecommerce platform selling tech products like PC hardware, software, games, storage devices, office equipment, and more. Built with NestJS, Node.js, and TypeScript, it uses TypeORM with Postgres for persistent storage and Redis for caching, ensuring performance and reliability..
#Technology Stack
- TypeScript
- Nest.js
- Postgres SQL
- TypeORM
- Nodemailer
- Cloudinary
- Multer
- Winston
- Docker
- Stripe
- Passport
- …etc
#Database Design
#code with dbml language
// Users TableTable users { id serial [primary key] first_name varchar(50) [not null] last_name varchar(50) [not null] password varchar(50) [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}
// Phone NumbersTable phones_numbers { id serial [primary key] phoneNumber varchar(25) isPrimary boolean [not null, default: false] user_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: phones_numbers.user_id > users.id [delete: cascade,update no action]
// Emails TableTable emails { id int [pk, increment] user_id int [not null] email varchar(25) [not null, unique] isPrimary boolean [not null, default: false] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: emails.user_id > users.id [delete: cascade, update: no action]
// User ImageTable user_image { id serial [primary key] url varchar(255) image_id varchar(255) user_id int [not null, unique] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: user_image.user_id > users.id [delete: cascade, update: no action]
// Addresses TableTable addresses { id serial [primary key] city varchar(100) [not null] postCode varchar(20) [not null] country varchar(20) [not null] isPrimary boolean [not null, default: false] user_id int [not null] order_id int created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: addresses.user_id > users.id [delete: cascade, update: no action]Ref: addresses.order_id - orders.address_id [delete: cascade, update: no action]
// Notifications TableTable notifications { id serial [primary key] user_id int [not null] read boolean [not null, default: false] message text [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: notifications.user_id > users.id
// Products TableTable products { id serial [primary key] name varchar(255) [not null] price decimal [not null, default: 0] category_id int created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: products.category_id > categories.id [delete: set null, update: no action]
// Category TableTable categories { id serial [primary key] name varchar(50) [not null] description varchar(500) created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}
// Images TableTable product_image { id serial [primary key] url varchar(255) image_id varchar(255) product_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: product_image.product_id > products.id [delete: cascade, update: no action]
// Reviews TableTable reviews { id serial [primary key] user_id int [not null] product_id int [not null] rating int created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: reviews.user_id > users.idRef: reviews.product_id > products.id
// WishListTable wishlist { id serial [primary key] user_id int [not null] product_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: wishlist.user_id - users.id [delete: cascade, update: no action]Ref: wishlist.product_id > products.id [delete: set null, update: no action]
// Cart TableTable carts { id serial [primary key] user_id int [not null, unique] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: carts.user_id > users.id
// Cart Items TableTable cart_items { id serial [primary key] quantity int [not null] cart_id int [not null] product_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: cart_items.cart_id > carts.id [delete: cascade, update: no actions]Ref: cart_items.product_id > products.id [delete: cascade, update: no actions]
// Order TableTable orders { id serial [primary key] user_id int [not null] total_amount decimal [not null] order_date timestamp address_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: orders.user_id > users.id [delete: cascade, update: no actions]
// Order Items TableTable order_items { id serial [primary key] quantity int [not null] price decimal [not null] order_id int [not null] product_id int [not null] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}Ref: order_items.order_id > orders.id [delete: cascade, update: no actions]Ref: order_items.product_id > products.id [delete: cascade, update: no actions]
// Promo Codes TableTable promo_codes { id serial [primary key] code varchar(50) [not null] discount int [not null, default: 0] expiration_date timestamp [not null, default: `now()`] usage_limit int [not null, default: 0] usage_count int [not null, default: 0] is_active boolean [not null, default: true] created_at timestamp [not null, default: `now()`] updated_at timestamp [not null, default: `now()`]}