# zohodevelopers/embeddedapp-js-sdk architecture

> Architecture diagram of the GitHub repository zohodevelopers/embeddedapp-js-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zohodevelopers/embeddedapp-js-sdk
- Repository: https://github.com/zohodevelopers/embeddedapp-js-sdk

## Overview

##### Main Components
- Core SDK Library – Represented by the files in the lib directory (e.g., ZSDK.js and ZohoCrmHelper.js). This is the heart of your SDK that handles event subscriptions, initialization, and communication with the Zoho CRM ecosystem.
- Documentation Generator – The jaguarjs-jsdoc folder contains Grunt scripts, Less (CSS) files, templates (tmpl), and static assets. It is used to generate documentation for the SDK.
- Test Suite – The test directory houses various HTML and JS test files that are used to simulate and validate the behavior of the SDK.
- Configuration/Build Tools – Files such as build.gradle, conf.json, and package.json (in jaguarjs-jsdoc) indicate that there is an automated build/deployment and configuration setup.

##### Relationships & Interactions
- The Core SDK receives initialization calls and event registrations from client applications (shown in sample code from the README). It then uses internal logic (possibly through helper functions) to interact with Zoho CRM’s embedded environment.
- The Documentation Generator is used separately to automatically parse the SDK source code, apply doc templates, and produce user documentation. It is not invoked at runtime in a production environment but is essential for external users.
- The tests interact with the SDK by including it in HTML pages and running sample scenarios. This validates the event binding and functionality provided by the library.
- The build and configuration tools coordinate how the library and documentation are built/deployed.

##### Architectural Patterns/Design Principles
- Modularity – There is a clear separation between the core library (logic and helper modules), the documentation generation system, and the testing framework.
- Event-driven Design – The README sample shows that the SDK uses an event subscription (pub/sub-like) mechanism to notify client code about dynamic events from the CRM environment.
- Separation of Concerns – Code related to documentation (jaguarjs-jsdoc) is separated from the core business logic (lib/) and tests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes outside subgraphs
    ClientApps("Client Applications (Zoho CRM embedded apps)"):::client
    ZohoCRM("Zoho CRM Interface"):::crm

    %% Subgraph for Core SDK Library
    subgraph "Core SDK Library"
        libMain("SDK Core"):::sdkMain
        fileZ("ZSDK.js"):::sdkFile
        fileHelper("ZohoCrmHelper.js"):::sdkFile
        libMain --> fileZ
        libMain --> fileHelper
    end

    %% Subgraph for Documentation Generator
    subgraph "Documentation Generator"
        docMain("Doc Generator"):::docMain
        grunt("Gruntfile.js"):::docFile
        less("Less Templates"):::docFile
        tmpl("Templates"):::docFile
        static("Static Assets"):::docFile
        docMain --> grunt
        docMain --> less
        docMain --> tmpl
        docMain --> static
    end

    %% Subgraph for Test Suite
    subgraph "Test Suite"
        testMain("SDK Tests"):::testMain
        htmlTests("HTML Tests"):::testFile
        jsTests("JS Tests"):::testFile
        testMain --> htmlTests
        testMain --> jsTests
    end

    %% Subgraph for Build & Configuration
    subgraph "Build & Configuration"
        build("Build Tools"):::configMain
        gradle("build.gradle"):::configFile
        conf("conf.json"):::configFile
        pkg("package.json"):::configFile
        confJ("jaguarjs-jsdoc/conf.json"):::configFile
        build --> gradle
        build --> conf
        build --> pkg
        build --> confJ
    end

    %% Interactions
    ClientApps -->|"init/on_events"| libMain
    libMain -->|"communicates_events"| ZohoCRM
    libMain -->|"source_for_docs"| docMain
    testMain -->|"validates"| libMain
    build -->|"builds_deploys"| libMain
    build -->|"builds_deploys"| docMain

    %% Click Events for Core SDK Library
    click libMain "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/lib/"
    click fileZ "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/lib/ZSDK.js"
    click fileHelper "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/lib/ZohoCrmHelper.js"

    %% Click Events for Documentation Generator
    click docMain "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/jaguarjs-jsdoc/"
    click grunt "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/jaguarjs-jsdoc/Gruntfile.js"
    click less "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/jaguarjs-jsdoc/less/"
    click tmpl "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/jaguarjs-jsdoc/tmpl/"
    click static "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/jaguarjs-jsdoc/static/"

    %% Click Events for Test Suite
    click testMain "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/test/"
    click htmlTests "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/test/html/"
    click jsTests "https://github.com/zohodevelopers/embeddedapp-js-sdk/tree/master/test/js/"

    %% Click Events for Build & Configuration
    click gradle "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/build.gradle"
    click conf "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/conf.json"
    click pkg "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/jaguarjs-jsdoc/package.json"
    click confJ "https://github.com/zohodevelopers/embeddedapp-js-sdk/blob/master/jaguarjs-jsdoc/conf.json"

    %% Styles
    classDef client fill:#a0d8f1,stroke:#333,stroke-width:2px;
    classDef crm fill:#f9d6a5,stroke:#333,stroke-width:2px;
    
    classDef sdkMain fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef sdkFile fill:#dae8fc,stroke:#333,stroke-width:1px;
    
    classDef docMain fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef docFile fill:#e8f8f5,stroke:#333,stroke-width:1px;
    
    classDef testMain fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef testFile fill:#fcf3cf,stroke:#333,stroke-width:1px;
    
    classDef configMain fill:#fad7a0,stroke:#333,stroke-width:2px;
    classDef configFile fill:#f6ddcc,stroke:#333,stroke-width:1px;
```
