# swiftlatex/ide architecture

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

- Interactive diagram: https://gitdiagram.com/swiftlatex/ide
- Repository: https://github.com/swiftlatex/ide

## Overview

##### Project type and purpose
- This is Eclipse Theia, an extensible full-stack IDE platform that can run in the browser (cloud IDE) and on the desktop via Electron.
- It exposes a modular architecture of “packages” (features and services), a plugin system compatible with VS Code extensions, and a core runtime based on dependency injection and JSON-RPC.

##### File structure
- At the root you see Lerna/Yarn workspaces, shared configs, build scripts (webpack, tsconfig), and a “packages/” folder.
- Each subfolder under “packages/” is a separate feature package—e.g. core, workspace, filesystem, debug, plugin-ext, languages, etc.—each containing:
- A browser sub-folder (“frontend contribution”)
- A node or electron-browser sub-folder (“backend contribution”)
- Common code (interfaces, protocols)
- There’s also a CLI package, dev-tools packages, examples, and src-gen for code-generated stubs.

##### README for additional insights
- The README calls it a “Cloud & Desktop IDE Platform,” mentions multi-language support via language and debug server protocols (Language Server Protocol, Debug Server Protocol).
- It refers to extension points and plugin development, hints at a JSON-RPC based communication.

##### Main components
a. Frontend (Browser/Electron Renderer)
- Bundle assembled by webpack from browser contributions of each package.
- Hosts: Application Shell, Widget Manager, Menu/Keybinding Services, Monaco editor integration, UI contributions.
- Runs in:
- Standard browser (HTTP(S) + WebSocket JSON-RPC)
- Electron Renderer (IPC JSON-RPC)
b. Backend (Node/Electron Main)
- Node.js application server (Express or plain HTTP) for cloud deployments.
- Electron Main process for desktop, loading the renderer.
- Hosts the JSON-RPC server side, file-system, processes, workspace services.
c. Plugin Host / Extension System
- A separate process or worker thread that loads plugins (VS Code extensions).
- Communicates with both frontend and backend via RPC.
- Plugin API surface implemented by plugin-ext packages; plugin-ext main and hosted modules.
d. Core Packages and Services
- Core DI container (Inversify-based), contribution registry.
- Shared common protocols (messages, preferences, quick-open, tasks, terminal).
e. External Services and Protocols
- Language Server Protocol (over WebSocket or IPC)
- Debug Server Protocol
- optional external storage, metrics, telemetry.

##### Relationships and interactions
1. User interacts with UI in browser/renderer → triggers command in frontend DI container.
2. Frontend contribution forwards request via JSON-RPC over WebSocket/IPC → to backend.
3. Backend service (e.g. filesystem, workspace, language server proxy) handles request, returns a response back over RPC.
4. Plugins (in plugin host) may intercept commands or implement additional contributions; plugin host communicates with main container via RPC.
5. Language servers and debug adapters (external processes) connect via LSP/DAP over JSON-RPC.

##### Architectural patterns and design principles
- Modular monorepo with Lerna: packages as independent modules.
- Inversion of Control / Dependency Injection across both frontend and backend.
- Extension/contribution pattern: each package registers contributions to menus, commands, widgets.
- RPC layers: JSON-RPC for front-to-back and plugin-host communications.
- Dual-runtime: browser & Electron renderer share the same frontend code; Electron main process shares backend APIs.

##### Technologies, frameworks, libraries
- TypeScript, Inversify.js for DI, Webpack for bundling, Lerna/Yarn workspaces for monorepo management.
- Node.js (Express or HTTP server), Electron for desktop.
- Monaco Editor integration for code editing.
- JSON-RPC implementations for LSP, DAP, and internal communications.
- WebSocket or IPC transport layers.
- Tests using Mocha/Chai, nyc, typedoc for docs.

