# juspay/xyne-boxes architecture

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

- Interactive diagram: https://gitdiagram.com/juspay/xyne-boxes
- Repository: https://github.com/juspay/xyne-boxes

## Overview

xyne-boxes is a CLI and TypeScript client for managing remote Linux development boxes over SSH. The principal workflow is to configure the client, establish SSH authentication, send box lifecycle commands to the control host, wait for launched boxes, and prepare local SSH configuration; `connect` then starts an interactive SSH session through a proxy. README and CLI help also document listing, forking, destruction, version information, and the client library. Some command implementations are unsampled, so their links are shown only where the source index or documentation supports them.

Main entry points: [`packages/client/src/client.ts`](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/client.ts) (Client API), [`packages/client/src/auth.ts`](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/auth.ts) (SSH authentication), [`packages/cli/src/commands/connect.ts`](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/connect.ts) (Connect command), [`packages/client/src/ssh.ts`](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/ssh.ts) (Instance SSH config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI commands"]
  node_entry["CLI entry<br/>[cli.ts]"]
  node_routes["Command router<br/>[root.ts]"]
  node_connect["Connect command<br/>[connect.ts]"]
  node_lifecycle["Box commands"]
  node_clihelpers["CLI helpers<br/>[shared.ts]"]
  node_cliui["Terminal UI<br/>[ui.ts]"]
  node_verbose["Verbose flags<br/>[verbose.ts]"]
  node_buildinfo["Version details<br/>[build-info.ts]"]
end

subgraph group_client["Client operations"]
  node_client["Client API<br/>[client.ts]"]
  node_config["Configuration<br/>[config.ts]"]
  node_names["Name validation<br/>[names.ts]"]
  node_listing["List parsing<br/>[list.ts]"]
end

subgraph group_auth["Authentication"]
  node_auth["SSH authentication<br/>[auth.ts]"]
  node_recovery["CA recovery hints<br/>[recover.ts]"]
  node_tools["Step discovery<br/>[tools.ts]"]
end

subgraph group_ssh["SSH and local state"]
  node_sshconfig["Instance SSH config<br/>[ssh.ts]"]
  node_state[("Local state files")]
end

subgraph group_runtime["Process runtime"]
  node_process["Process runner<br/>[process.ts]"]
  node_errors["Client errors<br/>[errors.ts]"]
end

node_user(("Engineer"))
node_control{{"Control host"}}
node_instance{{"Remote box"}}
node_sshprocess{{"OpenSSH process"}}
node_step{{"step CA tool"}}

node_user -->|"runs commands"| node_entry
node_entry -->|"dispatches"| node_routes
node_routes -->|"routes connect"| node_connect
node_routes -->|"routes box actions"| node_lifecycle
node_routes -->|"uses helpers"| node_clihelpers
node_connect -->|"prepares SSH"| node_client
node_connect -->|"starts session"| node_sshprocess
node_connect -->|"creates client"| node_clihelpers
node_connect -->|"reports progress"| node_cliui
node_connect -->|"checks verbosity"| node_verbose
node_clihelpers -->|"constructs client"| node_client
node_clihelpers -->|"announces result"| node_cliui
node_entry -->|"processes flags"| node_verbose
node_entry -->|"reports errors"| node_cliui
node_client -->|"resolves settings"| node_config
node_client -->|"validates names"| node_names
node_client -->|"ensures authentication"| node_auth
node_client -->|"parses box list"| node_listing
node_client -->|"writes SSH config"| node_sshconfig
node_client -->|"sends box actions"| node_control
node_client -->|"removes box state"| node_state
node_auth -->|"reads settings"| node_config
node_auth -->|"resolves step"| node_tools
node_auth -->|"uses CA hints"| node_recovery
node_auth -->|"runs auth tools"| node_process
node_auth -->|"stores identity"| node_state
node_auth -->|"checks and signs"| node_step
node_sshconfig -->|"uses paths"| node_config
node_sshconfig -->|"writes SSH files"| node_state
node_sshconfig -->|"runs control SSH"| node_process
node_sshconfig -->|"sends SSH commands"| node_control
node_sshconfig -->|"proxies connection"| node_instance
node_client -->|"runs commands"| node_process
node_process -->|"spawns processes"| node_sshprocess
node_process -->|"returns failures"| node_errors
node_listing -->|"validates rows"| node_names
node_routes -->|"routes version"| node_buildinfo

click node_entry "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/cli.ts"
click node_routes "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/root.ts"
click node_connect "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/connect.ts"
click node_lifecycle "https://github.com/juspay/xyne-boxes/tree/main/packages/cli/src/commands"
click node_clihelpers "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/shared.ts"
click node_cliui "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/ui.ts"
click node_verbose "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/verbose.ts"
click node_buildinfo "https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/build-info.ts"
click node_client "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/client.ts"
click node_config "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/config.ts"
click node_names "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/names.ts"
click node_listing "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/list.ts"
click node_auth "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/auth.ts"
click node_recovery "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/recover.ts"
click node_tools "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/tools.ts"
click node_sshconfig "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/ssh.ts"
click node_process "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/process.ts"
click node_errors "https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/errors.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_entry,node_routes,node_connect,node_lifecycle,node_clihelpers,node_cliui,node_verbose,node_buildinfo toneBlue
class node_client,node_config,node_names,node_listing toneAmber
class node_auth,node_recovery,node_tools toneMint
class node_sshconfig,node_state toneRose
class node_process,node_errors,node_user,node_control,node_instance,node_sshprocess,node_step toneIndigo
```

## Components

### CLI commands

- [CLI entry](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/cli.ts): `packages/cli/src/cli.ts`
- [Command router](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/root.ts): `packages/cli/src/commands/root.ts`
- [Connect command](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/connect.ts): `packages/cli/src/commands/connect.ts`
- [Box commands](https://github.com/juspay/xyne-boxes/tree/main/packages/cli/src/commands): `packages/cli/src/commands`
- [CLI helpers](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/commands/shared.ts): `packages/cli/src/commands/shared.ts`
- [Terminal UI](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/ui.ts): `packages/cli/src/ui.ts`
- [Verbose flags](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/verbose.ts): `packages/cli/src/verbose.ts`
- [Version details](https://github.com/juspay/xyne-boxes/blob/main/packages/cli/src/build-info.ts): `packages/cli/src/build-info.ts`

### Client operations

- [Client API](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/client.ts): `packages/client/src/client.ts`
- [Configuration](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/config.ts): `packages/client/src/config.ts`
- [Name validation](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/names.ts): `packages/client/src/names.ts`
- [List parsing](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/list.ts): `packages/client/src/list.ts`

### Authentication

- [SSH authentication](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/auth.ts): `packages/client/src/auth.ts`
- [CA recovery hints](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/recover.ts): `packages/client/src/recover.ts`
- [Step discovery](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/tools.ts): `packages/client/src/tools.ts`

### SSH and local state

- [Instance SSH config](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/ssh.ts): `packages/client/src/ssh.ts`
- **Local state files**

### Process runtime

- [Process runner](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/process.ts): `packages/client/src/process.ts`
- [Client errors](https://github.com/juspay/xyne-boxes/blob/main/packages/client/src/errors.ts): `packages/client/src/errors.ts`

### Other components

- **Engineer**
- **Control host**
- **Remote box**
- **OpenSSH process**
- **step CA tool**

## Connections

- Engineer → CLI entry: runs commands (evidence: `README.md`)
- CLI entry → Command router: dispatches (evidence: `packages/cli/src/cli.ts`)
- Command router → Connect command: routes connect (evidence: `packages/cli/src/commands/root.ts`)
- Command router → Box commands: routes box actions (evidence: `packages/cli/src/commands/root.ts`)
- Command router → CLI helpers: uses helpers (evidence: `packages/cli/src/commands/root.ts`)
- Connect command → Client API: prepares SSH (evidence: `packages/cli/src/commands/connect.ts`)
- Connect command → OpenSSH process: starts session (evidence: `packages/cli/src/commands/connect.ts`)
- Connect command → CLI helpers: creates client (evidence: `packages/cli/src/commands/connect.ts`)
- Connect command → Terminal UI: reports progress (evidence: `packages/cli/src/commands/connect.ts`)
- Connect command → Verbose flags: checks verbosity (evidence: `packages/cli/src/commands/connect.ts`)
- CLI helpers → Client API: constructs client (evidence: `packages/cli/src/commands/shared.ts`)
- CLI helpers → Terminal UI: announces result (evidence: `packages/cli/src/commands/shared.ts`)
- CLI entry → Verbose flags: processes flags (evidence: `packages/cli/src/cli.ts`)
- CLI entry → Terminal UI: reports errors (evidence: `packages/cli/src/cli.ts`)
- Client API → Configuration: resolves settings (evidence: `packages/client/src/client.ts`)
- Client API → Name validation: validates names (evidence: `packages/client/src/client.ts`)
- Client API → SSH authentication: ensures authentication (evidence: `packages/client/src/client.ts`)
- Client API → List parsing: parses box list (evidence: `packages/client/src/client.ts`)
- Client API → Instance SSH config: writes SSH config (evidence: `packages/client/src/client.ts`)
- Client API → Control host: sends box actions (evidence: `packages/client/src/client.ts`)
- Client API → Local state files: removes box state (evidence: `packages/client/src/client.ts`)
- SSH authentication → Configuration: reads settings (evidence: `packages/client/src/auth.ts`)
- SSH authentication → Step discovery: resolves step (evidence: `packages/client/src/auth.ts`)
- SSH authentication → CA recovery hints: uses CA hints (evidence: `packages/client/src/auth.ts`)
- SSH authentication → Process runner: runs auth tools (evidence: `packages/client/src/auth.ts`)
- SSH authentication → Local state files: stores identity (evidence: `packages/client/src/auth.ts`)
- SSH authentication → step CA tool: checks and signs (evidence: `packages/client/src/auth.ts`)
- Instance SSH config → Configuration: uses paths (evidence: `packages/client/src/ssh.ts`)
- Instance SSH config → Local state files: writes SSH files (evidence: `packages/client/src/ssh.ts`)
- Instance SSH config → Process runner: runs control SSH (evidence: `packages/client/src/ssh.ts`)
- Instance SSH config → Control host: sends SSH commands (evidence: `packages/client/src/ssh.ts`)
- Instance SSH config → Remote box: proxies connection (evidence: `packages/client/src/ssh.ts`)
- Client API → Process runner: runs commands (evidence: `packages/client/src/client.ts`)
- Process runner → OpenSSH process: spawns processes (evidence: `packages/client/src/process.ts`)
- Process runner → Client errors: returns failures (evidence: `packages/client/src/process.ts`)
- List parsing → Name validation: validates rows (evidence: `packages/client/src/list.ts`)
- Command router → Version details: routes version (evidence: `packages/cli/src/commands/root.ts`)
