# kolhun/legcord architecture

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

- Interactive diagram: https://gitdiagram.com/kolhun/legcord
- Repository: https://github.com/kolhun/legcord

## Overview

Legcord is a standalone Electron Discord client: startup initializes configuration and optional client mods, then opens the Discord web app in a customized native window. Users configure themes, plugins, keybinds, games, and client behavior through the integrated settings UI; the main process bridges those choices to runtime features. The README also describes privacy protections, Rich Presence, and experimental mobile support. Edges reflect explicit imports/calls or README statements; unsampled modules are represented only where documented, so some subsystem links are intentionally omitted.

Main entry points: [`src/main.ts`](https://github.com/kolhun/legcord/blob/dev/src/main.ts) (Legcord app startup), [`src/discord/window.ts`](https://github.com/kolhun/legcord/blob/dev/src/discord/window.ts) (Discord window), [`src/shelter/settings/index.ts`](https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/index.ts) (Shelter settings UI), [`src/discord/ipc.ts`](https://github.com/kolhun/legcord/blob/dev/src/discord/ipc.ts) (Main-process IPC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and setup"]
  node_app["Legcord app startup<br/>[main.ts]"]
  node_setup["First-run setup<br/>[main.ts]"]
  node_splash["Startup splash<br/>[main.ts]"]
end

subgraph group_client["Discord runtime"]
  node_discord["Discord window<br/>[window.ts]"]
  node_preload["Preload patches<br/>[patches.mts]"]
  node_csp["Tracker blocking<br/>[csp.ts]"]
  node_ipc["Main-process IPC<br/>[ipc.ts]"]
end

subgraph group_custom["Mods and appearance"]
  node_modloader["Built-in mod loader<br/>[modloader.ts]"]
  node_pluginext["Plugin extension<br/>[plugin.ts]"]
  node_pluginmgr["Plugin manager<br/>[manager.ts]"]
  node_theme["Theme manager<br/>[themes.ts]"]
end

subgraph group_settings["Settings and persistence"]
  node_settingsui["Shelter settings UI<br/>[index.ts]"]
  node_settingspage["General settings<br/>[SettingsPage.tsx]"]
  node_settingsstate["Settings state<br/>[settings.ts]"]
  node_config[("Configuration store<br/>[config.ts]")]
  node_backup["Settings backup<br/>[backup.ts]"]
  node_themespage["Theme settings<br/>[ThemesPage.tsx]"]
end

subgraph group_extras["Integrated features"]
  node_presence["Rich Presence<br/>[rpcProcess.ts]"]
  node_screenshare["Screen sharing<br/>[screenshare.ts]"]
  node_screenshareui["Screen source picker"]
  node_csseditor["CSS editor<br/>[main.ts]"]
end

node_user(("User"))
node_externaldiscord["Discord web app"]

node_user -->|"launches"| node_app
node_app -->|"opens first-run"| node_setup
node_app -.->|"opens"| node_splash
node_app -->|"loads mods"| node_modloader
node_app -->|"initializes"| node_pluginmgr
node_app -->|"creates window"| node_discord
node_discord -->|"loads web app"| node_externaldiscord
node_discord -->|"configures preload"| node_preload
node_app -->|"loads protections"| node_csp
node_discord -.->|"registers IPC"| node_ipc
node_discord -->|"injects themes"| node_theme
node_discord -->|"starts presence"| node_presence
node_discord -.->|"uses capture"| node_screenshare
node_ipc -->|"opens editor"| node_csseditor
node_ipc -->|"reads settings"| node_config
node_pluginmgr -->|"reads plugin state"| node_config
node_settingsui -->|"registers page"| node_settingspage
node_settingsui -->|"refreshes state"| node_settingsstate
node_settingspage -->|"updates settings"| node_settingsstate
node_settingspage -->|"renders backup"| node_backup
node_settingsstate -.->|"persists settings"| node_config
node_settingsui -->|"registers themes"| node_themespage
node_themespage -.->|"manages themes"| node_theme
node_settingsui -.->|"exposes plugins"| node_pluginmgr
node_screenshareui -.->|"selects sources"| node_screenshare

click node_app "https://github.com/kolhun/legcord/blob/dev/src/main.ts"
click node_setup "https://github.com/kolhun/legcord/blob/dev/src/setup/main.ts"
click node_splash "https://github.com/kolhun/legcord/blob/dev/src/splash/main.ts"
click node_discord "https://github.com/kolhun/legcord/blob/dev/src/discord/window.ts"
click node_preload "https://github.com/kolhun/legcord/blob/dev/src/discord/preload/patches.mts"
click node_csp "https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/csp.ts"
click node_ipc "https://github.com/kolhun/legcord/blob/dev/src/discord/ipc.ts"
click node_modloader "https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/modloader.ts"
click node_pluginext "https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/plugin.ts"
click node_pluginmgr "https://github.com/kolhun/legcord/blob/dev/src/discord/plugins/manager.ts"
click node_theme "https://github.com/kolhun/legcord/blob/dev/src/common/themes.ts"
click node_settingsui "https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/index.ts"
click node_settingspage "https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/pages/SettingsPage.tsx"
click node_settingsstate "https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/settings.ts"
click node_config "https://github.com/kolhun/legcord/blob/dev/src/common/config.ts"
click node_backup "https://github.com/kolhun/legcord/blob/dev/src/common/backup.ts"
click node_presence "https://github.com/kolhun/legcord/blob/dev/src/discord/rpcProcess.ts"
click node_screenshare "https://github.com/kolhun/legcord/blob/dev/src/discord/screenshare.ts"
click node_screenshareui "https://github.com/kolhun/legcord/blob/dev/src/shelter/screenshare/components/ScreensharePicker.tsx"
click node_csseditor "https://github.com/kolhun/legcord/blob/dev/src/cssEditor/main.ts"
click node_themespage "https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/pages/ThemesPage.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_setup,node_splash,node_user toneBlue
class node_discord,node_preload,node_csp,node_ipc toneAmber
class node_modloader,node_pluginext,node_pluginmgr,node_theme toneMint
class node_settingsui,node_settingspage,node_settingsstate,node_config,node_backup,node_themespage toneRose
class node_presence,node_screenshare,node_screenshareui,node_csseditor,node_externaldiscord toneIndigo
```

## Components

### Startup and setup

- [Legcord app startup](https://github.com/kolhun/legcord/blob/dev/src/main.ts): `src/main.ts`
- [First-run setup](https://github.com/kolhun/legcord/blob/dev/src/setup/main.ts): `src/setup/main.ts`
- [Startup splash](https://github.com/kolhun/legcord/blob/dev/src/splash/main.ts): `src/splash/main.ts`

### Discord runtime

- [Discord window](https://github.com/kolhun/legcord/blob/dev/src/discord/window.ts): `src/discord/window.ts`
- [Preload patches](https://github.com/kolhun/legcord/blob/dev/src/discord/preload/patches.mts): `src/discord/preload/patches.mts`
- [Tracker blocking](https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/csp.ts): `src/discord/extensions/csp.ts`
- [Main-process IPC](https://github.com/kolhun/legcord/blob/dev/src/discord/ipc.ts): `src/discord/ipc.ts`

### Mods and appearance

- [Built-in mod loader](https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/modloader.ts): `src/discord/extensions/modloader.ts`
- [Plugin extension](https://github.com/kolhun/legcord/blob/dev/src/discord/extensions/plugin.ts): `src/discord/extensions/plugin.ts`
- [Plugin manager](https://github.com/kolhun/legcord/blob/dev/src/discord/plugins/manager.ts): `src/discord/plugins/manager.ts`
- [Theme manager](https://github.com/kolhun/legcord/blob/dev/src/common/themes.ts): `src/common/themes.ts`

### Settings and persistence

- [Shelter settings UI](https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/index.ts): `src/shelter/settings/index.ts`
- [General settings](https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/pages/SettingsPage.tsx): `src/shelter/settings/pages/SettingsPage.tsx`
- [Settings state](https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/settings.ts): `src/shelter/settings/settings.ts`
- [Configuration store](https://github.com/kolhun/legcord/blob/dev/src/common/config.ts): `src/common/config.ts`
- [Settings backup](https://github.com/kolhun/legcord/blob/dev/src/common/backup.ts): `src/common/backup.ts`
- [Theme settings](https://github.com/kolhun/legcord/blob/dev/src/shelter/settings/pages/ThemesPage.tsx): `src/shelter/settings/pages/ThemesPage.tsx`

### Integrated features

- [Rich Presence](https://github.com/kolhun/legcord/blob/dev/src/discord/rpcProcess.ts): `src/discord/rpcProcess.ts`
- [Screen sharing](https://github.com/kolhun/legcord/blob/dev/src/discord/screenshare.ts): `src/discord/screenshare.ts`
- [Screen source picker](https://github.com/kolhun/legcord/blob/dev/src/shelter/screenshare/components/ScreensharePicker.tsx): `src/shelter/screenshare/components/ScreensharePicker.tsx`
- [CSS editor](https://github.com/kolhun/legcord/blob/dev/src/cssEditor/main.ts): `src/cssEditor/main.ts`

### Other components

- **User**
- **Discord web app**

## Connections

- User → Legcord app startup: launches
- Legcord app startup → First-run setup: opens first-run (evidence: `src/main.ts`)
- Legcord app startup → Startup splash: opens (evidence: `src/main.ts`)
- Legcord app startup → Built-in mod loader: loads mods (evidence: `src/main.ts`)
- Legcord app startup → Plugin manager: initializes (evidence: `src/main.ts`)
- Legcord app startup → Discord window: creates window (evidence: `src/main.ts`)
- Discord window → Discord web app: loads web app
- Discord window → Preload patches: configures preload (evidence: `src/discord/window.ts`)
- Legcord app startup → Tracker blocking: loads protections (evidence: `src/main.ts`)
- Discord window → Main-process IPC: registers IPC (evidence: `src/discord/window.ts`)
- Discord window → Theme manager: injects themes (evidence: `src/discord/window.ts`)
- Discord window → Rich Presence: starts presence (evidence: `src/discord/window.ts`)
- Discord window → Screen sharing: uses capture (evidence: `src/discord/window.ts`)
- Main-process IPC → CSS editor: opens editor (evidence: `src/discord/ipc.ts`)
- Main-process IPC → Configuration store: reads settings (evidence: `src/discord/ipc.ts`)
- Plugin manager → Configuration store: reads plugin state (evidence: `src/discord/plugins/manager.ts`)
- Shelter settings UI → General settings: registers page (evidence: `src/shelter/settings/index.ts`)
- Shelter settings UI → Settings state: refreshes state (evidence: `src/shelter/settings/index.ts`)
- General settings → Settings state: updates settings (evidence: `src/shelter/settings/pages/SettingsPage.tsx`)
- General settings → Settings backup: renders backup (evidence: `src/shelter/settings/pages/SettingsPage.tsx`)
- Settings state → Configuration store: persists settings
- Shelter settings UI → Theme settings: registers themes (evidence: `src/shelter/settings/index.ts`)
- Theme settings → Theme manager: manages themes
- Shelter settings UI → Plugin manager: exposes plugins
- Screen source picker → Screen sharing: selects sources
