# hnql/test architecture

> Architecture diagram of the GitHub repository hnql/test, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hnql/test
- Repository: https://github.com/hnql/test

## Overview

##### Project type and purpose
- This is a cross-cloud integration connector (“service-cloud-connector”) that synchronizes data between Salesforce B2C Commerce (Demandware/SFCC) and Salesforce Service Cloud “above the API.”
- Its code lives in two runtime contexts:
- Service Cloud (Apex classes, custom settings, connected app)
- B2C Commerce (OCAPI settings, cartridges, job scripts)
- It is delivered as an open-source tool (Salesforce Labs) that you install and configure rather than a monolithic full-stack app.

A. Service Cloud Environment
- Apex package: SCCConnectorPostInstallScript, custom objects, custom settings, field mappings
- CommerceCloudConnector Connected App (OAuth2 client)
- REST endpoints (auto-generated at runtime via service-cloud-connector)
B. B2C Commerce Environment
- Cartridges:
– plugin_service_cloud (OCAPI client configuration)
– int_service_cloud (job scripts: customerSync.js, orderSync.js; steptypes.json)
- Business Manager configurations:
– Remote Site Setting “SCCSG”
– Named Credentials: SFCCClientCreds, SFCCClientCredsBearer, SFCCUserCreds
– OCAPI Shop & Data API settings (wapi_shop_config.json, wapi_data_config.json)
– Custom Site Preferences & Custom Objects (for connector settings and auth token storage)
- Jobs: scc-customer-sync, scc-order-sync with scheduled steps
C. Deployment & Build Tooling
- Apache Ant under settings/sfsc/salesforce_ant_48.0 for deploying metadata to Service Cloud
- build.properties to configure Ant with org credentials and server URL

##### Architectural patterns and principles
- “Above the API” decoupling: Use of standard REST and OCAPI rather than hard-wired code
- Scheduled vs. real-time sync: configurable via site preference (“Is async mode…”)
- Secure credentials management: Named Credentials in Commerce and Connected App in Service Cloud
- Extensible cartridges: plugin + integration layer via SFCC cartridge path

##### Essential detail checklist
- Ant + build.properties → Service Cloud package
- Connected App OAuth2 handshake and callback URL
- Named Credentials and Remote Site Settings feeding into job scripts
- Job names (scc-customer-sync, scc-order-sync) and script file names
- OCAPI Shop & Data APIs with wapi_shop_config.json & wapi_data_config.json

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & Deployment
    Developer["Developer"]:::dev
    Ant["Apache Ant"]:::dev
    BuildProps["build.properties"]:::artifact
    Doc["Project Documentation\nREADME.md"]:::artifact

    Developer --> Ant
    Developer --> Doc
    BuildProps -->|config org creds| Ant

    %% Service Cloud Layer
    subgraph "Service Cloud Environment"
        SCpackage["Service Cloud Package\n(Apex, Custom Settings, Field Mappings)"]:::sc
        ConnectedApp["CommerceCloudConnector Connected App\n(OAuth2 client)"]:::sc
        REST["REST Endpoints\n(auto-generated)"]:::sc
    end

    Ant -->|deploy metadata| SCpackage
    SCpackage --> REST

    %% B2C Commerce Layer
    subgraph "B2C Commerce Environment"
        BMConfigs["Business Manager Configs\nRemote Site, Named Credentials\nOCAPI JSON, Site Preferences"]:::bc
        Cartridges["Cartridges\nplugin_service_cloud, int_service_cloud"]:::bc
        Jobs["Jobs\nscc-customer-sync, scc-order-sync"]:::bc
        ShopDataAPI["OCAPI Shop & Data APIs"]:::bc
    end

    BMConfigs --> Cartridges
    Cartridges --> Jobs

    Jobs -->|REST call\nOAuth2 via Named Credential| REST
    ConnectedApp -->|callback URL\nOAuth2 grant| BMConfigs
    REST -->|OCAPI calls\nvia Named Credential| ShopDataAPI

    %% Click Events
    click Doc "https://github.com/hnql/test/blob/master/README.md"

    %% Styles
    classDef dev fill:#d3d3d3,stroke:#666,stroke-width:1px;
    classDef sc fill:#add8e6,stroke:#036,stroke-width:1px;
    classDef bc fill:#00008b,stroke:#fff,stroke-width:1px,color:#fff;
    classDef artifact fill:#eeeeee,stroke:#999,stroke-width:1px;
```
