{"id":29913641,"url":"https://github.com/akkaraponph/go-fiber-e-commerce","last_synced_at":"2026-04-11T08:02:53.291Z","repository":{"id":298310129,"uuid":"853977663","full_name":"akkaraponph/go-fiber-e-commerce","owner":"akkaraponph","description":"[Hobby Project] Simulate Development Process an APIs for e commerce platform","archived":false,"fork":false,"pushed_at":"2024-09-28T14:55:14.000Z","size":595,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T23:26:31.981Z","etag":null,"topics":["docker","e-commerce-api","e-commerce-example","fiber-framework","golang","gorm","hexagonal-architecture","postgresql","temporalio"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akkaraponph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-08T04:07:14.000Z","updated_at":"2025-05-23T05:07:28.000Z","dependencies_parsed_at":"2025-06-10T13:32:21.828Z","dependency_job_id":null,"html_url":"https://github.com/akkaraponph/go-fiber-e-commerce","commit_stats":null,"previous_names":["akkaraponph/go-fiber-e-commerce"],"tags_count":0,"template":false,"template_full_name":"akkaraponph/exclusive-go-hexa","purl":"pkg:github/akkaraponph/go-fiber-e-commerce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkaraponph%2Fgo-fiber-e-commerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkaraponph%2Fgo-fiber-e-commerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkaraponph%2Fgo-fiber-e-commerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkaraponph%2Fgo-fiber-e-commerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akkaraponph","download_url":"https://codeload.github.com/akkaraponph/go-fiber-e-commerce/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkaraponph%2Fgo-fiber-e-commerce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31673068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","e-commerce-api","e-commerce-example","fiber-framework","golang","gorm","hexagonal-architecture","postgresql","temporalio"],"created_at":"2025-08-02T02:13:10.365Z","updated_at":"2026-04-11T08:02:53.258Z","avatar_url":"https://github.com/akkaraponph.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-fiber-e-commerse \n\nThis project follows the Hexagonal Architecture (also known as Ports and Adapters Architecture), which aims to create a clear separation between the core business logic and external systems. The structure of the project is designed to ensure maintainability, testability, and scalability by decoupling various components.\n\n## Project Structure\n\n`cmd`\nContains the main application entry points. This is where the application starts and is responsible for setting up the application context, configuration, and running the server.\n\n`internal`\nThe core of the application is divided into several packages:\n- `adapters`: Contains the implementations for interacting with external systems.\n  -  `app`: Application-level adapters.\n  -  `database`: Database-related adapters, including models and seeders.\n     - `models`: Database models used for ORM.\n     - `seeders`: Scripts for populating the database with initial data.\n   - `http`: HTTP-related adapters, including handlers and routers.\n     - `handlers`: HTTP request handlers, organized by domain (e.g., documents, orders, system_fields).\n     - `routers`: Routing configurations for handling HTTP requests and responses.\n   - `repositories`: Data access repositories, organized by domain (e.g., documents, orders, system_fields).\n - `core`: Contains the business logic and domain-specific code.\n\t- `domain`: Domain models and business entities, organized by domain (e.g., documents, orders, system_fields).\n\t- `ports`: Interfaces that define the interactions between the core domain and the external systems.\n    \t- documents, master_files, orders, system_fields: Ports for different domains.\n\n  - `services`: Business logic and use cases, organized by domain (e.g., documents, orders, system_fields).\n\n\n`pkg`\nContains shared utilities and helpers that can be used across the application.\n\n- `configs`: Configuration management.\n- `helpers`: Utility functions for various tasks.\n- `filters`: Helpers for filtering data.\n- `pagination`: Helpers for pagination.\n- `utils`: Additional utility functions, such as Argon2ID for password hashing\n\n\n# Business Context\n\nAn e-commerce system is a digital platform designed to facilitate the buying and selling of goods and services over the internet. It provides a comprehensive online shopping experience for users, encompassing various functionalities to handle different aspects of the shopping lifecycle, from product discovery to purchase and delivery.\n\n## Brief Entities\n\n- [dbdocs: exclusive-e-comerse-example](https://dbdocs.io/lacakira/exclusive-e-comerse-example?view=table_structure)\n\n![dbdiagram](docs/exclusive-e-comerse-example.svg)\n\n\n### Core Entities\n  - User: Manages user data and roles.\n  - UserProfile: Contains additional profile information for users.\n  - UserRole: Defines user roles and associated permissions.\n  - UserPermission: Manages permissions linked to each role.\n  - RefreshToken: Stores JWT refresh tokens for user sessions, including their expiration and usage status.\n  - OAuthProvider: Manages OAuth providers used for external authentication.\n  - OAuthAccessToken: Represents access tokens issued by OAuth providers for authentication and authorization.\n  - OAuthRefreshToken: Represents refresh tokens used to obtain new access tokens after expiration.\n  - Email: Stores information about emails sent to users, including recipient details, content, and status.\n  - OTP: Stores one-time passwords (OTPs) used for user verification and authentication processes.\n\n### Product Management\n  - Category: Categorizes products.\n  - Product: Stores product details.\n  - ProductImage: Manages product images.\n  - ProductVariant: Handles different product variants (e.g., size, color).\n\n### Order Management\n  - Order: Represents a customer's order.\n  - OrderItem: Details of items within an order.\n  - Inventory: Tracks product stock levels.\n  - Payment: Handles payment information for orders.\n  - BillingInfo: Stores billing details for orders.\n  - ShippingInfo: Manages shipping details and status for orders.\n\n### Shopping Cart\n  - Cart: Represents a user's shopping cart.\n  - CartItem: Stores items added to the cart.\n\n### Marketing and Discounts\n  - Coupon: Manages discount codes.\n  - AppliedCoupon: Tracks coupons applied to orders.\n\n### Reviews and Ratings\n  - Review: Captures product reviews and ratings.\n  - ShippingReview: Stores user reviews specifically for shipping experiences.\n\n### Change Tracking\n  - ChangeLogs: Records changes made to entities for auditing purposes.\n\n\n## ER Diagram\n\n### Core Entities\n  \n#### User: Manages user data and roles.\n\n**Description**: Represents users of the system with various roles (ADMIN, SELLER, CUSTOMER). This table manages user details and tracks who created each record.\n\n| Column Name         | Data Type  | Constraints                                | Description                                                |\n|---------------------|------------|--------------------------------------------|------------------------------------------------------------|\n| `id`                | `SERIAL`   | `PRIMARY KEY`                              | Unique identifier for each user.                          |\n| `first_name`        | `VARCHAR(50)`|                                            | User's first name.                                        |\n| `last_name`         | `VARCHAR(50)`|                                            | User's last name.                                         |\n| `role_id`           | `INTEGER`  | `REFERENCES UserRole(id)`                  | References the UserRole table to assign a role to the user.|\n| `address`           | `VARCHAR(255)`|                                            | User's address for contact and authentication purposes.    |\n| `phone_number`      | `VARCHAR(20)`|                                            | User's phone number.                                      |\n| `email`             | `VARCHAR(100)`|                                            | User's email address.                                    |\n| `username`          | `VARCHAR(50)`|                                            | User's chosen username.                                  |\n| `password`          | `VARCHAR(255)`|                                            | User's hashed password.                                  |\n| `status`            | `VARCHAR(20)`|                                            | Status of the user account (e.g., 'Active', 'Inactive').  |\n| `last_login`        | `TIMESTAMP`|                                            | Timestamp of the last time the user logged in.            |\n| `two_factor_enabled`| `BOOLEAN`  |                                            | Indicates if two-factor authentication is enabled for the user. |\n| `two_factor_secret` | `VARCHAR(255)`|                                            | Secret used for generating 2FA codes. (Only if 2FA is enabled) |\n| `created_by`        | `INTEGER`  | `REFERENCES User(id)`                      | References the user who created this record, enabling tracking of record creation. |\n| `created_at`        | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`                | Timestamp when the record was created.                    |\n| `updated_at`        | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`                | Timestamp when the record was last updated.               |\n| `deleted_at`        | `TIMESTAMP`| `DEFAULT NULL`                             | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `role_id` references the `UserRole` table to assign roles.\n- `created_by` references the `User` table for tracking record creation.\n- `deleted_at` allows for soft deletes.\n\n```sql\nTable User [NOTE: \"Represents users of the system with various roles (ADMIN, SELLER, CUSTOMER). This table manages user details and tracks who created each record.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each user.\"]\n  first_name VARCHAR(50) [NOTE: \"User's first name.\"]\n  last_name VARCHAR(50) [NOTE: \"User's last name.\"]\n  role_id INTEGER [ref: \u003e UserRole.id, NOTE: \"References the UserRole table to assign a role to the user.\"]\n  address VARCHAR(255) [NOTE: \"User's address for contact and authentication purposes.\"]\n  phone_number VARCHAR(20) [NOTE: \"User's phone number.\"]\n  email VARCHAR(100) [NOTE: \"User's email address.\"]\n  username VARCHAR(50) [NOTE: \"User's chosen username.\"]\n  password VARCHAR(255) [NOTE: \"User's hashed password.\"]\n  status VARCHAR(20) [NOTE: \"Status of the user account (e.g., 'Active', 'Inactive').\"]\n  last_login TIMESTAMP [NOTE: \"Timestamp of the last time the user logged in.\"]\n  two_factor_enabled BOOLEAN [NOTE: \"Indicates if two-factor authentication is enabled for the user.\"]\n  two_factor_secret VARCHAR(255) [NOTE: \"Secret used for generating 2FA codes. (Only if 2FA is enabled)\"]\n  created_by INTEGER [ref: \u003e User.id, NOTE: \"References the user who created this record, enabling tracking of record creation.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the record as deleted without actual removal.\"]\n}\n```\n\n\n#### UserProfile Table\n\n**Description**: Stores additional profile information for users, including profile pictures and user preferences.\n\n| Column Name          | Data Type | Constraints                              | Description                                                |\n|----------------------|-----------|------------------------------------------|------------------------------------------------------------|\n| `id`                 | `SERIAL`  | `PRIMARY KEY`                            | Unique identifier for each user profile.                  |\n| `user_id`            | `INTEGER` | `REFERENCES User(id)`                    | References the `User` table, linking the profile to a specific user. |\n| `profile_picture`    | `VARCHAR(255)`  |                                          | URL or path to the user's profile picture.                |\n| `preferences`        | `JSONB`   |                                          | JSON object storing user-specific preferences and settings.|\n| `date_of_birth`      | `DATE`    |                                          | User's date of birth.                                    |\n| `social_media_links` | `JSONB`   |                                          | JSON object storing links to user's social media profiles.|\n| `created_at`         | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the profile was created.                   |\n| `updated_at`         | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the profile was last updated.              |\n| `deleted_at`         | `TIMESTAMP`| `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` references the `User` table to link the profile with the corresponding user.\n- `preferences` and `social_media_links` are stored as JSONB for flexibility.\n- `created_at` and `updated_at` track record creation and modification times.\n- `deleted_at` allows for soft deletes.\n\n\n```sql\nTable UserProfile [NOTE: \"Stores additional profile information for users, including profile pictures and user preferences.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each user profile.\"]\n  user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table, linking the profile to a specific user.\"]\n  profile_picture VARCHAR(255) [NOTE: \"URL or path to the user's profile picture.\"]\n  preferences JSONB [NOTE: \"JSON object storing user-specific preferences and settings.\"]\n  date_of_birth DATE [NOTE: \"User's date of birth.\"]\n  social_media_links JSONB [NOTE: \"JSON object storing links to user's social media profiles.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the profile was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the profile was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the record as deleted without actual removal.\"]\n}\n```\n\n#### UserRole Table\n\n**Description**: Defines user roles and associated permissions. Roles may include ADMIN, SELLER, and CUSTOMER, with descriptions for each role's purpose within the system.\n\n| Column Name     | Data Type  | Constraints                              | Description                                               |\n|-----------------|------------|------------------------------------------|-----------------------------------------------------------|\n| `id`            | `SERIAL`   | `PRIMARY KEY`                            | Unique identifier for each user role.                    |\n| `role_name`     | `VARCHAR(50)`   |                                          | Name of the role (e.g., 'ADMIN', 'SELLER', 'CUSTOMER').  |\n| `description`   | `VARCHAR(255)`   |                                          | Description of the role and its purpose within the system.|\n| `created_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the role was created.                     |\n| `updated_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the role was last updated.                |\n| `deleted_at`    | `TIMESTAMP`| `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `role_name` provides the name for the role.\n- `description` gives context about the role's function within the system.\n- `created_at` and `updated_at` track record creation and updates.\n- `deleted_at` allows for soft deletes.\n\n```sql\nTable UserRole [NOTE: \"Defines the roles available in the system, such as ADMIN, SELLER, and CUSTOMER, and provides descriptions for each role.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each user role.\"]\n  role_name VARCHAR(50) [NOTE: \"Name of the role (e.g., 'ADMIN', 'SELLER', 'CUSTOMER').\"]\n  description VARCHAR(255) [NOTE: \"Description of the role and its purpose within the system.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the profile was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the profile was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the record as deleted without actual removal.\"]\n}\n```\n\n\n#### UserPermission Table\n\n**Description**: Manages permissions linked to each role, specifying what actions each role can perform.\n\n| Column Name        | Data Type      | Constraints                              | Description                                               |\n|--------------------|----------------|------------------------------------------|-----------------------------------------------------------|\n| `id`               | `SERIAL`       | `PRIMARY KEY`                            | Unique identifier for each permission record.            |\n| `role_id`          | `INTEGER`      | `REFERENCES UserRole(id)`                | References the `UserRole` table, linking permissions to specific roles. |\n| `permission`       | `VARCHAR(100)` |                                          | Description of the permission (e.g., 'CREATE_PRODUCT', 'VIEW_ORDERS'). |\n| `permission_type`  | `VARCHAR(50)`  |                                          | Type of permission (e.g., 'Read', 'Write', 'Admin').     |\n| `effective_date`   | `TIMESTAMP`    |                                          | Timestamp when the permission became effective.          |\n| `description`      | `TEXT`         |                                          | Brief description of the permissions associated with this role. |\n| `created_at`       | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the record was created.                   |\n| `updated_at`       | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the record was last updated.              |\n| `deleted_at`       | `TIMESTAMP`    | `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `role_id` links the permission to a specific role defined in the `UserRole` table.\n- `permission` and `permission_type` specify the actions that the role can perform.\n- `effective_date` tracks when the permission was applied.\n- `description` provides additional context about the permission.\n- `created_at` and `updated_at` track when the record was created and modified.\n- `deleted_at` allows for soft deletes.\n\n```sql\nTable UserPermission [NOTE: \"Manages permissions associated with user roles, specifying what actions each role can perform.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each permission record.\"]\n  role_id INTEGER [ref: \u003e UserRole.id, NOTE: \"References the UserRole table to link permissions to specific roles.\"]\n  permission VARCHAR(100) [NOTE: \"Description of the permission (e.g., 'CREATE_PRODUCT', 'VIEW_ORDERS').\"]\n  permission_type VARCHAR(50) [NOTE: \"Type of permission (e.g., 'Read', 'Write', 'Admin').\"]\n  effective_date TIMESTAMP [NOTE: \"Timestamp when the permission became effective.\"]\n  description TEXT [NOTE: \"Brief description of the permissions associated with this role.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the permission record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the permission record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the record as deleted without actual removal.\"]\n}\n```\n\n#### RefreshToken Table\n\n**Description**: Stores JWT refresh tokens for user sessions, including their expiration and usage status.\n\n| Column Name   | Data Type      | Constraints                              | Description                                               |\n|---------------|----------------|------------------------------------------|-----------------------------------------------------------|\n| `id`          | `SERIAL`       | `PRIMARY KEY`                            | Unique identifier for each refresh token record.         |\n| `user_id`     | `INTEGER`      | `REFERENCES User(id)`                    | References the `User` table to link the refresh token to a specific user. |\n| `token`       | `VARCHAR(255)` |                                          | JWT refresh token string used to renew user authentication sessions. |\n| `expires_at`  | `TIMESTAMP`    |                                          | Timestamp indicating when the refresh token will expire. |\n| `used`        | `BOOLEAN`      | `DEFAULT FALSE`                          | Indicates whether the refresh token has been used to issue a new token. |\n| `created_at`  | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the refresh token record was created.     |\n| `updated_at`  | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the refresh token record was last updated.|\n| `deleted_at`  | `TIMESTAMP`    | `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` links the refresh token to a specific user in the `User` table.\n- `token` stores the actual JWT refresh token.\n- `expires_at` indicates when the token is no longer valid.\n- `used` tracks whether the token has been utilized.\n- `created_at` and `updated_at` track when the record was created and modified.\n- `deleted_at` allows for soft deletes.\n\n\n```sql\nTable RefreshToken [NOTE: \"Stores JWT refresh tokens for user sessions, including their expiration and usage status.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each refresh token record.\"]\n  user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the refresh token to a specific user.\"]\n  token VARCHAR(255) [NOTE: \"JWT refresh token string used to renew user authentication sessions.\"]\n  expires_at TIMESTAMP [NOTE: \"Timestamp indicating when the refresh token will expire.\"]\n  used BOOLEAN [default: FALSE, NOTE: \"Indicates whether the refresh token has been used to issue a new token.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the refresh token record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the refresh token record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the record as deleted without actual removal.\"]\n}\n```\n\n#### OAuthProvider Table\n\n**Description**: Manages OAuth providers used for external authentication.\n\n| Column Name     | Data Type  | Constraints                              | Description                                               |\n|-----------------|------------|------------------------------------------|-----------------------------------------------------------|\n| `id`            | `SERIAL`   | `PRIMARY KEY`                            | Unique identifier for each OAuth provider.               |\n| `provider_name` | `VARCHAR(100)`   |                                          | Name of the OAuth provider (e.g., 'Google', 'Facebook'). |\n| `client_id`     | `VARCHAR(255)`   |                                          | Client ID provided by the OAuth provider.                |\n| `client_secret` | `VARCHAR(255)`   |                                          | Client Secret provided by the OAuth provider.            |\n| `created_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the record was created.                   |\n| `updated_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the record was last updated.              |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `provider_name` specifies the name of the OAuth provider used for authentication.\n- `client_id` and `client_secret` are used to authenticate with the OAuth provider.\n- `created_at` and `updated_at` track the creation and modification times of the record.\n\n```sql\nTable OAuthProvider [NOTE: \"Contains information about OAuth providers.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each OAuth provider.\"]\n  provider_name VARCHAR(100) [NOTE: \"Name of the OAuth provider (e.g., 'Google', 'Facebook').\"]\n  client_id VARCHAR(255) [NOTE: \"Client ID provided by the OAuth provider.\"]\n  client_secret VARCHAR(255) [NOTE: \"Client Secret provided by the OAuth provider.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the record was last updated.\"]\n}\n```\n\n#### OAuthAccessToken Table\n\n**Description**: Represents access tokens issued by OAuth providers for authentication and authorization.\n\n| Column Name     | Data Type  | Constraints                              | Description                                               |\n|-----------------|------------|------------------------------------------|-----------------------------------------------------------|\n| `id`            | `SERIAL`   | `PRIMARY KEY`                            | Unique identifier for each access token.                 |\n| `user_id`       | `INTEGER`  | `REFERENCES User(id)`                    | References the User table to link the token to a specific user. |\n| `provider_id`   | `INTEGER`  | `REFERENCES OAuthProvider(id)`           | References the OAuthProvider table to identify the provider of the token. |\n| `access_token`  | `VARCHAR(255)`   |                                          | The OAuth access token string.                           |\n| `token_type`    | `VARCHAR(50)`   |                                          | Type of token (e.g., 'Bearer').                          |\n| `expires_in`    | `INTEGER`  |                                          | Token expiration time in seconds.                       |\n| `created_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the access token was created.             |\n| `updated_at`    | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the access token was last updated.        |\n| `deleted_at`    | `TIMESTAMP`| `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` links the token to a specific user.\n- `provider_id` identifies the OAuth provider that issued the token.\n- `access_token` is the actual token used for accessing protected resources.\n- `token_type` specifies the type of token issued.\n- `expires_in` indicates how long the token is valid in seconds.\n- `created_at` and `updated_at` track the creation and modification times of the token.\n\n```sql\nTable OAuthAccessToken [NOTE: \"Records OAuth access tokens issued to users.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each access token.\"]\n  user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the token to a specific user.\"]\n  provider_id INTEGER [ref: \u003e OAuthProvider.id, NOTE: \"References the OAuthProvider table to identify the provider of the token.\"]\n  access_token VARCHAR(255) [NOTE: \"The OAuth access token.\"]\n  token_type VARCHAR(50) [NOTE: \"Type of token (e.g., 'Bearer').\"]\n  expires_in INTEGER [NOTE: \"Token expiration time in seconds.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the access token was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the access token was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the token record as deleted without actual removal.\"]\n}\n```\n\n#### OAuthRefreshToken Table\n\n**Description**: Represents refresh tokens used to obtain new access tokens after expiration.\n\n| Column Name      | Data Type  | Constraints                              | Description                                               |\n|------------------|------------|------------------------------------------|-----------------------------------------------------------|\n| `id`             | `SERIAL`   | `PRIMARY KEY`                            | Unique identifier for each refresh token.                |\n| `user_id`        | `INTEGER`  | `REFERENCES User(id)`                    | References the User table to link the token to a specific user. |\n| `provider_id`    | `INTEGER`  | `REFERENCES OAuthProvider(id)`           | References the OAuthProvider table to identify the provider of the token. |\n| `refresh_token`  | `VARCHAR(255)`   |                                          | The OAuth refresh token string.                          |\n| `created_at`     | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the refresh token was created.            |\n| `updated_at`     | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the refresh token was last updated.       |\n| `deleted_at`     | `TIMESTAMP`| `DEFAULT NULL`                           | Timestamp for soft deletes, marking the record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` links the refresh token to a specific user.\n- `provider_id` identifies the OAuth provider that issued the token.\n- `refresh_token` is the actual token used to obtain new access tokens.\n- `created_at` and `updated_at` track the creation and modification times of the token.\n\n\n```sql\nTable OAuthRefreshToken [NOTE: \"Records OAuth refresh tokens issued to users.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each refresh token.\"]\n  user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the token to a specific user.\"]\n  provider_id INTEGER [ref: \u003e OAuthProvider.id, NOTE: \"References the OAuthProvider table to identify the provider of the token.\"]\n  refresh_token VARCHAR(255) [NOTE: \"The OAuth refresh token.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the refresh token was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the refresh token was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the token record as deleted without actual removal.\"]\n}\n```\n\n#### Email Table\n\n**Description**: Stores information about emails sent to users, including recipient details, content, and status.\n\n| Column Name      | Data Type  | Constraints                              | Description                                               |\n|------------------|------------|------------------------------------------|-----------------------------------------------------------|\n| `id`             | `SERIAL`   | `PRIMARY KEY`                            | Unique identifier for each email record.                 |\n| `user_id`        | `INTEGER`  | `REFERENCES User(id)`                    | References the User table to link the email to a specific user. |\n| `temporal_id`    | `VARCHAR(255)` | `UNIQUE`                                 | Unique identifier generated by Temporal services for tracking purposes. |\n| `recipient_email`| `VARCHAR(255)` |                                      | Email address of the recipient.                          |\n| `subject`        | `VARCHAR(255)` |                                      | Subject line of the email.                               |\n| `body`           | `TEXT`     |                                          | Body content of the email.                               |\n| `status`         | `VARCHAR(50)`  |                                      | Current status of the email (e.g., 'sent', 'failed').    |\n| `sent_at`        | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the email was sent.                       |\n| `failed_reason`  | `TEXT`     |                                          | Reason for failure if the email was not successfully sent. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` links the email to a specific user.\n- `temporal_id` is a unique identifier from Temporal services for tracking the Email's processing.\n- `recipient_email` contains the recipient's email address.\n- `subject` and `body` define the content of the email.\n- `status` indicates the current status of the email delivery.\n- `sent_at` tracks when the email was sent.\n- `failed_reason` provides details if the email failed to send.\n\n```sql\nTable Email [NOTE: \"Stores information about emails sent to users, including recipient details, content, and status.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each email record.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the email to a specific user.\"]\n    temporal_id VARCHAR(255) [NOTE: \"Unique identifier from Temporal services for tracking purposes.\"]\n    recipient_email STRING [NOTE: \"Email address of the recipient.\"]\n    subject STRING [NOTE: \"Subject line of the email.\"]\n    body TEXT [NOTE: \"Body content of the email.\"]\n    status STRING [NOTE: \"Current status of the email (e.g., 'sent', 'failed').\"]\n    sent_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the email was sent.\"]\n    failed_reason TEXT [NOTE: \"Reason for failure if the email was not successfully sent.\"]\n}\n```\n\n\n#### OTP Table\n\n**Description**: Stores one-time passwords (OTPs) used for user verification and authentication processes.\n\n```markdown\n| Column Name      | Data Type      | Constraints                              | Description                                               |\n|------------------|----------------|------------------------------------------|-----------------------------------------------------------|\n| `id`             | `SERIAL`       | `PRIMARY KEY`                            | Unique identifier for each OTP record.                   |\n| `user_id`        | `INTEGER`      | `REFERENCES User(id)`                    | References the User table to link the OTP to a specific user. |\n| `otp`            | `VARCHAR(255)` |                                          | The OTP value generated for authentication purposes.      |\n| `expires_at`     | `TIMESTAMP`    |                                          | Timestamp indicating when the OTP will expire.           |\n| `used`           | `BOOLEAN`      | `DEFAULT FALSE`                          | Indicates whether the OTP has been used.                 |\n| `temporal_id`    | `VARCHAR(255)` | `UNIQUE`                                 | Unique identifier generated by Temporal services for tracking purposes. |\n| `created_at`     | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the OTP record was created.               |\n| `updated_at`     | `TIMESTAMP`    | `DEFAULT CURRENT_TIMESTAMP`              | Timestamp when the OTP record was last updated.          |\n| `deleted_at`     | `TIMESTAMP`    | `DEFAULT NULL`                           | Timestamp for soft deletes, marking the OTP record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id` links the OTP to a specific user.\n- `temporal_id` is a unique identifier from Temporal services for tracking the OTP's processing.\n- `otp` contains the one-time password value.\n- `expires_at` indicates when the OTP will expire.\n- `used` shows whether the OTP has been used.\n- `temporal_id` is a unique identifier from Temporal services for tracking the OTP's processing.\n- `created_at` and `updated_at` track the creation and modification times of the OTP.\n- `deleted_at` marks the OTP as deleted without actual removal from the database.\n\n\n```sql\nTable OTP [NOTE: \"Stores one-time passwords (OTPs) used for user verification and authentication processes.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each OTP record.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the OTP to a specific user.\"]\n    temporal_id VARCHAR(255) [NOTE: \"Unique identifier from Temporal services for tracking purposes.\"]\n    otp STRING [NOTE: \"The OTP value generated for authentication purposes.\"]\n    expires_at TIMESTAMP [NOTE: \"Timestamp indicating when the OTP will expire.\"]\n    used BOOLEAN [default: FALSE, NOTE: \"Indicates whether the OTP has been used.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the OTP record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the OTP record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the OTP record as deleted without actual removal.\"]\n}\n```\n\n### Product Management\n\n#### Category Table\n\n**Description**: Categorizes products.\n\n| Column Name  | Data Type  | Constraints                            | Description                                               |\n|--------------|------------|----------------------------------------|-----------------------------------------------------------|\n| `id`         | `SERIAL`   | `PRIMARY KEY`                          | Unique identifier for each category.                     |\n| `name`       | `VARCHAR(100)`   |                                        | Name of the category.                                   |\n| `created_by` | `INTEGER`  | `REFERENCES User(id)`                  | References the User table to track who created the category. |\n| `created_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the category was created.                 |\n| `updated_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the category was last updated.            |\n| `deleted_at` | `TIMESTAMP`| `DEFAULT NULL`                         | Timestamp for soft deletes, marking the category as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `name`: The name of the category.\n- `created_by`: Tracks the user who created the category.\n- `created_at` and `updated_at`: Track creation and last modification times.\n\n```sql\nTable Category [NOTE: \"Stores product categories, allowing products to be organized and classified.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each category.\"]\n  name VARCHAR(100) [NOTE: \"Name of the category.\"]\n  created_by INTEGER [ref: \u003e User.id, NOTE: \"References the User table to track who created the category.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the category was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the category was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the category as deleted without actual removal.\"]\n}\n```\n\n#### Product Table\n\n**Description**: Stores product details.\n\n| Column Name  | Data Type  | Constraints                            | Description                                               |\n|--------------|------------|----------------------------------------|-----------------------------------------------------------|\n| `id`         | `SERIAL`   | `PRIMARY KEY`                          | Unique identifier for each product.                      |\n| `name`       | `VARCHAR(150)`   |                                        | Name of the product.                                    |\n| `category_id` | `INTEGER`  | `REFERENCES Category(id)`              | References the Category table to classify the product into a category. |\n| `created_by` | `INTEGER`  | `REFERENCES User(id)`                  | References the User table to track who created the product. |\n| `created_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the product was created.                  |\n| `updated_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the product was last updated.             |\n| `deleted_at` | `TIMESTAMP`| `DEFAULT NULL`                         | Timestamp for soft deletes, marking the product as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `name`: The name of the product.\n- `category_id`: Links the product to a specific category.\n- `created_by`: Tracks the user who created the product.\n- `created_at` and `updated_at`: Track creation and last modification times.\n\n```sql\nTable Product [NOTE: \"Stores information about products available in the system, including categorization and creation details.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each product.\"]\n  name VARCHAR(150) [NOTE: \"Name of the product.\"]\n  category_id INTEGER [ref: \u003e Category.id, NOTE: \"References the Category table to classify the product into a category.\"]\n  created_by INTEGER [ref: \u003e User.id, NOTE: \"References the User table to track who created the product.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the product was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the product was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the product as deleted without actual removal.\"]\n}\n```\n\n#### ProductImage Table\n\n**Description**: Stores images associated with products, including details about whether an image is primary.\n\n| Column Name  | Data Type  | Constraints                            | Description                                               |\n|--------------|------------|----------------------------------------|-----------------------------------------------------------|\n| `id`         | `SERIAL`   | `PRIMARY KEY`                          | Unique identifier for each product image.                |\n| `product_id` | `INTEGER`  | `REFERENCES Product(id)`               | References the Product table to link the image to a specific product. |\n| `image_url`  | `VARCHAR(255)`   |                                        | URL or path to the image file.                           |\n| `is_primary` | `BOOLEAN`  | `DEFAULT FALSE`                        | Indicates whether this image is the primary image for the product. |\n| `created_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the image record was created.             |\n| `updated_at` | `TIMESTAMP`| `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the image record was last updated.        |\n| `deleted_at` | `TIMESTAMP`| `DEFAULT NULL`                         | Timestamp for soft deletes, marking the image as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `product_id`: Links the image to a specific product.\n- `image_url`: The URL or path where the image is stored.\n- `is_primary`: Indicates if this image is the primary image for the product.\n- `created_at` and `updated_at`: Track creation and last modification times.\n\n```sql\n\nTable ProductImage [NOTE: \"Stores images associated with products, including details about whether an image is primary.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each product image.\"]\n  product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to link the image to a specific product.\"]\n  image_url VARCHAR(255) [NOTE: \"URL or path to the image file.\"]\n  is_primary BOOLEAN [default: false, NOTE: \"Indicates whether this image is the primary image for the product.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the image record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the image record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the image as deleted without actual removal.\"]\n}\n```\n\n#### ProductVariant Table\n\n**Description**: Handles different product variants (e.g., size, color).\n\n| Column Name       | Data Type    | Constraints                            | Description                                               |\n|-------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`              | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each product variant.              |\n| `product_id`      | `INTEGER`    | `REFERENCES Product(id)`               | References the Product table to link the variant to a specific product. |\n| `variant_name`    | `VARCHAR(100)`     |                                        | Name of the variant (e.g., 'Size', 'Color').             |\n| `variant_value`   | `VARCHAR(100)`     |                                        | Value of the variant (e.g., 'Large', 'Red').             |\n| `price_adjustment`| `FLOAT64`    |                                        | Price adjustment based on the variant.                   |\n| `created_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the product variant record was created.   |\n| `updated_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the product variant record was last updated. |\n| `deleted_at`      | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the product variant record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `product_id`: Links the variant to a specific product.\n- `variant_name`: Describes the type of variant (e.g., 'Size', 'Color').\n- `variant_value`: Describes the specific value of the variant (e.g., 'Large', 'Red').\n- `price_adjustment`: Indicates any price change associated with the variant.\n- `created_at` and `updated_at`: Track creation and last modification times.\n\n```sql\nTable ProductVariant [NOTE: \"Contains details about different variants of a product, such as size or color, including any price adjustments.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each product variant.\"]\n    product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to link the variant to a specific product.\"]\n    variant_name VARCHAR(100) [NOTE: \"Name of the variant (e.g., 'Size', 'Color').\"]\n    variant_value VARCHAR(100) [NOTE: \"Value of the variant (e.g., 'Large', 'Red').\"]\n    price_adjustment float64 [NOTE: \"Price adjustment based on the variant.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the product variant record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the product variant record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the product variant record as deleted without actual removal.\"]\n}\n```\n\n### Order Management\n\n#### Order Table\n\n**Description**: Represents a customer's order.\n\n| Column Name   | Data Type    | Constraints                            | Description                                               |\n|---------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`          | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each order.                        |\n| `total_price` | `FLOAT64`    |                                        | Total price of the order.                               |\n| `status`      | `VARCHAR(50)`     |                                        | Current status of the order (e.g., 'pending', 'shipped', 'delivered'). |\n| `order_date`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order was placed.                     |\n| `delivery_date`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order is expected to be delivered..                     |\n| `created_by`  | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to track who created the order. |\n| `created_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order record was created.             |\n| `updated_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order record was last updated.        |\n| `deleted_at`  | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the order as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `total_price`: Represents the total amount for the order.\n- `status`: Indicates the current state of the order.\n- `order_date`: Records when the order was placed.\n- `created_by`: Links the order to the user who created it.\n- `created_at` and `updated_at`: Track creation and last modification times.\n\n\n```sql\nTable Order [NOTE: \"Represents customer orders, including details about the total price, the associated product, and the user who created the order.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each order.\"]\n  total_price FLOAT64 [NOTE: \"Total price of the order.\"]\n  status VARCHAR(50) [NOTE: \"Current status of the order (e.g., 'pending', 'shipped', 'delivered').\"]\n  order_date TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the order was placed.\"]\n  delivery_date TIMESTAMP [NOTE: \"Timestamp when the order is expected to be delivered.\"]\n  created_by INTEGER [ref: \u003e User.id, NOTE: \"References the User table to track who created the order.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the order record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the order record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the order as deleted without actual removal.\"]\n}\n```\n\n#### OrderItem Table\n\n**Description**: Details of items within an order.\n\n| Column Name   | Data Type    | Constraints                            | Description                                               |\n|---------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`          | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each order item.                   |\n| `order_id`    | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the item to a specific order. |\n| `product_id`  | `INTEGER`    | `REFERENCES Product(id)`               | References the Product table to identify the product being ordered. |\n| `quantity`    | `INTEGER`    |                                        | Quantity of the product ordered.                         |\n| `unit_price`  | `FLOAT64`    |                                        | Price per unit of the product at the time of purchase.    |\n| `total_price` | `FLOAT64`    |                                        | Total price for this item, calculated as `quantity * unit_price`. |\n| `created_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order item record was created.        |\n| `updated_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the order item record was last updated.   |\n| `deleted_at`  | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the order item as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `order_id`: Links the item to the order it belongs to.\n- `product_id`: Identifies which product is being ordered.\n- `quantity`: The amount of the product ordered.\n- `unit_price`: The price per unit of the product at the time of the order.\n- `total_price`: Calculated as the product of `quantity` and `unit_price`.\n- `created_at` and `updated_at`: Track the creation and last modification times of the record.\n\n\n```sql\nTable OrderItem [NOTE: \"Details the individual items within an order, including quantities and pricing.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each order item.\"]\n  order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the item to a specific order.\"]\n  product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to identify the product being ordered.\"]\n  quantity INTEGER [NOTE: \"Quantity of the product ordered.\"]\n  unit_price float64 [NOTE: \"Price per unit of the product at the time of purchase.\"]\n  total_price float64 [NOTE: \"Total price for this item, calculated as qty * unit_price.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the order item record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the order item record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the order item as deleted without actual removal.\"]\n}\n```\n\n#### Inventory Table\n\n**Description**: Tracks product stock levels.\n\n| Column Name   | Data Type    | Constraints                            | Description                                               |\n|---------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`          | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each inventory record.             |\n| `product_id`  | `INTEGER`    | `REFERENCES Product(id)`               | References the Product table to link the inventory record to a specific product. |\n| `quantity`    | `INTEGER`    |                                        | Quantity of the product available in inventory.          |\n| `created_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the inventory record was created.         |\n| `updated_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the inventory record was last updated.    |\n| `deleted_at`  | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the inventory as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `product_id`: Links the inventory record to the specific product it tracks.\n- `quantity`: Represents the current stock level of the product.\n- `created_at` and `updated_at`: Track the creation and last modification times of the record.\n\n\n```sql\n\nTable Inventory [NOTE: \"Tracks the inventory levels of products, including quantity and last update time.\"] {\n  id SERIAL [pk, NOTE: \"Unique identifier for each inventory record.\"]\n  product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to link the inventory record to a specific product.\"]\n  quantity INTEGER [NOTE: \"Quantity of the product available in inventory.\"]\n  created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the inventory item record was created.\"]\n  updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the inventory record was last updated.\"]\n  deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the inventory as deleted without actual removal.\"]\n}\n```\n\n\n### Shopping Cart\n\n#### Cart Table\n\n**Description**: Represents a user's shopping cart.\n\n| Column Name   | Data Type    | Constraints                            | Description                                               |\n|---------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`          | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each cart.                         |\n| `user_id`     | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to link the cart to a specific user. |\n| `status`      | `VARCHAR(50)`     |                                        | Status of the cart (e.g., 'active', 'abandoned', 'completed'). |\n| `created_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the cart was created.                     |\n| `updated_at`  | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the cart was last updated.                |\n| `deleted_at`  | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the cart as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id`: Links the cart record to the specific user who owns the cart.\n- `status`: Indicates the current state of the cart.\n- `created_at` and `updated_at`: Track the creation and last modification times of the cart record.\n\n```sql\nTable Cart [NOTE: \"Represents a user's shopping cart, allowing them to add and manage products before purchase.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each cart.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the cart to a specific user.\"]\n    status VARCHAR(50) [NOTE: \"Status of the cart (e.g., 'active', 'abandoned', 'completed').\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the cart was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the cart was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the cart as deleted without actual removal.\"]\n}\n```\n\n#### CartItem Table\n\n**Description**: Stores items added to the cart.\n\n| Column Name       | Data Type    | Constraints                            | Description                                               |\n|-------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`              | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each cart item.                    |\n| `cart_id`         | `INTEGER`    | `REFERENCES Cart(id)`                  | References the Cart table to link the item to a specific cart. |\n| `product_id`      | `INTEGER`    | `REFERENCES Product(id)`               | References the Product table to identify the product added to the cart. |\n| `variant_id`      | `INTEGER`    | `REFERENCES ProductVariant(id)`        | References the ProductVariant table for product variations. |\n| `quantity`        | `INTEGER`    |                                        | Quantity of the product added to the cart.                |\n| `unit_price`      | `FLOAT64`    |                                        | Price per unit of the product at the time of addition to the cart. |\n| `discount_applied`| `FLOAT64`    |                                        | Discount amount applied to this item, if any.             |\n| `created_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the cart item was created.                |\n| `updated_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the cart item was last updated.           |\n| `deleted_at`      | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the cart item as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `cart_id`: Links the item record to the specific cart.\n- `product_id`: Identifies the product added to the cart.\n- `variant_id`: Specifies the variant of the product, if applicable.\n- `quantity`: Number of units of the product added to the cart.\n- `unit_price`: Price of the product at the time of addition.\n- `discount_applied`: Any discount applied to the item.\n- `created_at` and `updated_at`: Track creation and modification times.\n\n```sql\nTable CartItem [NOTE: \"Tracks items added to a user's cart, including the quantity of each product.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each cart item.\"]\n    cart_id INTEGER [ref: \u003e Cart.id, NOTE: \"References the Cart table to link the item to a specific cart.\"]\n    product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to link the item to a specific product.\"]\n    variant_id INTEGER [ref: \u003e ProductVariant.id, NOTE: \"References the ProductVariant table for product variations.\"]\n    quantity INTEGER [NOTE: \"Quantity of the product added to the cart.\"]\n    unit_price float64 [NOTE: \"Price per unit of the product at the time of addition to the cart.\"]\n    discount_applied float64 [NOTE: \"Discount amount applied to this item, if any.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the cart item was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the cart item was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the cart item as deleted without actual removal.\"]\n}\n```\n\n\n#### Payment Table\n\n**Description**: Handles payment information for orders.\n\n| Column Name       | Data Type    | Constraints                            | Description                                               |\n|-------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`              | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each payment record.               |\n| `order_id`        | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the payment to a specific order. |\n| `payment_date`    | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the payment was made.                     |\n| `payment_method`  | `STRING`     |                                        | Method used for payment (e.g., 'Credit Card', 'PayPal').  |\n| `amount`          | `FLOAT64`    |                                        | Amount paid for the order.                               |\n| `status`          | `VARCHAR(50)`     |                                        | Current status of the payment (e.g., 'Pending', 'Completed', 'Failed'). |\n| `transaction_id`  | `STRING`     |                                        | Transaction ID from the payment gateway.                 |\n| `created_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the payment record was created.           |\n| `updated_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the payment record was last updated.      |\n| `deleted_at`      | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the payment record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `order_id`: Links the payment record to the specific order.\n- `payment_date`: Indicates when the payment was made.\n- `payment_method`: Specifies the method used for the payment.\n- `amount`: The total amount paid.\n- `status`: Current state of the payment.\n- `transaction_id`: Identifier provided by the payment gateway.\n- `created_at` and `updated_at`: Track creation and modification times.\n\n```sql\nTable Payment [NOTE: \"Records payment details for orders, including payment method, amount, and status.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each payment record.\"]\n    order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the payment to a specific order.\"]\n    payment_date TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the payment was made.\"]\n    payment_method STRING [NOTE: \"Method used for payment (e.g., 'Credit Card', 'PayPal').\"]\n    amount float64 [NOTE: \"Amount paid for the order.\"]\n    status VARCHAR(50) [NOTE: \"Current status of the payment (e.g., 'Pending', 'Completed', 'Failed').\"]\n    transaction_id STRING [NOTE: \"Transaction ID from the payment gateway.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the payment record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the payment record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the payment record as deleted without actual removal.\"]\n}\n```\n\n#### BillingInfo Table\n\n**Description**: Stores billing details for orders.\n\n| Column Name       | Data Type    | Constraints                            | Description                                               |\n|-------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`              | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each billing information record.    |\n| `user_id`         | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to link the billing info to a specific user. |\n| `order_id`        | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the billing info to a specific order. |\n| `address` | `VARCHAR(255)`     |                                        | Billing address for the order.                           |\n| `phone`   | `VARCHAR(10)`     |                                        | Phone number associated with the billing information.     |\n| `email`   | `VARCHAR(100)`     |                                        | Email address associated with the billing information.    |\n| `method`  | `VARCHAR(50)`     |                                        | Method used for billing (e.g., 'Credit Card', 'Bank Transfer'). |\n| `created_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the billing information record was created. |\n| `updated_at`      | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the billing information record was last updated. |\n| `deleted_at`      | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the billing information record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `user_id`: Links the billing information record to the specific user.\n- `order_id`: Links the billing information record to the specific order.\n- `address`, `phone`, and `email`: Contact details for billing.\n- `billing_method`: Specifies the method used for billing.\n- `created_at` and `updated_at`: Track creation and modification times.\n\n\n```sql\nTable BillingInfo [NOTE: \"Contains billing details associated with user orders, including address, phone, and email.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each billing information record.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the billing info to a specific user.\"]\n    order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the billing info to a specific order.\"]\n    address VARCHAR(255) [NOTE: \"Billing address for the order.\"]\n    phone VARCHAR(10) [NOTE: \"Phone number associated with the billing information.\"]\n    email VARCHAR(100) [NOTE: \"Email address associated with the billing information.\"]\n    method VARCHAR(50) [NOTE: \"Method used for billing (e.g., 'Credit Card', 'Bank Transfer').\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the billing information record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the billing information record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the billing information record as deleted without actual removal.\"]\n}\n```\n\n#### ShippingInfo Table\n\n**Description**: Manages shipping details and status for orders.\n\n| Column Name                | Data Type    | Constraints                            | Description                                               |\n|----------------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`                       | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each shipping record.              |\n| `order_id`                 | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the shipping info to a specific order. |\n| `address`         | `VARCHAR(255)`     |                                        | Address where the order will be shipped.                 |\n| `method`          | `VARCHAR(50)`     |                                        | Method of shipping (e.g., 'Standard', 'Express').        |\n| `shipping_cost`            | `FLOAT64`    |                                        | Cost of shipping the order.                              |\n| `tracking_number`          | `STRING`     |                                        | Tracking number for the shipment.                        |\n| `shipped_at`               | `TIMESTAMP`  |                                        | Timestamp when the order was shipped.                    |\n| `delivered_at`             | `TIMESTAMP`  |                                        | Timestamp when the order was delivered.                  |\n| `estimated_delivery_date`  | `TIMESTAMP`  |                                        | Estimated delivery date for the order.                   |\n| `created_at`               | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the shipping information record was created. |\n| `updated_at`               | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the shipping information record was last updated. |\n| `deleted_at`               | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the shipping information record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `order_id`: Links the shipping information to the specific order.\n- `address`: The destination address for the shipment.\n- `method`: The shipping method used.\n- `shipping_cost`: The cost incurred for shipping.\n- `tracking_number`: Used for tracking the shipment.\n- `shipped_at` and `delivered_at`: Track the shipping and delivery times.\n- `estimated_delivery_date`: Provides an estimate for when the order will arrive.\n- `created_at` and `updated_at`: Track creation and modification times.\n\n```sql\n\nTable ShippingInfo [NOTE: \"Contains shipping details for orders, including addresses, methods, and tracking information.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each shipping record.\"]\n    order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the shipping info to a specific order.\"]\n    address VARCHAR(255) [NOTE: \"Address where the order will be shipped.\"]\n    method VARCHAR(50) [NOTE: \"Method of shipping (e.g., 'Standard', 'Express').\"]\n    shipping_cost float64 [NOTE: \"Cost of shipping the order.\"]\n    tracking_number STRING [NOTE: \"Tracking number for the shipment.\"]\n    shipped_at TIMESTAMP [NOTE: \"Timestamp when the order was shipped.\"]\n    delivered_at TIMESTAMP [NOTE: \"Timestamp when the order was delivered.\"]\n    estimated_delivery_date TIMESTAMP [NOTE: \"Estimated delivery date for the order.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the shipping information record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the shipping information record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the shipping information record as deleted without actual removal.\"]\n}\n```\n\n### Marketing and Discounts\n\n#### Coupon Table\n\n**Description**: Manages discount codes.\n\n| Column Name        | Data Type    | Constraints                            | Description                                               |\n|--------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`               | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each coupon.                       |\n| `code`             | `VARCHAR(50)`     |                                        | Unique code for the coupon.                              |\n| `description`      | `TEXT`       |                                        | Description or details about the coupon.                 |\n| `discount_type`    | `VARCHAR(50)`     |                                        | Type of discount (e.g., 'Percentage', 'Fixed').          |\n| `discount_value`   | `FLOAT64`    |                                        | Value of the discount.                                  |\n| `start_date`       | `TIMESTAMP`  |                                        | Date and time when the coupon becomes valid.             |\n| `end_date`         | `TIMESTAMP`  |                                        | Date and time when the coupon expires.                   |\n| `created_by`       | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to link the coupon to the user who created it. |\n| `created_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the coupon record was created.            |\n| `updated_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the coupon record was last updated.       |\n| `deleted_at`       | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the coupon record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `code`: Unique identifier for applying the coupon.\n- `description`: Provides details about the coupon.\n- `discount_type`: Indicates how the discount is applied (e.g., percentage off or fixed amount off).\n- `discount_value`: The actual value of the discount.\n- `start_date` and `end_date`: Define the validity period of the coupon.\n- `created_by`: Links to the user who created the coupon.\n- `created_at` and `updated_at`: Track creation and modification times.\n\n```sql\nTable Coupon [NOTE: \"Contains details about discount coupons available for use in the system.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each coupon.\"]\n    code VARCHAR(50) [NOTE: \"Unique code for the coupon.\"]\n    description TEXT [NOTE: \"Description or details about the coupon.\"]\n    discount_type VARCHAR(50) [NOTE: \"Type of discount (e.g., 'Percentage', 'Fixed').\"]\n    discount_value float64 [NOTE: \"Value of the discount.\"]\n    start_date TIMESTAMP [NOTE: \"Date and time when the coupon becomes valid.\"]\n    end_date TIMESTAMP [NOTE: \"Date and time when the coupon expires.\"]\n    created_by INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the coupon to the user who created it.\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the coupon record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the coupon record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the coupon record as deleted without actual removal.\"]\n}\n```\n\n#### AppliedCoupon Table\n\n**Description**: Tracks coupons applied to orders.\n\n| Column Name        | Data Type    | Constraints                            | Description                                               |\n|--------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`               | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each applied coupon record.        |\n| `order_id`         | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the applied coupon to a specific order. |\n| `coupon_id`        | `INTEGER`    | `REFERENCES Coupon(id)`                | References the Coupon table to link the applied coupon to a specific coupon. |\n| `discount_applied` | `FLOAT64`    |                                        | Amount of discount applied to the order.                 |\n| `status`           | `VARCHAR(50)`     |                                        | Status of the coupon application (e.g., 'applied', 'refunded'). |\n| `created_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the applied coupon record was created.    |\n| `deleted_at`       | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the applied coupon record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `order_id`: Links to the order where the coupon was applied.\n- `coupon_id`: Links to the specific coupon that was applied.\n- `discount_applied`: Indicates how much discount was applied to the order.\n- `status`: Reflects the current state of the coupon application (e.g., whether it was applied or refunded).\n- `created_at`: Records the time when the coupon was applied.\n- `deleted_at`: Used for soft deletes to mark the record as deleted without actual removal.\n\n```sql\nTable AppliedCoupon [NOTE: \"Tracks the coupons applied to orders, including the discount amount applied.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each applied coupon record.\"]\n    order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the applied coupon to a specific order.\"]\n    coupon_id INTEGER [ref: \u003e Coupon.id, NOTE: \"References the Coupon table to link the applied coupon to a specific coupon.\"]\n    discount_applied float64 [NOTE: \"Amount of discount applied to the order.\"]\n    status VARCHAR(50) [NOTE: \"Status of the coupon application (e.g., 'applied', 'refunded').\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the applied coupon record was created.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the applied coupon record as deleted without actual removal.\"]\n}\n```\n\n\n### Reviews and Ratings\n\n#### Review Table\n\n**Description**: Captures product reviews and ratings.\n\n| Column Name        | Data Type    | Constraints                            | Description                                               |\n|--------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`               | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each review.                       |\n| `product_id`       | `INTEGER`    | `REFERENCES Product(id)`               | References the Product table to link the review to a specific product. |\n| `user_id`          | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to link the review to the user who wrote it. |\n| `rating`           | `INTEGER`    |                                        | Rating given by the user (e.g., 1-5 stars).              |\n| `comment`          | `TEXT`       |                                        | Textual comment or review left by the user.             |\n| `status`           | `VARCHAR(50)`     |                                        | Status of the review (e.g., 'Pending', 'Approved', 'Rejected'). |\n| `created_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the review record was created.            |\n| `updated_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the review record was last updated.       |\n| `deleted_at`       | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the review record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `product_id`: Links to the product being reviewed.\n- `user_id`: Links to the user who wrote the review.\n- `rating`: Represents the user's rating for the product.\n- `comment`: Contains the textual feedback provided by the user.\n- `status`: Reflects the current state of the review.\n- `created_at`: Records when the review was created.\n- `updated_at`: Records when the review was last updated.\n- `deleted_at`: Used for soft deletes to mark the review as deleted without actual removal.\n\n```sql\nTable Review [NOTE: \"Stores user reviews for products, including ratings and comments.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each review.\"]\n    product_id INTEGER [ref: \u003e Product.id, NOTE: \"References the Product table to link the review to a specific product.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the review to the user who wrote it.\"]\n    rating INTEGER [NOTE: \"Rating given by the user (e.g., 1-5 stars).\"]\n    comment TEXT [NOTE: \"Textual comment or review left by the user.\"]\n    status VARCHAR(50) [NOTE: \"Status of the review (e.g., 'Pending', 'Approved', 'Rejected').\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the review record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the review record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the review record as deleted without actual removal.\"]\n}\n```\n\n#### ShippingReview Table\n\n**Description**: Stores user reviews specifically for shipping experiences.\n\n| Column Name        | Data Type    | Constraints                            | Description                                               |\n|--------------------|--------------|----------------------------------------|-----------------------------------------------------------|\n| `id`               | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each shipping review.              |\n| `order_id`         | `INTEGER`    | `REFERENCES Order(id)`                 | References the Order table to link the shipping review to a specific order. |\n| `user_id`          | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to link the review to the user who wrote it. |\n| `rating`           | `INTEGER`    |                                        | Rating given by the user for the shipping experience (e.g., 1-5 stars). |\n| `comment`          | `TEXT`       |                                        | Textual comment or review left by the user regarding the shipping experience. |\n| `delivery_time`    | `TIMESTAMP`  |                                        | Timestamp when the product was delivered.                |\n| `status`           | `VARCHAR(50)`     |                                        | Status of the shipping process (e.g., 'On Time', 'Delayed'). |\n| `created_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the shipping review record was created.    |\n| `updated_at`       | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the shipping review record was last updated. |\n| `deleted_at`       | `TIMESTAMP`  | `DEFAULT NULL`                         | Timestamp for soft deletes, marking the shipping review record as deleted without actual removal. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `order_id`: Links to the specific order for which the shipping experience is reviewed.\n- `user_id`: Links to the user who wrote the shipping review.\n- `rating`: Represents the user's rating for the shipping experience.\n- `comment`: Contains feedback regarding the shipping experience.\n- `delivery_time`: Records the actual delivery time of the order.\n- `status`: Reflects the shipping process status.\n- `created_at`: Records when the review was created.\n- `updated_at`: Records when the review was last updated.\n- `deleted_at`: Used for soft deletes to mark the review as deleted without actual removal.\n\n```sql\nTable ShippingReview [NOTE: \"Stores user reviews specifically for shipping experiences.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each shipping review.\"]\n    order_id INTEGER [ref: \u003e Order.id, NOTE: \"References the Order table to link the shipping review to a specific order.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to link the review to the user who wrote it.\"]\n    rating INTEGER [NOTE: \"Rating given by the user for the shipping experience (e.g., 1-5 stars).\"]\n    comment TEXT [NOTE: \"Textual comment or review left by the user regarding the shipping experience.\"]\n    delivery_time TIMESTAMP [NOTE: \"Timestamp when the product was delivered.\"]\n    status VARCHAR(50) [NOTE: \"Status of the shipping process (e.g., 'On Time', 'Delayed').\"]\n    created_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the review record was created.\"]\n    updated_at TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the review record was last updated.\"]\n    deleted_at TIMESTAMP [default: NULL, NOTE: \"Timestamp for soft deletes, marking the review record as deleted without actual removal.\"]\n}\n```\n\n\n### Change Tracking\n\n#### ChangeLogs Table\n\n**Description**: Records changes made to entities for auditing purposes.\n\n| Column Name   | Data Type    | Constraints                            | Description                                                |\n|---------------|--------------|----------------------------------------|------------------------------------------------------------|\n| `id`          | `SERIAL`     | `PRIMARY KEY`                          | Unique identifier for each change log entry.              |\n| `entity_type` | `VARCHAR(255)`     |                                        | The type of entity that was changed, e.g., 'User', 'Order', etc. |\n| `entity_id`   | `INTEGER`    |                                        | The ID of the record that was modified.                   |\n| `field_name`  | `VARCHAR(255)`     |                                        | The name of the field that was changed.                   |\n| `old_value`   | `STRING`     |                                        | The previous value of the field before the change.         |\n| `new_value`   | `STRING`     |                                        | The new value of the field after the change.              |\n| `action`      | `VARCHAR(50)`     |                                        | The type of action performed, such as 'UPDATE', 'INSERT', or 'DELETE'. |\n| `timestamp`   | `TIMESTAMP`  | `DEFAULT CURRENT_TIMESTAMP`            | Timestamp when the change was recorded.                   |\n| `user_id`     | `INTEGER`    | `REFERENCES User(id)`                  | References the User table to identify the user who made the change. |\n| `description` | `STRING`     |                                        | Optional description providing additional context or details about the change. |\n\n**Notes**:\n- `id`: Auto-incrementing primary key.\n- `entity_type`: Indicates the type of entity that was modified, helping to categorize the changes.\n- `entity_id`: Links to the specific record that was modified.\n- `field_name`: Specifies which field in the entity was changed.\n- `old_value`: Captures the value before the change occurred.\n- `new_value`: Captures the value after the change occurred.\n- `action`: Defines the action taken, which can be useful for understanding the nature of the modification.\n- `timestamp`: Records the time when the change was made.\n- `user_id`: Links to the user who made the change, useful for tracking accountability.\n- `description`: Provides additional context or details about the change, if needed.\n\n```sql\nTable ChangeLogs [NOTE: \"Records changes made to various entities within the system, including updates, inserts, and deletions. Useful for auditing and tracking modifications.\"] {\n    id SERIAL [pk, NOTE: \"Unique identifier for each change log entry.\"]\n    entity_type VARCHAR(255) [NOTE: \"The type of entity that was changed, e.g., 'User', 'Order', etc.\"]\n    entity_id INTEGER [NOTE: \"The ID of the record that was modified.\"]\n    field_name VARCHAR(255) [NOTE: \"The name of the field that was changed.\"]\n    old_value STRING [NOTE: \"The previous value of the field before the change.\"]\n    new_value STRING [NOTE: \"The new value of the field after the change.\"]\n    action VARCHAR(50) [NOTE: \"The type of action performed, such as 'UPDATE', 'INSERT', or 'DELETE'.\"]\n    timestamp TIMESTAMP [default: `CURRENT_TIMESTAMP`, NOTE: \"Timestamp when the change was recorded.\"]\n    user_id INTEGER [ref: \u003e User.id, NOTE: \"References the User table to identify the user who made the change.\"]\n    description STRING [NOTE: \"Optional description providing additional context or details about the change.\"]\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakkaraponph%2Fgo-fiber-e-commerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakkaraponph%2Fgo-fiber-e-commerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakkaraponph%2Fgo-fiber-e-commerce/lists"}