# bitfocus/companion-module-casparcg-server architecture

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

- Interactive diagram: https://gitdiagram.com/bitfocus/companion-module-casparcg-server
- Repository: https://github.com/bitfocus/companion-module-casparcg-server

## Overview

##### Project Type and Purpose
- This is a Node.js-based Companion module (named “companion-module-casparcg-server”) intended to integrate with the CasparCG server.
- The module serves as a bridge between the Companion core (which may manage various modules) and the CasparCG server—likely issuing commands and handling responses.
- The README and file names (e.g., manifest.json and HELP.md) confirm that this module is designed to plug into a larger ecosystem, providing a standardized interface for broadcast automation or graphics control.

##### Analyzing the File Structure
- Top-Level Files:
- index.js: Likely the main entry point that initializes the module, registers it with the Companion core, and directs incoming actions.
- actions.js: Contains functions or definitions for specific actions the module can perform (such as sending commands to CasparCG).
- package.json: Manages dependencies and scripts typical in Node.js projects.
- LICENSE, .gitignore, and GitHub-related folders indicate standard repository management and CI configuration.
- The companion Directory:
- manifest.json: Contains metadata, configuration details, and integration instructions—this file is key to how the core Companion application discovers and leverages the module.
- HELP.md: Provides documentation and guidance specific to this module.

##### Key Components
a. The Companion Module Components:
- Module Entry Point (index.js): Acts as the interface between the Companion ecosystem’s core and the module’s internal logic.
- Actions Handlers (actions.js): Implements various commands or operations to interact with the CasparCG server.
- Module Metadata (companion/manifest.json): Contains configuration and descriptive data used by the Companion core to load and manage the module.
- Documentation/Help (companion/HELP.md): Supports developers and users in understanding how to use and configure the module.

b. External Integration:

c. Auxiliary Elements (Optional for a high-level overview):
- GitHub Actions/CI: Although not part of the runtime architecture, the workflow (.github/workflows/companion-module-checks.yaml) can be noted as it reflects the build and test pipeline integrity.

##### Relationships and Interactions
- The Companion core (or host application) loads the module using information from the manifest file.
- Upon usage, user interactions or automated triggers within Companion signal the module’s entry point (index.js).
- index.js then calls functions from actions.js, which are responsible for interfacing with the CasparCG server.
- Any responses or state changes from the CasparCG server can flow back through the module to be processed or displayed by the Companion core.
- Where applicable, configuration options (possibly loaded from the manifest or referenced help docs) dictate behavior or command parameters.

##### Architectural Patterns and Principles
- Clearly separate configuration (manifest, documentation) from runtime logic (index.js and actions.js).
- That this is a plug-in style design: the module is a self-contained unit meant to be discovered and used by a host application.
- A layered design where the module acts as an intermediary: translating requests from the Companion core into commands for the CasparCG server.
- Optional mention of integration testing pipelines as part of CI to ensure module stability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Companion Core
    CompanionCore["Companion Core<br/>(Host Application)"]:::core

    %% External Service
    CasparCG["CasparCG Server<br/>(External Service)"]:::external

    %% CI Pipeline
    CI[".github/workflows/companion-module-checks.yaml<br/>(CI Pipeline)"]:::ci

    %% Companion Module Components
    subgraph "Companion Module"
        mod_index["index.js<br/>(Module Entry Point)"]:::internal
        actions["actions.js<br/>(Action Handlers)"]:::internal
        mod_index -->|"calls"| actions
    end

    %% Module Configuration
    subgraph "Module Configuration"
        manifest["manifest.json<br/>(Module Metadata)"]:::config
        help["HELP.md<br/>(Documentation)"]:::doc
    end

    %% Relationships
    CompanionCore -->|"loads"| mod_index
    actions -->|"sends_command"| CasparCG

    %% Link CI (Optional: representing build/test pipeline)
    CI ---|"validates"| mod_index

    %% Click Events
    click mod_index "https://github.com/bitfocus/companion-module-casparcg-server/blob/master/index.js"
    click actions "https://github.com/bitfocus/companion-module-casparcg-server/blob/master/actions.js"
    click manifest "https://github.com/bitfocus/companion-module-casparcg-server/blob/master/companion/manifest.json"
    click help "https://github.com/bitfocus/companion-module-casparcg-server/blob/master/companion/HELP.md"
    click CI "https://github.com/bitfocus/companion-module-casparcg-server/blob/master/.github/workflows/companion-module-checks.yaml"

    %% Styles
    classDef core fill:#82E0AA,stroke:#2E8B57,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef ci fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef internal fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef doc fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
```
