# unknownskl/greenlight architecture

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

- Interactive diagram: https://gitdiagram.com/unknownskl/greenlight
- Repository: https://github.com/unknownskl/greenlight

## Overview

Greenlight is a cross-platform Electron client for Xbox home streaming and xCloud. The principal workflow is: a user authenticates, browses Xbox or Game Pass content, starts a home/cloud session, negotiates streaming, and controls the rendered game with gamepad or keyboard input. The legacy desktop runtime is best evidenced here; desktop-v3 and the platform/player packages provide a newer tRPC-oriented path. Some IPC and renderer wiring is inferred only from filenames and sampled call sites, so uncertain links are omitted.

Main entry points: [`packages/desktop/main/application.ts`](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/application.ts) (Electron Application), [`packages/desktop/main/ipc.ts`](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/ipc.ts) (IPC Channels), [`packages/platform/src/index.ts`](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/index.ts) (Platform Router), [`packages/desktop/main/authentication.ts`](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/authentication.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop Runtime"]
  node_desktop_app["Electron Application<br/>[application.ts]"]
  node_desktop_ui["Desktop UI<br/>[home.tsx]"]
  node_desktop_ipc["IPC Channels<br/>[ipc.ts]"]
  node_web_ui["Web UI<br/>[webui.ts]"]
end

subgraph group_identity["Identity And Data"]
  node_auth["Authentication<br/>[authentication.ts]"]
  node_token_store[("Token Store<br/>[tokenstore.ts]")]
  node_settings[("Settings Store<br/>[application.ts]")]
  node_friends_worker["Friends Worker<br/>[xboxWorker.ts]"]
  node_title_manager["Title Manager<br/>[titlemanager.ts]"]
end

subgraph group_streaming["Streaming"]
  node_stream_manager["Stream Manager<br/>[streammanager.ts]"]
  node_xcloud_api["xCloud API<br/>[xcloudapi.ts]"]
  node_player["Stream Player<br/>[player.ts]"]
  node_player_channel["Input Channels<br/>[channel.ts]"]
end

subgraph group_platform["Platform Services"]
  node_platform_router["Platform Router<br/>[index.ts]"]
  node_platform_auth["Platform Auth<br/>[auth.ts]"]
  node_platform_games["Game Pass API<br/>[gamepass.ts]"]
  node_platform_profile["Profile API<br/>[profile.ts]"]
  node_platform_streaming["Smartglass API<br/>[smartglass.ts]"]
  node_platform_worker["Cloudflare Worker<br/>[worker.ts]"]
end

node_user(("Player"))
node_xbox_services["Xbox Services"]
node_xcloud_services["xCloud Services"]
node_catalog_services["Game Pass Catalog"]

node_user -->|"uses"| node_desktop_ui
node_desktop_app -->|"opens"| node_desktop_ui
node_desktop_app -->|"starts"| node_desktop_ipc
node_desktop_app -->|"creates"| node_auth
node_desktop_app -->|"initializes"| node_web_ui
node_desktop_app -->|"reads/writes"| node_settings
node_desktop_ui -->|"invokes"| node_desktop_ipc
node_desktop_ipc -->|"dispatches"| node_auth
node_auth -->|"stores tokens"| node_token_store
node_auth -->|"authenticates"| node_xbox_services
node_desktop_app -->|"starts"| node_friends_worker
node_friends_worker -->|"loads friends"| node_xbox_services
node_desktop_ipc -->|"updates"| node_settings
node_desktop_ipc -->|"queries"| node_title_manager
node_title_manager -->|"hydrates titles"| node_catalog_services
node_desktop_ipc -->|"dispatches"| node_stream_manager
node_stream_manager -->|"starts streams"| node_xcloud_api
node_stream_manager -->|"gets tokens"| node_auth
node_xcloud_api -->|"controls session"| node_xcloud_services
node_desktop_ui -->|"renders stream"| node_player
node_player -->|"sends input"| node_player_channel
node_player_channel -->|"controls game"| node_xcloud_services
node_platform_worker -->|"serves requests"| node_platform_router
node_platform_router -.->|"routes auth"| node_platform_auth
node_platform_router -.->|"routes catalog"| node_platform_games
node_platform_router -.->|"routes profile"| node_platform_profile
node_platform_router -.->|"routes streaming"| node_platform_streaming
node_platform_auth -.->|"requests tokens"| node_xbox_services
node_platform_games -.->|"loads titles"| node_catalog_services
node_platform_profile -.->|"loads profile"| node_xbox_services
node_platform_streaming -.->|"starts streams"| node_xcloud_services

click node_desktop_app "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/application.ts"
click node_desktop_ui "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/renderer/pages/home.tsx"
click node_desktop_ipc "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/ipc.ts"
click node_web_ui "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/webui.ts"
click node_auth "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/authentication.ts"
click node_token_store "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/tokenstore.ts"
click node_settings "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/application.ts"
click node_friends_worker "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/xboxWorker.ts"
click node_title_manager "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/titlemanager.ts"
click node_stream_manager "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/streammanager.ts"
click node_xcloud_api "https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/xcloudapi.ts"
click node_player "https://github.com/unknownskl/greenlight/blob/main-v2/packages/player/src/client/lib/player.ts"
click node_player_channel "https://github.com/unknownskl/greenlight/blob/main-v2/packages/player/src/client/lib/channel/channel.ts"
click node_platform_router "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/index.ts"
click node_platform_auth "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/auth.ts"
click node_platform_games "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/gamepass.ts"
click node_platform_profile "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/profile.ts"
click node_platform_streaming "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/smartglass.ts"
click node_platform_worker "https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/worker.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_desktop_app,node_desktop_ui,node_desktop_ipc,node_web_ui toneBlue
class node_auth,node_token_store,node_settings,node_friends_worker,node_title_manager toneAmber
class node_stream_manager,node_xcloud_api,node_player,node_player_channel toneMint
class node_platform_router,node_platform_auth,node_platform_games,node_platform_profile,node_platform_streaming,node_platform_worker toneRose
class node_user,node_xbox_services,node_xcloud_services,node_catalog_services toneIndigo
```

## Components

### Desktop Runtime

- [Electron Application](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/application.ts): `packages/desktop/main/application.ts`
- [Desktop UI](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/renderer/pages/home.tsx): `packages/desktop/renderer/pages/home.tsx`
- [IPC Channels](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/ipc.ts): `packages/desktop/main/ipc.ts`
- [Web UI](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/webui.ts): `packages/desktop/main/webui.ts`

### Identity And Data

- [Authentication](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/authentication.ts): `packages/desktop/main/authentication.ts`
- [Token Store](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/tokenstore.ts): `packages/desktop/main/helpers/tokenstore.ts`
- [Settings Store](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/application.ts): `packages/desktop/main/application.ts`
- [Friends Worker](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/xboxWorker.ts): `packages/desktop/main/helpers/xboxWorker.ts`
- [Title Manager](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/titlemanager.ts): `packages/desktop/main/helpers/titlemanager.ts`

### Streaming

- [Stream Manager](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/streammanager.ts): `packages/desktop/main/helpers/streammanager.ts`
- [xCloud API](https://github.com/unknownskl/greenlight/blob/main-v2/packages/desktop/main/helpers/xcloudapi.ts): `packages/desktop/main/helpers/xcloudapi.ts`
- [Stream Player](https://github.com/unknownskl/greenlight/blob/main-v2/packages/player/src/client/lib/player.ts): `packages/player/src/client/lib/player.ts`
- [Input Channels](https://github.com/unknownskl/greenlight/blob/main-v2/packages/player/src/client/lib/channel/channel.ts): `packages/player/src/client/lib/channel/channel.ts`

### Platform Services

- [Platform Router](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/index.ts): `packages/platform/src/index.ts`
- [Platform Auth](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/auth.ts): `packages/platform/src/controller/auth.ts`
- [Game Pass API](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/gamepass.ts): `packages/platform/src/controller/gamepass.ts`
- [Profile API](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/profile.ts): `packages/platform/src/controller/profile.ts`
- [Smartglass API](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/controller/smartglass.ts): `packages/platform/src/controller/smartglass.ts`
- [Cloudflare Worker](https://github.com/unknownskl/greenlight/blob/main-v2/packages/platform/src/worker.ts): `packages/platform/src/worker.ts`

### Other components

- **Player**
- **Xbox Services**
- **xCloud Services**
- **Game Pass Catalog**

## Connections

- Player → Desktop UI: uses
- Electron Application → Desktop UI: opens
- Electron Application → IPC Channels: starts
- Electron Application → Authentication: creates
- Electron Application → Web UI: initializes
- Electron Application → Settings Store: reads/writes
- Desktop UI → IPC Channels: invokes
- IPC Channels → Authentication: dispatches
- Authentication → Token Store: stores tokens
- Authentication → Xbox Services: authenticates
- Electron Application → Friends Worker: starts
- Friends Worker → Xbox Services: loads friends
- IPC Channels → Settings Store: updates
- IPC Channels → Title Manager: queries
- Title Manager → Game Pass Catalog: hydrates titles
- IPC Channels → Stream Manager: dispatches
- Stream Manager → xCloud API: starts streams
- Stream Manager → Authentication: gets tokens
- xCloud API → xCloud Services: controls session
- Desktop UI → Stream Player: renders stream
- Stream Player → Input Channels: sends input
- Input Channels → xCloud Services: controls game
- Cloudflare Worker → Platform Router: serves requests
- Platform Router → Platform Auth: routes auth
- Platform Router → Game Pass API: routes catalog
- Platform Router → Profile API: routes profile
- Platform Router → Smartglass API: routes streaming
- Platform Auth → Xbox Services: requests tokens
- Game Pass API → Game Pass Catalog: loads titles
- Profile API → Xbox Services: loads profile
- Smartglass API → xCloud Services: starts streams
