# onlyoffice/sdkjs architecture

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

- Interactive diagram: https://gitdiagram.com/onlyoffice/sdkjs
- Repository: https://github.com/onlyoffice/sdkjs

## Overview

##### Main Project Components
- API & SDK Core: The central logic that exposes office document APIs. This is represented by common API files (e.g., in cell/api.js, common/apiBase.js, word/api.js, slide/api.js, visio/api.js) that provide the endpoints and definitions for the Office JavaScript APIs.
- Domain-Specific Modules: These are split into several key areas:
– Cell: For spreadsheet functionality. Contains modules for models, formulas, collaborative editing, views, CSS, and utilities.
– Word: For document editing. Contains modules for document editing, paragraph processing, drawing, styles, and more.
– Slide: For presentation editing. Contains drawing components, themes, API builders, and editor specifics.
– Visio: For diagramming/Visio-related functionality.
– PDF: For PDF annotations, drawing, form processing, and viewer interactions.
- Common/Shared Libraries: Components under “common” providing shared functionality such as drawing objects, chart rendering, collaborative editing base features, and utilities (e.g., geometry, text shaping, plugin APIs, etc.).
- Build & Deployment Tools: Files in the “build” directory, Makefile, Gruntfile.js, and related build scripts responsible for packaging, minification, and deployment.
- Testing & Quality Assurance: The “tests” directory contains a variety of test suites across modules (cell, word, slide, visio, pdf) ensuring functionality and performance.
- External Configurations and Vendor Code: Configuration files (under “configs”, .eslintrc.yaml, .codeclimate.yml, etc.) and vendor folder with external libraries, ensuring code quality and integration with third-party tools.

##### Relationships & Interactions
- The SDK core (API layer) acts as the foundation upon which domain-specific modules like cell, word, slide, and visio are built. These modules leverage shared utilities from the common layer.
- Build tools are used to combine, bundle, and optimize these components, enabling smooth integration into desktop editors and the Document Server.
- Test suites and CI/CD workflows (evident in the .github directories and workflows for CodeQL, dev and common checks) interact with both the build process and source files, enforcing code quality.
- The modules interact with external services and collaborative editing backend layers via defined APIs, as seen in files such as collaborative editing scripts in cell and common.

##### Important Architectural Patterns & Design Principles
- Modular Architecture: The codebase is clearly divided into independent modules (cell, word, slide, visio, pdf) that each encapsulate specific functionality.
- Layered Structure: There is a separation between the presentation/view layers (UI components like Editor, DrawingControllers), business logic (models, core API functions), and utility/common services (shared libraries, collaborative editing modules).
- Reusability & Plug-Ins: Shared components in the “common” directory suggest an emphasis on code reuse. The plugin files and extensible APIs hint at customizable, extensible design which is essential for SDK development.
- Build & Test Automation: The extensive presence of build scripts and a variety of tests indicates a continuous integration approach and automated deployment workflow.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core & Shared"
        API_Core["API & SDK Core"]:::api
        Shared["Common/Shared Libraries"]:::shared
    end

    subgraph "Domain Modules"
        CellModule["Spreadsheet Module (Cell)"]:::domain
        WordModule["Document Editor (Word)"]:::domain
        SlideModule["Presentation Module (Slide)"]:::domain
        VisioModule["Diagramming Module (Visio)"]:::domain
        PDFModule["PDF Module"]:::domain
    end

    subgraph "Infrastructure"
        BuildTools["Build & Deployment Tools"]:::build
        TestingCI["Testing & CI/CD"]:::test
        ExternalConfig["External Configurations & Vendor Code"]:::external
    end

    %% API Core exposes domain modules
    API_Core -->|"exposes"| CellModule
    API_Core -->|"exposes"| WordModule
    API_Core -->|"exposes"| SlideModule
    API_Core -->|"exposes"| VisioModule
    API_Core -->|"exposes"| PDFModule

    %% Domain modules use common libraries
    CellModule -->|"uses"| Shared
    WordModule -->|"uses"| Shared
    SlideModule -->|"uses"| Shared
    VisioModule -->|"uses"| Shared
    PDFModule -->|"uses"| Shared

    %% Build Tools interactions
    BuildTools -->|"builds"| API_Core
    BuildTools -->|"builds"| CellModule
    BuildTools -->|"builds"| WordModule
    BuildTools -->|"builds"| SlideModule
    BuildTools -->|"builds"| VisioModule
    BuildTools -->|"builds"| PDFModule
    BuildTools -->|"builds"| Shared

    %% Testing / CI interactions
    TestingCI -->|"tests"| API_Core
    TestingCI -->|"tests"| CellModule
    TestingCI -->|"tests"| WordModule
    TestingCI -->|"tests"| SlideModule
    TestingCI -->|"tests"| VisioModule
    TestingCI -->|"tests"| PDFModule
    TestingCI -->|"tests"| Shared

    %% External configurations influence
    ExternalConfig -->|"configures"| API_Core
    ExternalConfig -->|"configures"| WordModule
    ExternalConfig -->|"configures"| SlideModule
    ExternalConfig -->|"configures"| VisioModule
    ExternalConfig -->|"configures"| PDFModule
    ExternalConfig -->|"configures"| BuildTools
    ExternalConfig -->|"configures"| TestingCI

    %% Click Events for API & SDK Core
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/cell/api.js"
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/common/apiBase.js"
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/word/api.js"
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/slide/api.js"
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/visio/api.js"
    click API_Core "https://github.com/onlyoffice/sdkjs/blob/master/pdf/api.js"

    %% Click Events for Domain Modules
    click CellModule "https://github.com/onlyoffice/sdkjs/tree/master/cell/"
    click WordModule "https://github.com/onlyoffice/sdkjs/tree/master/word/"
    click SlideModule "https://github.com/onlyoffice/sdkjs/tree/master/slide/"
    click VisioModule "https://github.com/onlyoffice/sdkjs/tree/master/visio/"
    click PDFModule "https://github.com/onlyoffice/sdkjs/tree/master/pdf/"

    %% Click Event for Common/Shared Libraries
    click Shared "https://github.com/onlyoffice/sdkjs/tree/master/common/"

    %% Click Events for Build & Deployment Tools
    click BuildTools "https://github.com/onlyoffice/sdkjs/tree/master/build/"
    click BuildTools "https://github.com/onlyoffice/sdkjs/tree/master/Makefile"

    %% Click Events for Testing & CI/CD
    click TestingCI "https://github.com/onlyoffice/sdkjs/tree/master/tests/"
    click TestingCI "https://github.com/onlyoffice/sdkjs/tree/master/.github/workflows"

    %% Click Events for External Configurations and Vendor Code
    click ExternalConfig "https://github.com/onlyoffice/sdkjs/tree/master/configs/"
    click ExternalConfig "https://github.com/onlyoffice/sdkjs/blob/master/.eslintrc.yaml"
    click ExternalConfig "https://github.com/onlyoffice/sdkjs/blob/master/.codeclimate.yml"
    click ExternalConfig "https://github.com/onlyoffice/sdkjs/tree/master/vendor/"

classDef api fill:#ADD8E6,stroke:#000,stroke-width:2px;
classDef domain fill:#90EE90,stroke:#000,stroke-width:2px;
classDef shared fill:#FFFFE0,stroke:#000,stroke-width:2px;
classDef build fill:#FFD700,stroke:#000,stroke-width:2px;
classDef test fill:#87CEFA,stroke:#000,stroke-width:2px;
classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
