This document outlines the design and functionality of NitroX running at https://x.nitrocommerce.ai - The system is designed to facilitate seamless integration with Shopify store (SuperAquire on Shopify), enabling features such as script injection, webhook registration, user and organization management, and coupon creation.
Script Injection
get_shopify_script
: Generates and returns JavaScript code based on the organization token and environment settings.add_script_to_shopify_shop_through_graphQl
: Adds scripts to Shopify stores using GraphQL API.remove_script_through_graphQl
: Removes scripts from Shopify stores using GraphQL API.Webhook Management
register_shopify_webhooks_through_graphql
: Registers multiple webhooks for a Shopify store.create_shopify_webhook_through_graphql
: Creates individual webhooks using GraphQL API.User and Organization Management
createUserAndOrganisation
: Creates or updates user and organization entities based on Shopify store data.shopify_login
: Handles login for Shopify users by validating tokens stored in Redis.Coupon Management
create_coupon_in_shopify
: Creates discount coupons using Shopify's GraphQL API.coupon_exists_in_shopify
: Checks if a coupon already exists in a Shopify store.Integration Utilities
build_install_request_url
: Constructs the URL for installing the Shopify app.build_access_token_request_url
: Constructs the URL for fetching access tokens.App Installation
install_shopify
function initiates the installation process by redirecting the user to Shopify's OAuth authorization page.post_install_shopify
function fetches the access token and registers webhooks and scripts.Script Management
add_script_to_shopify_shop_through_graphQl
.remove_script_through_graphQl
.Webhook Registration
register_shopify_webhooks_through_graphql
.User and Organization Creation
createUserAndOrganisation
function creates or updates user and organization entities based on Shopify store data.Coupon Creation
create_coupon_in_shopify
and validated using coupon_exists_in_shopify
.Input:
Processing:
Output:
API Errors:
create_coupon_in_shopify
and register_shopify_webhooks_through_graphql
handle API errors by logging the response and returning appropriate error messages.Validation Errors:
shopify_login
validate tokens and user data before proceeding.External Libraries:
requests
: For making HTTP requests to Shopify APIs.loguru
: For logging.Internal Modules:
core.lib
: Contains helper functions for database operations, API requests, and user management.core.models
: Defines the data models for users and organizations.