# duolahypercho/codex-router architecture

> Architecture diagram of the GitHub repository duolahypercho/codex-router, 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/duolahypercho/codex-router
- Repository: https://github.com/duolahypercho/codex-router

## Overview

Codex Router is a local model-routing product: client applications send routed requests to a local router, which provides access to external model providers while keeping credentials on the user's computer. Its documented workflow also includes provider setup, client integration, and management through the Control Center; optional agent bridges and local vision support are separate capabilities. The README describes the product-level integrations, while the source index provides limited import evidence. Several runtime modules and UI pages were not sampled, so links between those components are shown only where documented or directly evidenced.

Main entry points: [`src/caller-key-client-refresh.mjs`](https://github.com/duolahypercho/codex-router/blob/main/src/caller-key-client-refresh.mjs) (Client refresh), [`src/router.mjs`](https://github.com/duolahypercho/codex-router/blob/main/src/router.mjs) (Local router), [`src/config-manager.mjs`](https://github.com/duolahypercho/codex-router/blob/main/src/config-manager.mjs) (Client configuration), [`src/agent-bridges.mjs`](https://github.com/duolahypercho/codex-router/blob/main/src/agent-bridges.mjs) (Subscription agent bridges)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routing["Routing and providers"]
  node_router["Local router<br/>[router.mjs]"]
  node_provider_selection["Provider selection"]
  node_provider_adapters["Provider adapters<br/>[providers.mjs]"]
  node_provider_services(("Model providers"))
  node_vision_bridge["Vision bridge<br/>[vision-bridge.mjs]"]
  node_vision_engines["Vision engine policy<br/>[vision-engines.mjs]"]
  node_caller_auth["Caller authentication<br/>[caller-auth.mjs]"]
end

subgraph group_client_integrations["Client integrations"]
  node_caller_refresh["Client refresh"]
  node_harness_manager["Harness publishing"]
  node_dsh_catalog["Harness catalog<br/>[dsh-catalog.mjs]"]
  node_config_manager["Client configuration<br/>[config-manager.mjs]"]
end

subgraph group_management["Setup and management"]
  node_control_center["Control Center<br/>[App.tsx]"]
  node_dashboard["Dashboard view<br/>[DashboardPage.tsx]"]
  node_control_ipc["Desktop IPC<br/>[ipc.mjs]"]
  node_command_runner["Command runner<br/>[command-runner.mjs]"]
  node_model_picker["Model picker state"]
  node_multi_agent_state["Agent state"]
  node_file_security["Private file handling<br/>[file-security.mjs]"]
  node_paths["Runtime paths<br/>[paths.mjs]"]
end

subgraph group_desktop["Desktop interfaces"]
  node_tray_app["Menu bar app"]
  node_widget["Usage widget"]
  node_widget_snapshot["Widget snapshot"]
  node_panel["Read-only panel<br/>[app.js]"]
end

subgraph group_agent_bridges["Agent bridges"]
  node_agent_bridges["Subscription agent bridges<br/>[agent-bridges.mjs]"]
  node_claude_bridge["Claude bridge"]
  node_acp_client["ACP agent client"]
end

node_client_apps(("Codex clients"))

node_client_apps -->|"send requests"| node_router
node_router -.->|"selects provider"| node_provider_selection
node_router -.->|"routes requests"| node_provider_adapters
node_provider_adapters -.->|"calls models"| node_provider_services
node_router -.->|"supports vision"| node_vision_bridge
node_vision_engines -->|"selects engines"| node_vision_bridge
node_router -.->|"authenticates callers"| node_caller_auth
node_control_center -->|"renders"| node_dashboard
node_control_ipc -->|"invokes commands"| node_command_runner
node_config_manager -->|"checks secret"| node_caller_auth
node_harness_manager -->|"validates secret"| node_caller_auth
node_harness_manager -->|"publishes catalog"| node_dsh_catalog
node_caller_refresh -->|"reads catalog"| node_dsh_catalog
node_caller_refresh -.->|"refreshes config"| node_config_manager
node_config_manager -->|"protects files"| node_file_security
node_config_manager -->|"uses paths"| node_paths
node_caller_refresh -.->|"uses paths"| node_paths
node_caller_refresh -.->|"reads picker state"| node_model_picker
node_caller_refresh -.->|"reads agent state"| node_multi_agent_state
node_widget -->|"reads snapshot"| node_widget_snapshot
node_agent_bridges -.->|"includes bridge"| node_claude_bridge
node_agent_bridges -.->|"uses client"| node_acp_client
node_client_apps -->|"requests optional turns"| node_agent_bridges

click node_router "https://github.com/duolahypercho/codex-router/blob/main/src/router.mjs"
click node_provider_selection "https://github.com/duolahypercho/codex-router/blob/main/src/provider-selection.mjs"
click node_provider_adapters "https://github.com/duolahypercho/codex-router/blob/main/src/providers.mjs"
click node_vision_bridge "https://github.com/duolahypercho/codex-router/blob/main/src/vision-bridge.mjs"
click node_vision_engines "https://github.com/duolahypercho/codex-router/blob/main/src/vision-engines.mjs"
click node_caller_auth "https://github.com/duolahypercho/codex-router/blob/main/src/caller-auth.mjs"
click node_caller_refresh "https://github.com/duolahypercho/codex-router/blob/main/src/caller-key-client-refresh.mjs"
click node_harness_manager "https://github.com/duolahypercho/codex-router/blob/main/src/routed-harness-manager.mjs"
click node_dsh_catalog "https://github.com/duolahypercho/codex-router/blob/main/src/dsh-catalog.mjs"
click node_config_manager "https://github.com/duolahypercho/codex-router/blob/main/src/config-manager.mjs"
click node_control_center "https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/src/App.tsx"
click node_dashboard "https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/src/pages/DashboardPage.tsx"
click node_control_ipc "https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/electron/ipc.mjs"
click node_command_runner "https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/electron/command-runner.mjs"
click node_model_picker "https://github.com/duolahypercho/codex-router/blob/main/src/model-picker-state.mjs"
click node_multi_agent_state "https://github.com/duolahypercho/codex-router/blob/main/src/multi-agent-state.mjs"
click node_file_security "https://github.com/duolahypercho/codex-router/blob/main/src/file-security.mjs"
click node_paths "https://github.com/duolahypercho/codex-router/blob/main/src/paths.mjs"
click node_tray_app "https://github.com/duolahypercho/codex-router/blob/main/apps/macos/ModelRouterTray/Sources/ModelRouterTrayApp.swift"
click node_widget "https://github.com/duolahypercho/codex-router/blob/main/apps/macos/RouterUsageWidget/RouterUsageWidget/RouterUsageWidget.swift"
click node_widget_snapshot "https://github.com/duolahypercho/codex-router/blob/main/apps/macos/ModelRouterTray/Sources/RouterWidgetSnapshot.swift"
click node_panel "https://github.com/duolahypercho/codex-router/blob/main/apps/panel/app.js"
click node_agent_bridges "https://github.com/duolahypercho/codex-router/blob/main/src/agent-bridges.mjs"
click node_claude_bridge "https://github.com/duolahypercho/codex-router/blob/main/src/claude-agent-bridge.mjs"
click node_acp_client "https://github.com/duolahypercho/codex-router/blob/main/src/acp-agent-client.mjs"

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_router,node_provider_selection,node_provider_adapters,node_provider_services,node_vision_bridge,node_vision_engines,node_caller_auth,node_client_apps toneBlue
class node_caller_refresh,node_harness_manager,node_dsh_catalog,node_config_manager toneAmber
class node_control_center,node_dashboard,node_control_ipc,node_command_runner,node_model_picker,node_multi_agent_state,node_file_security,node_paths toneMint
class node_tray_app,node_widget,node_widget_snapshot,node_panel toneRose
class node_agent_bridges,node_claude_bridge,node_acp_client toneIndigo
```

## Components

### Routing and providers

- [Local router](https://github.com/duolahypercho/codex-router/blob/main/src/router.mjs): `src/router.mjs`
- [Provider selection](https://github.com/duolahypercho/codex-router/blob/main/src/provider-selection.mjs): `src/provider-selection.mjs`
- [Provider adapters](https://github.com/duolahypercho/codex-router/blob/main/src/providers.mjs): `src/providers.mjs`
- **Model providers**
- [Vision bridge](https://github.com/duolahypercho/codex-router/blob/main/src/vision-bridge.mjs): `src/vision-bridge.mjs`
- [Vision engine policy](https://github.com/duolahypercho/codex-router/blob/main/src/vision-engines.mjs): `src/vision-engines.mjs`
- [Caller authentication](https://github.com/duolahypercho/codex-router/blob/main/src/caller-auth.mjs): `src/caller-auth.mjs`

### Client integrations

- [Client refresh](https://github.com/duolahypercho/codex-router/blob/main/src/caller-key-client-refresh.mjs): `src/caller-key-client-refresh.mjs`
- [Harness publishing](https://github.com/duolahypercho/codex-router/blob/main/src/routed-harness-manager.mjs): `src/routed-harness-manager.mjs`
- [Harness catalog](https://github.com/duolahypercho/codex-router/blob/main/src/dsh-catalog.mjs): `src/dsh-catalog.mjs`
- [Client configuration](https://github.com/duolahypercho/codex-router/blob/main/src/config-manager.mjs): `src/config-manager.mjs`

### Setup and management

- [Control Center](https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/src/App.tsx): `apps/control-center/src/App.tsx`
- [Dashboard view](https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/src/pages/DashboardPage.tsx): `apps/control-center/src/pages/DashboardPage.tsx`
- [Desktop IPC](https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/electron/ipc.mjs): `apps/control-center/electron/ipc.mjs`
- [Command runner](https://github.com/duolahypercho/codex-router/blob/main/apps/control-center/electron/command-runner.mjs): `apps/control-center/electron/command-runner.mjs`
- [Model picker state](https://github.com/duolahypercho/codex-router/blob/main/src/model-picker-state.mjs): `src/model-picker-state.mjs`
- [Agent state](https://github.com/duolahypercho/codex-router/blob/main/src/multi-agent-state.mjs): `src/multi-agent-state.mjs`
- [Private file handling](https://github.com/duolahypercho/codex-router/blob/main/src/file-security.mjs): `src/file-security.mjs`
- [Runtime paths](https://github.com/duolahypercho/codex-router/blob/main/src/paths.mjs): `src/paths.mjs`

### Desktop interfaces

- [Menu bar app](https://github.com/duolahypercho/codex-router/blob/main/apps/macos/ModelRouterTray/Sources/ModelRouterTrayApp.swift): `apps/macos/ModelRouterTray/Sources/ModelRouterTrayApp.swift`
- [Usage widget](https://github.com/duolahypercho/codex-router/blob/main/apps/macos/RouterUsageWidget/RouterUsageWidget/RouterUsageWidget.swift): `apps/macos/RouterUsageWidget/RouterUsageWidget/RouterUsageWidget.swift`
- [Widget snapshot](https://github.com/duolahypercho/codex-router/blob/main/apps/macos/ModelRouterTray/Sources/RouterWidgetSnapshot.swift): `apps/macos/ModelRouterTray/Sources/RouterWidgetSnapshot.swift`
- [Read-only panel](https://github.com/duolahypercho/codex-router/blob/main/apps/panel/app.js): `apps/panel/app.js`

### Agent bridges

- [Subscription agent bridges](https://github.com/duolahypercho/codex-router/blob/main/src/agent-bridges.mjs): `src/agent-bridges.mjs`
- [Claude bridge](https://github.com/duolahypercho/codex-router/blob/main/src/claude-agent-bridge.mjs): `src/claude-agent-bridge.mjs`
- [ACP agent client](https://github.com/duolahypercho/codex-router/blob/main/src/acp-agent-client.mjs): `src/acp-agent-client.mjs`

### Other components

- **Codex clients**

## Connections

- Codex clients → Local router: send requests
- Local router → Provider selection: selects provider
- Local router → Provider adapters: routes requests
- Provider adapters → Model providers: calls models
- Local router → Vision bridge: supports vision
- Vision engine policy → Vision bridge: selects engines (evidence: `src/vision-engines.mjs`)
- Local router → Caller authentication: authenticates callers
- Control Center → Dashboard view: renders (evidence: `apps/control-center/src/App.tsx`)
- Desktop IPC → Command runner: invokes commands (evidence: `apps/control-center/electron/ipc.mjs`)
- Client configuration → Caller authentication: checks secret (evidence: `src/config-manager.mjs`)
- Harness publishing → Caller authentication: validates secret (evidence: `src/routed-harness-manager.mjs`)
- Harness publishing → Harness catalog: publishes catalog (evidence: `src/routed-harness-manager.mjs`)
- Client refresh → Harness catalog: reads catalog (evidence: `src/caller-key-client-refresh.mjs`)
- Client refresh → Client configuration: refreshes config (evidence: `src/config-manager.mjs`)
- Client configuration → Private file handling: protects files (evidence: `src/config-manager.mjs`)
- Client configuration → Runtime paths: uses paths (evidence: `src/config-manager.mjs`)
- Client refresh → Runtime paths: uses paths
- Client refresh → Model picker state: reads picker state
- Client refresh → Agent state: reads agent state
- Usage widget → Widget snapshot: reads snapshot (evidence: `apps/macos/RouterUsageWidget/RouterUsageWidget/RouterUsageWidget.swift`)
- Subscription agent bridges → Claude bridge: includes bridge
- Subscription agent bridges → ACP agent client: uses client
- Codex clients → Subscription agent bridges: requests optional turns
