# mastergo-design/mastergo-magic-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/mastergo-design/mastergo-magic-mcp
- Repository: https://github.com/mastergo-design/mastergo-magic-mcp

## Overview

##### Main Components
- CLI Entry Point: Highlight the bin/cli.js file. This is where command-line execution begins and the service is invoked via npx.
- Core Service Logic: The src/index.ts file likely acts as the main module that wires up all functionalities and handles interactions.
- Utility Modules:
– Tools: Under src/tools, separate modules such as:
▪ base-tool.ts (a base class or common functionality for tools)
▪ get-component-link.ts (responsible for retrieving component links)
▪ get-dsl.ts (handles DSL extraction from design files)
– HTTP Utility: src/http-util.ts suggests a dedicated module for network calls or interactions with remote services.
- Build & Configuration: The presence of build.js, package.json, tsconfig.json, .npmignore, and .npmrc indicates the build process and configuration management for the npm package.

##### Relationships and Data Flows
- The CLI (bin/cli.js) takes in user input along with tokens and URLs (as seen in the usage instructions) and routes them to the core service in src/index.ts.
- The core service coordinates the operations by calling the appropriate tools (found in src/tools) depending on the command-line inputs.
- For network operations (such as retrieving data from MasterGo design files), the http-util.ts module is used—representing the integration point for external communication.
- The entire process is designed to be run directly with npx, emphasizing a lightweight, dependency-sparse architecture that only requires a Node.js environment.

##### Architectural Patterns and Design Principles
- Modularization: The clear separation between CLI entry, core logic, and specialized tools indicates well-defined modular boundaries.
- Extensibility: The tools directory suggests that additional functionality can be added as separate modules without impacting the overall structure.
- Separation of Concerns: Different responsibilities (command parsing, DSL extraction, network utilities) are isolated into dedicated modules, which simplifies maintenance and potential upgrades.

##### Role of Technologies and Libraries
- Node.js: The entire service runs on Node.js, with the npm ecosystem handling dependencies and distribution.
- TypeScript: With tsconfig.json present, the project is built using TypeScript, ensuring better type-checking and maintainability.
- GitHub Actions: The .github/workflows directory (with files like ci.yml and publish.yml) reflects automated CI/CD pipelines for code quality checks and package publishing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CLI["CLI Entry Point"]:::cli
    Core["Core Service Logic"]:::core
    CLI -->|"triggers"| Core

    subgraph "Utility Modules"
        BaseTool["Base Tool"]:::tool
        CompLink["Get Component Link"]:::tool
        DSL["DSL Extraction"]:::tool
    end
    Core -->|"uses"| BaseTool
    Core -->|"uses"| CompLink
    Core -->|"uses"| DSL

    HTTP["HTTP Utility Module"]:::http
    Core -->|"calls"| HTTP

    subgraph "Build & Configuration"
        BuildJS["build.js"]:::build
        Package["package.json"]:::build
        TSConfig["tsconfig.json"]:::build
        NPMIgnore[".npmignore"]:::build
        NPMRC[".npmrc"]:::build
    end

    subgraph "CI/CD Pipelines"
        CI["ci.yml"]:::cicd
        Publish["publish.yml"]:::cicd
    end

    %% Linking build to CI/CD (representative connection)
    BuildJS -->|"triggers"| CI

    %% Click Events
    click CLI "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/bin/cli.js"
    click Core "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/src/index.ts"
    click BaseTool "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/src/tools/base-tool.ts"
    click CompLink "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/src/tools/get-component-link.ts"
    click DSL "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/src/tools/get-dsl.ts"
    click HTTP "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/src/http-util.ts"
    click BuildJS "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/build.js"
    click Package "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/package.json"
    click TSConfig "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/tsconfig.json"
    click NPMIgnore "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/.npmignore"
    click NPMRC "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/.npmrc"
    click CI "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/.github/workflows/ci.yml"
    click Publish "https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/.github/workflows/publish.yml"

    %% Styles
    classDef cli fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef core fill:#A9DFBF,stroke:#000,stroke-width:2px;
    classDef tool fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef http fill:#F5CBA7,stroke:#000,stroke-width:2px;
    classDef build fill:#D2B4DE,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FAD7A0,stroke:#000,stroke-width:2px;
```
