# cdr/code-server architecture

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

- Interactive diagram: https://gitdiagram.com/cdr/code-server
- Repository: https://github.com/cdr/code-server

## Overview

code-server runs VS Code on a remote machine and serves its browser-based interface to users. The main workflow starts with command-line configuration, creates an HTTP/WebSocket server, registers routes, and delegates editor requests to the bundled VS Code server. Separate branches handle authentication, proxying, health and update endpoints, and persistent settings. The source index and excerpts establish several internal calls; README statements support the product-level remote-editor workflow. Some route internals and integrations were not sampled, so uncertain connections are omitted.

Main entry points: [`src/node/routes/index.ts`](https://github.com/cdr/code-server/blob/main/src/node/routes/index.ts) (Route Registration), [`src/node/app.ts`](https://github.com/cdr/code-server/blob/main/src/node/app.ts) (HTTP Server), [`src/node/main.ts`](https://github.com/cdr/code-server/blob/main/src/node/main.ts) (Runtime Startup), [`src/node/entry.ts`](https://github.com/cdr/code-server/blob/main/src/node/entry.ts) (Process Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and Configuration"]
  node_cli["CLI Configuration<br/>[cli.ts]"]
  node_entry["Process Entry<br/>[entry.ts]"]
  node_runtime["Runtime Startup<br/>[main.ts]"]
end

subgraph group_server["HTTP and Access"]
  node_httpserver["HTTP Server<br/>[app.ts]"]
  node_routes["Route Registration<br/>[index.ts]"]
  node_auth["Authentication<br/>[login.ts]"]
  node_domainproxy["Domain Proxy<br/>[domainProxy.ts]"]
  node_pathproxy["Port Path Proxy<br/>[pathProxy.ts]"]
  node_proxy["Proxy Utilities<br/>[proxy.ts]"]
end

subgraph group_editor["Editor and Sessions"]
  node_vscode["VS Code Web Server<br/>[vscode.ts]"]
  node_session["Editor Session Manager<br/>[vscodeSocket.ts]"]
  node_wsrouter["WebSocket Routing<br/>[wsRouter.ts]"]
  node_browser["Browser Resources"]
end

subgraph group_operations["Runtime Services"]
  node_settings[("Persistent Settings<br/>[settings.ts]")]
  node_updater["Release Update Check<br/>[update.ts]"]
  node_health["Health Endpoint<br/>[health.ts]"]
  node_heartbeat["Heartbeat Monitor<br/>[heart.ts]"]
end

node_user(("Browser User"))
node_operator(("Server Operator"))
node_github["GitHub Releases"]
node_remote["Remote Machine"]

node_operator -->|"starts process"| node_entry
node_entry -->|"parses options"| node_cli
node_entry -->|"starts runtime"| node_runtime
node_runtime -->|"converts editor args"| node_cli
node_runtime -->|"creates server"| node_httpserver
node_runtime -->|"registers routes"| node_routes
node_httpserver -->|"handles upgrades"| node_wsrouter
node_httpserver -->|"creates session server"| node_session
node_routes -->|"registers login"| node_auth
node_routes -->|"registers editor routes"| node_vscode
node_routes -->|"mounts proxy routes"| node_domainproxy
node_routes -->|"dispatches port paths"| node_pathproxy
node_routes -->|"mounts update endpoint"| node_updater
node_routes -->|"creates settings provider"| node_settings
node_routes -->|"creates monitor"| node_heartbeat
node_routes -->|"registers health endpoint"| node_health
node_vscode -->|"builds editor arguments"| node_cli
node_vscode -->|"declares WebSocket routes"| node_wsrouter
node_domainproxy -->|"uses proxy helpers"| node_proxy
node_pathproxy -->|"uses proxy helpers"| node_proxy
node_user -->|"connects remotely"| node_httpserver
node_user -->|"uses browser interface"| node_browser
node_httpserver -->|"serves remote VS Code"| node_remote
node_updater -->|"checks releases"| node_github

click node_cli "https://github.com/cdr/code-server/blob/main/src/node/cli.ts"
click node_entry "https://github.com/cdr/code-server/blob/main/src/node/entry.ts"
click node_runtime "https://github.com/cdr/code-server/blob/main/src/node/main.ts"
click node_httpserver "https://github.com/cdr/code-server/blob/main/src/node/app.ts"
click node_routes "https://github.com/cdr/code-server/blob/main/src/node/routes/index.ts"
click node_auth "https://github.com/cdr/code-server/blob/main/src/node/routes/login.ts"
click node_vscode "https://github.com/cdr/code-server/blob/main/src/node/routes/vscode.ts"
click node_session "https://github.com/cdr/code-server/blob/main/src/node/vscodeSocket.ts"
click node_wsrouter "https://github.com/cdr/code-server/blob/main/src/node/wsRouter.ts"
click node_domainproxy "https://github.com/cdr/code-server/blob/main/src/node/routes/domainProxy.ts"
click node_pathproxy "https://github.com/cdr/code-server/blob/main/src/node/routes/pathProxy.ts"
click node_proxy "https://github.com/cdr/code-server/blob/main/src/node/proxy.ts"
click node_browser "https://github.com/cdr/code-server/tree/main/src/browser"
click node_settings "https://github.com/cdr/code-server/blob/main/src/node/settings.ts"
click node_updater "https://github.com/cdr/code-server/blob/main/src/node/update.ts"
click node_health "https://github.com/cdr/code-server/blob/main/src/node/routes/health.ts"
click node_heartbeat "https://github.com/cdr/code-server/blob/main/src/node/heart.ts"

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_cli,node_entry,node_runtime,node_user toneBlue
class node_httpserver,node_routes,node_auth,node_domainproxy,node_pathproxy,node_proxy toneAmber
class node_vscode,node_session,node_wsrouter,node_browser,node_operator toneMint
class node_settings,node_updater,node_health,node_heartbeat toneRose
class node_github,node_remote toneIndigo
```

## Components

### Startup and Configuration

- [CLI Configuration](https://github.com/cdr/code-server/blob/main/src/node/cli.ts): `src/node/cli.ts`
- [Process Entry](https://github.com/cdr/code-server/blob/main/src/node/entry.ts): `src/node/entry.ts`
- [Runtime Startup](https://github.com/cdr/code-server/blob/main/src/node/main.ts): `src/node/main.ts`

### HTTP and Access

- [HTTP Server](https://github.com/cdr/code-server/blob/main/src/node/app.ts): `src/node/app.ts`
- [Route Registration](https://github.com/cdr/code-server/blob/main/src/node/routes/index.ts): `src/node/routes/index.ts`
- [Authentication](https://github.com/cdr/code-server/blob/main/src/node/routes/login.ts): `src/node/routes/login.ts`
- [Domain Proxy](https://github.com/cdr/code-server/blob/main/src/node/routes/domainProxy.ts): `src/node/routes/domainProxy.ts`
- [Port Path Proxy](https://github.com/cdr/code-server/blob/main/src/node/routes/pathProxy.ts): `src/node/routes/pathProxy.ts`
- [Proxy Utilities](https://github.com/cdr/code-server/blob/main/src/node/proxy.ts): `src/node/proxy.ts`

### Editor and Sessions

- [VS Code Web Server](https://github.com/cdr/code-server/blob/main/src/node/routes/vscode.ts): `src/node/routes/vscode.ts`
- [Editor Session Manager](https://github.com/cdr/code-server/blob/main/src/node/vscodeSocket.ts): `src/node/vscodeSocket.ts`
- [WebSocket Routing](https://github.com/cdr/code-server/blob/main/src/node/wsRouter.ts): `src/node/wsRouter.ts`
- [Browser Resources](https://github.com/cdr/code-server/tree/main/src/browser): `src/browser`

### Runtime Services

- [Persistent Settings](https://github.com/cdr/code-server/blob/main/src/node/settings.ts): `src/node/settings.ts`
- [Release Update Check](https://github.com/cdr/code-server/blob/main/src/node/update.ts): `src/node/update.ts`
- [Health Endpoint](https://github.com/cdr/code-server/blob/main/src/node/routes/health.ts): `src/node/routes/health.ts`
- [Heartbeat Monitor](https://github.com/cdr/code-server/blob/main/src/node/heart.ts): `src/node/heart.ts`

### Other components

- **Browser User**
- **Server Operator**
- **GitHub Releases**
- **Remote Machine**

## Connections

- Server Operator → Process Entry: starts process
- Process Entry → CLI Configuration: parses options (evidence: `src/node/entry.ts`)
- Process Entry → Runtime Startup: starts runtime (evidence: `src/node/entry.ts`)
- Runtime Startup → CLI Configuration: converts editor args (evidence: `src/node/main.ts`)
- Runtime Startup → HTTP Server: creates server (evidence: `src/node/main.ts`)
- Runtime Startup → Route Registration: registers routes (evidence: `src/node/main.ts`)
- HTTP Server → WebSocket Routing: handles upgrades (evidence: `src/node/app.ts`)
- HTTP Server → Editor Session Manager: creates session server (evidence: `src/node/app.ts`)
- Route Registration → Authentication: registers login (evidence: `src/node/routes/index.ts`)
- Route Registration → VS Code Web Server: registers editor routes (evidence: `src/node/routes/index.ts`)
- Route Registration → Domain Proxy: mounts proxy routes (evidence: `src/node/routes/index.ts`)
- Route Registration → Port Path Proxy: dispatches port paths (evidence: `src/node/routes/index.ts`)
- Route Registration → Release Update Check: mounts update endpoint (evidence: `src/node/routes/index.ts`)
- Route Registration → Persistent Settings: creates settings provider (evidence: `src/node/routes/index.ts`)
- Route Registration → Heartbeat Monitor: creates monitor (evidence: `src/node/routes/index.ts`)
- Route Registration → Health Endpoint: registers health endpoint (evidence: `src/node/routes/index.ts`)
- VS Code Web Server → CLI Configuration: builds editor arguments (evidence: `src/node/routes/vscode.ts`)
- VS Code Web Server → WebSocket Routing: declares WebSocket routes (evidence: `src/node/routes/vscode.ts`)
- Domain Proxy → Proxy Utilities: uses proxy helpers (evidence: `src/node/routes/domainProxy.ts`)
- Port Path Proxy → Proxy Utilities: uses proxy helpers (evidence: `src/node/routes/pathProxy.ts`)
- Browser User → HTTP Server: connects remotely
- Browser User → Browser Resources: uses browser interface
- HTTP Server → Remote Machine: serves remote VS Code
- Release Update Check → GitHub Releases: checks releases