- Blue: UI / frontend
- Green: Backend / services
- Orange: Plugin Host / extensions
- Rectangles for modules/services
- Annotations for technologies at each connector: “WebSocket JSON-RPC,” “IPC JSON-RPC,” “HTTP REST,” “LSP.”

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        User["User"]:::external
        FB["Frontend Bundle"]:::frontend
        FDI["DI Container (Frontend)"]:::frontend
        AS["Application Shell"]:::frontend
        WM["Widget Manager"]:::frontend
        CM["Context Menu Renderer"]:::frontend
        KB["Keybinding Service"]:::frontend
        ME["Monaco Editor Integration"]:::frontend
        FSF["Filesystem Frontend Contribution"]:::frontend
        WSF["Workspace Frontend Service"]:::frontend
        LSC["LSP Client Contribution"]:::frontend
        DCC["Debug Session Contribution"]:::frontend
    end

    %% Plugin Host Layer
    subgraph "Plugin Host Layer"
        direction TB
        PHFD["Hosted Browser Host"]:::plugin
        PHND["Hosted Node Backend Module"]:::plugin
        PHBM["Main Browser Plugin Bridge"]:::plugin
        PHNM["Main Node Plugin Backend Module"]:::plugin
        VSC["VSCode Extension Layer"]:::plugin
        PAR["Plugin-Ext RPC API"]:::plugin
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        EM["Electron Desktop Entrypoint"]:::backend
        CLI["Theia CLI Entry"]:::backend
        BM["Backend Main Entry"]:::backend
        BAS["Backend Application Server"]:::backend
        BDI["DI Container (Backend)"]:::backend
        FSB["Filesystem Backend Module"]:::backend
        WSB["Workspace Backend Module"]:::backend
        LSB["Languages Backend Module"]:::backend
        DSB["Debug Backend Module"]:::backend
        CPD["Core Protocol Definitions"]:::backend
    end

    %% External Protocols
    LSP["Language Server"]:::external
    DAP["Debug Adapter"]:::external

    %% Connections UI Layer
    User -->|"interacts with"| FB
    FB --> FDI
    FDI --> AS
    FDI --> WM
    FDI --> CM
    FDI --> KB
    FDI --> ME
    FDI --> FSF
    FDI --> WSF
    FDI --> LSC
    FDI --> DCC

    %% UI to Backend / Plugin Host RPC
    FDI -->|"WebSocket JSON-RPC"| BAS
    FDI -->|"IPC JSON-RPC"| BM
    FDI -->|"Plugin RPC"| PHBM

    %% Plugin Host interactions
    PHBM --> PHFD
    PHBM --> PHND
    PHND -->|"RPC"| BDI
    PHBM --> VSC
    VSC --> PAR
    PAR --> BDI

    %% Backend internal
    BM --> BAS
    BAS --> BDI
    BDI --> FSB
    BDI --> WSB
    BDI --> LSB
    BDI --> DSB
    BDI --> CPD

    %% External protocols
    LSB -->|"LSP JSON-RPC"| LSP
    DSB -->|"DAP JSON-RPC"| DAP

    %% Click Events
    click FB "https://github.com/swiftlatex/ide/blob/master/webpack.config.js"
    click AS "https://github.com/swiftlatex/ide/blob/master/packages/core/src/browser/shell/application-shell.ts"
    click WM "https://github.com/swiftlatex/ide/blob/master/packages/core/src/browser/widget-manager.ts"
    click CM "https://github.com/swiftlatex/ide/blob/master/packages/core/src/browser/context-menu-renderer.ts"
    click KB "https://github.com/swiftlatex/ide/blob/master/packages/core/src/browser/keybinding.ts"
    click ME "https://github.com/swiftlatex/ide/blob/master/packages/monaco/src/browser/monaco-editor.ts"
    click FDI "https://github.com/swiftlatex/ide/blob/master/packages/core/src/browser/frontend-application-bindings.ts"
    click BAS "https://github.com/swiftlatex/ide/blob/master/packages/core/src/node/application-server.ts"
    click BM "https://github.com/swiftlatex/ide/blob/master/packages/core/src/node/main.ts"
    click FSF "https://github.com/swiftlatex/ide/blob/master/packages/filesystem/src/browser/filesystem-frontend-contribution.ts"
    click FSB "https://github.com/swiftlatex/ide/blob/master/packages/filesystem/src/node/filesystem-backend-module.ts"
    click WSF "https://github.com/swiftlatex/ide/blob/master/packages/workspace/src/browser/workspace-service.ts"
    click WSB "https://github.com/swiftlatex/ide/blob/master/packages/workspace/src/node/workspace-backend-module.ts"
    click PHFD "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext/src/hosted/browser/worker/worker-main.ts"
    click PHND "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext/src/hosted/node/plugin-ext-hosted-backend-module.ts"
    click PHBM "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext/src/main/browser/connection-main.ts"
    click PHNM "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts"
    click VSC "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext-vscode/src/node/plugin-vscode-backend-module.ts"
    click PAR "https://github.com/swiftlatex/ide/blob/master/packages/plugin-ext/src/common/plugin-api-rpc.ts"
    click LSC "https://github.com/swiftlatex/ide/blob/master/packages/languages/src/browser/language-client-contribution.ts"
    click LSB "https://github.com/swiftlatex/ide/blob/master/packages/languages/src/node/languages-backend-module.ts"
    click DCC "https://github.com/swiftlatex/ide/blob/master/packages/debug/src/browser/debug-session-contribution.ts"
    click DSB "https://github.com/swiftlatex/ide/blob/master/packages/debug/src/node/debug-backend-module.ts"
    click CLI "https://github.com/swiftlatex/ide/blob/master/dev-packages/cli/src/theia.ts"
    click EM "https://github.com/swiftlatex/ide/blob/master/dev-packages/electron/electron-cli.js"
    click CPD "https://github.com/swiftlatex/ide/blob/master/packages/core/src/common/application-protocol.ts"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#D6F5D6,stroke:#28A745,color:#28A745
    classDef plugin fill:#FFE5CC,stroke:#D46A00,color:#D46A00
    classDef external fill:#F0F0F0,stroke:#666666,color:#666666
    class User external
    class LSP,DAP external
```
