# dyalog/ride architecture

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

- Interactive diagram: https://gitdiagram.com/dyalog/ride
- Repository: https://github.com/dyalog/ride

## Overview

##### Project type and purpose
- Ride is a cross-platform desktop IDE built with Node.js and web technologies (HTML, CSS/LESS, JavaScript), packaged as native apps via Electron (implied by main.js, packaging scripts, CI for win/linux/osx).
- It connects to a local or remote Dyalog APL engine for editing, debugging, workspace browsing, etc.

##### File structure
- Top-level “src/” → the core JavaScript modules for both the Electron main process (main.js) and renderer (ide.js, cmds.js, dbg.js, ipc.js, etc.).
- “style/” → CSS and LESS files for theming/layout (bootstrap, goldenlayout, Monaco integration).
- “CI/” and “packagescripts/” → scripts for building, signing, packaging for Windows, macOS, Linux.
- “tools/” and “utils/” → code-generators (keyboard, menu, help URL checkers), sample extensions → plugin architecture.
- “test/” → unit tests for core modules (cn.js, ed.js, lb.js, se.js).
- Configuration files: package.json, gruntfile.js, nodemon.json, mkdocs.yml → build, watch, doc generation.

##### README
- Confirms Node.js v18, npm scripts to compile CSS (npm run css), run in dev mode (npm run dev), package native apps (npm run build dist).
- Describes remote access, full documentation link.

##### Components
a. Electron shell
– Main process (main.js): application lifecycle, menu, window creation, native APIs
– Renderer processes (one per window): UI modules under src/, CSS/LESS from style/
b. IPC layer (src/ipc.js): message bus between main and renderers
c. Dyalog APL engine
– Local (spawned child process via Node APIs)
– Remote (TCP/WebSocket connection, protocol.md describes wire protocol)
d. File system & configuration
– Workspace files, settings, session files
e. Extensions/plugins
– sample-extensions folder shows plugin entry points
f. Build & packaging pipeline
– CI server (Jenkinsfile) → runs tests, lint, build
– Platform scripts under CI/packagescripts → sign, notarize, package for each OS
g. External services
– GitHub Releases (publish.sh), Lintian, rpmlint, Apple notary service

##### Relationships and interactions
- UI → sends commands via IPC → main process → routes to APL engine or file system → returns results back via IPC → UI.
- CI pipeline → triggered by commits/tags → executes packaging scripts → outputs native installers.
- Developer local flow → npm scripts → Grunt tasks → CSS compilation, reload via nodemon → live reload in Electron.

##### Architectural patterns and principles
- Separation of concerns: UI logic (renderer) vs native integration (main)
- Plugin architecture: modular code generators, sample extensions
- Build pipeline as code: CI scripts maintain reproducible packaging
- MVC-style in UI modules: cmds.js (controller), listview.js (view), util.js (model helpers)

