# tunnel-labs/localdev architecture

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

- Interactive diagram: https://gitdiagram.com/tunnel-labs/localdev
- Repository: https://github.com/tunnel-labs/localdev

## Overview

localdev is a host-based local development process manager with an interactive terminal UI. The principal workflow is: a developer launches the CLI, localdev loads project configuration and prepares its proxy/domain setup, configured services run as processes, and their statuses and logs appear in the TUI. Users can also inspect logs and statuses, control services, and route local domains to development services. The README documents proxy and domain configuration; unsampled implementation details are represented only where those documented capabilities identify a subsystem.

Main entry points: [`utils/service.ts`](https://github.com/tunnel-labs/localdev/blob/main/utils/service.ts) (Service lifecycle), [`utils/start.ts`](https://github.com/tunnel-labs/localdev/blob/main/utils/start.ts) (Startup orchestration), [`utils/commands.ts`](https://github.com/tunnel-labs/localdev/blob/main/utils/commands.ts) (Interactive commands), [`utils/terminal.ts`](https://github.com/tunnel-labs/localdev/blob/main/utils/terminal.ts) (Terminal renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and configuration"]
  node_cli["CLI entry<br/>[localdev.ts]"]
  node_public_api["Package API<br/>[main.ts]"]
  node_config_loader["Config loader<br/>[config.ts]"]
  node_config_types["Config model<br/>[config.ts]"]
  node_startup_orchestrator["Startup orchestration<br/>[start.ts]"]
end

subgraph group_network["Local networking"]
  node_proxy_dns["Proxy and domains<br/>[setup.ts]"]
  node_certificates["Local certificates<br/>[mkcert.ts]"]
  node_admin_dns["DNS setup<br/>[powershell.ts]"]
end

subgraph group_runtime["Service runtime"]
  node_service_orchestrator["Service lifecycle<br/>[service.ts]"]
  node_process_runner["Process runner<br/>[process.ts]"]
  node_log_store[("Log files<br/>[process.ts]")]
end

subgraph group_interface["Terminal interface"]
  node_command_registry["Interactive commands<br/>[commands.ts]"]
  node_terminal["Terminal renderer<br/>[terminal.ts]"]
  node_log_display["Log formatting<br/>[logs.ts]"]
  node_shared_state["Shared UI state<br/>[state.ts]"]
  node_service_pane["Service statuses"]
  node_logs_pane["Logs view<br/>[logs.tsx]"]
  node_help_pane["Help view<br/>[help.tsx]"]
  node_hijack_pane["Service hijack view<br/>[hijack.tsx]"]
end

node_developer(("Developer"))
node_local_services(("Local service targets"))

node_developer -->|"launches"| node_cli
node_developer -->|"imports"| node_public_api
node_cli -->|"starts"| node_startup_orchestrator
node_public_api -->|"exports"| node_startup_orchestrator
node_startup_orchestrator -->|"loads config"| node_config_loader
node_config_loader -->|"validates"| node_config_types
node_startup_orchestrator -->|"sets up"| node_proxy_dns
node_proxy_dns -->|"creates certs"| node_certificates
node_proxy_dns -->|"configures DNS"| node_admin_dns
node_startup_orchestrator -->|"creates services"| node_service_orchestrator
node_service_orchestrator -->|"spawns"| node_process_runner
node_process_runner -->|"writes and reads"| node_log_store
node_service_orchestrator -->|"updates status"| node_shared_state
node_service_orchestrator -->|"streams logs"| node_log_store
node_startup_orchestrator -->|"starts UI"| node_terminal
node_terminal -->|"renders state"| node_shared_state
node_terminal -->|"formats logs"| node_log_display
node_terminal -->|"opens initially"| node_service_pane
node_command_registry -->|"controls services"| node_service_orchestrator
node_command_registry -->|"selects view"| node_service_pane
node_command_registry -->|"selects view"| node_logs_pane
node_command_registry -->|"selects view"| node_help_pane
node_command_registry -->|"selects view"| node_hijack_pane
node_service_pane -->|"reads statuses"| node_service_orchestrator
node_logs_pane -.->|"uses state"| node_shared_state
node_hijack_pane -.->|"uses service"| node_service_orchestrator
node_local_services -->|"receives proxied traffic"| node_proxy_dns

click node_cli "https://github.com/tunnel-labs/localdev/blob/main/bin/localdev.ts"
click node_public_api "https://github.com/tunnel-labs/localdev/blob/main/exports/main.ts"
click node_config_loader "https://github.com/tunnel-labs/localdev/blob/main/utils/config.ts"
click node_config_types "https://github.com/tunnel-labs/localdev/blob/main/types/config.ts"
click node_startup_orchestrator "https://github.com/tunnel-labs/localdev/blob/main/utils/start.ts"
click node_proxy_dns "https://github.com/tunnel-labs/localdev/blob/main/utils/setup.ts"
click node_certificates "https://github.com/tunnel-labs/localdev/blob/main/utils/mkcert.ts"
click node_admin_dns "https://github.com/tunnel-labs/localdev/blob/main/utils/powershell.ts"
click node_service_orchestrator "https://github.com/tunnel-labs/localdev/blob/main/utils/service.ts"
click node_process_runner "https://github.com/tunnel-labs/localdev/blob/main/utils/process.ts"
click node_log_store "https://github.com/tunnel-labs/localdev/blob/main/utils/process.ts"
click node_command_registry "https://github.com/tunnel-labs/localdev/blob/main/utils/commands.ts"
click node_terminal "https://github.com/tunnel-labs/localdev/blob/main/utils/terminal.ts"
click node_log_display "https://github.com/tunnel-labs/localdev/blob/main/utils/logs.ts"
click node_shared_state "https://github.com/tunnel-labs/localdev/blob/main/utils/state.ts"
click node_service_pane "https://github.com/tunnel-labs/localdev/blob/main/command-panes/service-statuses.tsx"
click node_logs_pane "https://github.com/tunnel-labs/localdev/blob/main/command-panes/logs.tsx"
click node_help_pane "https://github.com/tunnel-labs/localdev/blob/main/command-panes/help.tsx"
click node_hijack_pane "https://github.com/tunnel-labs/localdev/blob/main/command-panes/hijack.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_cli,node_public_api,node_config_loader,node_config_types,node_startup_orchestrator toneBlue
class node_proxy_dns,node_certificates,node_admin_dns toneAmber
class node_service_orchestrator,node_process_runner,node_log_store toneMint
class node_command_registry,node_terminal,node_log_display,node_shared_state,node_service_pane,node_logs_pane,node_help_pane,node_hijack_pane toneRose
class node_developer,node_local_services toneIndigo
```

## Components

### Startup and configuration

- [CLI entry](https://github.com/tunnel-labs/localdev/blob/main/bin/localdev.ts): `bin/localdev.ts`
- [Package API](https://github.com/tunnel-labs/localdev/blob/main/exports/main.ts): `exports/main.ts`
- [Config loader](https://github.com/tunnel-labs/localdev/blob/main/utils/config.ts): `utils/config.ts`
- [Config model](https://github.com/tunnel-labs/localdev/blob/main/types/config.ts): `types/config.ts`
- [Startup orchestration](https://github.com/tunnel-labs/localdev/blob/main/utils/start.ts): `utils/start.ts`

### Local networking

- [Proxy and domains](https://github.com/tunnel-labs/localdev/blob/main/utils/setup.ts): `utils/setup.ts`
- [Local certificates](https://github.com/tunnel-labs/localdev/blob/main/utils/mkcert.ts): `utils/mkcert.ts`
- [DNS setup](https://github.com/tunnel-labs/localdev/blob/main/utils/powershell.ts): `utils/powershell.ts`

### Service runtime

- [Service lifecycle](https://github.com/tunnel-labs/localdev/blob/main/utils/service.ts): `utils/service.ts`
- [Process runner](https://github.com/tunnel-labs/localdev/blob/main/utils/process.ts): `utils/process.ts`
- [Log files](https://github.com/tunnel-labs/localdev/blob/main/utils/process.ts): `utils/process.ts`

### Terminal interface

- [Interactive commands](https://github.com/tunnel-labs/localdev/blob/main/utils/commands.ts): `utils/commands.ts`
- [Terminal renderer](https://github.com/tunnel-labs/localdev/blob/main/utils/terminal.ts): `utils/terminal.ts`
- [Log formatting](https://github.com/tunnel-labs/localdev/blob/main/utils/logs.ts): `utils/logs.ts`
- [Shared UI state](https://github.com/tunnel-labs/localdev/blob/main/utils/state.ts): `utils/state.ts`
- [Service statuses](https://github.com/tunnel-labs/localdev/blob/main/command-panes/service-statuses.tsx): `command-panes/service-statuses.tsx`
- [Logs view](https://github.com/tunnel-labs/localdev/blob/main/command-panes/logs.tsx): `command-panes/logs.tsx`
- [Help view](https://github.com/tunnel-labs/localdev/blob/main/command-panes/help.tsx): `command-panes/help.tsx`
- [Service hijack view](https://github.com/tunnel-labs/localdev/blob/main/command-panes/hijack.tsx): `command-panes/hijack.tsx`

### Other components

- **Developer**
- **Local service targets**

## Connections

- Developer → CLI entry: launches (evidence: `readme.md`)
- Developer → Package API: imports (evidence: `readme.md`)
- CLI entry → Startup orchestration: starts (evidence: `bin/localdev.ts`)
- Package API → Startup orchestration: exports (evidence: `exports/main.ts`)
- Startup orchestration → Config loader: loads config (evidence: `utils/start.ts`)
- Config loader → Config model: validates (evidence: `types/config.ts`)
- Startup orchestration → Proxy and domains: sets up (evidence: `utils/start.ts`)
- Proxy and domains → Local certificates: creates certs (evidence: `utils/setup.ts`)
- Proxy and domains → DNS setup: configures DNS (evidence: `utils/setup.ts`)
- Startup orchestration → Service lifecycle: creates services (evidence: `utils/start.ts`)
- Service lifecycle → Process runner: spawns (evidence: `utils/service.ts`)
- Process runner → Log files: writes and reads (evidence: `utils/process.ts`)
- Service lifecycle → Shared UI state: updates status (evidence: `utils/service.ts`)
- Service lifecycle → Log files: streams logs (evidence: `utils/service.ts`)
- Startup orchestration → Terminal renderer: starts UI (evidence: `utils/start.ts`)
- Terminal renderer → Shared UI state: renders state (evidence: `utils/terminal.ts`)
- Terminal renderer → Log formatting: formats logs (evidence: `utils/terminal.ts`)
- Terminal renderer → Service statuses: opens initially (evidence: `utils/terminal.ts`)
- Interactive commands → Service lifecycle: controls services (evidence: `utils/commands.ts`)
- Interactive commands → Service statuses: selects view (evidence: `utils/commands.ts`)
- Interactive commands → Logs view: selects view (evidence: `utils/commands.ts`)
- Interactive commands → Help view: selects view (evidence: `utils/commands.ts`)
- Interactive commands → Service hijack view: selects view (evidence: `utils/commands.ts`)
- Service statuses → Service lifecycle: reads statuses (evidence: `command-panes/service-statuses.tsx`)
- Logs view → Shared UI state: uses state (evidence: `command-panes/logs.tsx`)
- Service hijack view → Service lifecycle: uses service (evidence: `command-panes/hijack.tsx`)
- Local service targets → Proxy and domains: receives proxied traffic (evidence: `readme.md`)