##### Diagramming conventions
- Use rectangles for components (Main, Renderer, APL Engine, CI server, Packaging scripts)
– UI → IPC → Main → APL
– CI → scripts → native installers
– Blue for runtime components
– Green for build/deploy components
– Yellow for external services (GitHub, Apple notary)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Runtime Layer"
        Main["Electron Main Process"]:::runtime
        IPC["IPC Message Bus"]:::runtime

        subgraph "Renderer Processes"
            IDE["Core UI Module"]:::runtime
            CMDS["Command Controller"]:::runtime
            DBG["Debugger Module"]:::runtime
            MENU["Menu Definitions"]:::runtime
            LIST["List View Component"]:::runtime
            UTIL["Utility Helpers"]:::runtime
            INIT["Workspace & Config Init"]:::runtime
            PRF["Preferences & Settings Panels"]:::runtime
            MON["Monaco APL Integration"]:::runtime
            LESSDIR["LESS Sources"]:::runtime
            DARK["dark-theme.less"]:::runtime
            LIGHT["light-theme.less"]:::runtime
            LAYOUT["layout.less"]:::runtime
        end

        APLL["Dyalog APL Engine (Local)"]:::runtime
        APLR["Dyalog APL Engine (Remote)\n(protocol.md)"]:::runtime
    end

    subgraph "Build & Deploy Layer"
        DEV["Developer Workflow\nnpm, Grunt, nodemon"]:::build
        CI["CI Server\nJenkinsfile"]:::build
        TESTS["Unit Tests"]:::build
        PS["Platform Packaging Scripts"]:::build
        PUBLISH["GitHub Release Script"]:::build
    end

    subgraph "External Services"
        GHR["GitHub Releases"]:::external
        APPLE["Apple Notary Service"]:::external
        LINT["Lintian / rpmlint"]:::external
    end

    %% Runtime interactions
    IDE -->|"invoke commands"| IPC
    CMDS -->|"send commands"| IPC
    IPC -->|"ipc.handle"| Main
    Main -->|"spawn child process"| APLL
    Main -->|"TCP/WebSocket"| APLR

    LESSDIR -->|"compile LESS"| DARK
    LESSDIR -->|"compile LESS"| LIGHT
    LESSDIR -->|"compile LESS"| LAYOUT
    DARK -->|"load CSS"| IDE
    LIGHT -->|"load CSS"| IDE
    LAYOUT -->|"load CSS"| IDE

    %% Build/Deploy interactions
    DEV -->|"npm run css"| LESSDIR
    DEV -->|"npm run dev"| Main
    DEV -->|"grunt watch"| IDE

    CI -->|"runs tests"| TESTS
    CI -->|"exec packaging"| PS
    CI -->|"trigger publish"| PUBLISH

    PS -->|"sign & notarize"| APPLE
    PS -->|"lint packages"| LINT
    PUBLISH -->|"publish binaries"| GHR

    %% Click Events
    click Main "https://github.com/dyalog/ride/blob/master/main.js"
    click IDE "https://github.com/dyalog/ride/blob/master/src/ide.js"
    click CMDS "https://github.com/dyalog/ride/blob/master/src/cmds.js"
    click DBG "https://github.com/dyalog/ride/blob/master/src/dbg.js"
    click IPC "https://github.com/dyalog/ride/blob/master/src/ipc.js"
    click MENU "https://github.com/dyalog/ride/blob/master/src/menu.js"
    click LIST "https://github.com/dyalog/ride/blob/master/src/listview.js"
    click UTIL "https://github.com/dyalog/ride/blob/master/src/util.js"
    click INIT "https://github.com/dyalog/ride/blob/master/src/init.js"
    click PRF "https://github.com/dyalog/ride/blob/master/src/prf.js"
    click PRF "https://github.com/dyalog/ride/blob/master/src/prf_ui.js"
    click LAYOUT "https://github.com/dyalog/ride/blob/master/src/prf_lyt.js"
    click MON "https://github.com/dyalog/ride/blob/master/src/mon_apl.js"
    click APLR "https://github.com/dyalog/ride/blob/master/docs/protocol.md"
    click LESSDIR "https://github.com/dyalog/ride/tree/master/style/less/"
    click DARK "https://github.com/dyalog/ride/blob/master/style/dark-theme.less"
    click LIGHT "https://github.com/dyalog/ride/blob/master/style/light-theme.less"
    click LAYOUT "https://github.com/dyalog/ride/blob/master/style/layout.less"
    click PS "https://github.com/dyalog/ride/tree/master/CI/packagescripts/"
    click CI "https://github.com/dyalog/ride/tree/master/Jenkinsfile"
    click PUBLISH "https://github.com/dyalog/ride/blob/master/CI/publish.sh"
    click TESTS "https://github.com/dyalog/ride/tree/master/test/"
    click DEV "https://github.com/dyalog/ride/tree/master/packagescripts/"
    
    classDef runtime fill:#D0E8FF,stroke:#036,stroke-width:1px
    classDef build fill:#D0FFD6,stroke:#080,stroke-width:1px
    classDef external fill:#FFF5B1,stroke:#880,stroke-width:1px
```
