# router-for-me/cliproxyapi architecture

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

- Interactive diagram: https://gitdiagram.com/router-for-me/cliproxyapi
- Repository: https://github.com/router-for-me/cliproxyapi

## Overview

CLIProxyAPI is a multi-provider proxy that exposes OpenAI-, Gemini-, and Claude-compatible APIs for CLI clients. The principal flow is a client request entering the HTTP server, being routed to a protocol handler, translated as needed, and served through provider-specific execution; authenticated provider accounts supply access to upstream models. The repository also includes account management, model discovery, plugins, and configuration capabilities. Some runtime links are documented in the README or source index but their exact call paths were not sampled, so those links are marked unverified.

Main entry points: [`internal/api/server.go`](https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/server.go) (HTTP server), [`sdk/api/handlers`](https://github.com/router-for-me/cliproxyapi/tree/main/sdk/api/handlers) (Protocol handlers), [`sdk/translator/pipeline.go`](https://github.com/router-for-me/cliproxyapi/blob/main/sdk/translator/pipeline.go) (Translation pipeline), [`internal/runtime/executor`](https://github.com/router-for-me/cliproxyapi/tree/main/internal/runtime/executor) (Provider executors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_server["HTTP server<br/>[server.go]"]
  node_routes["API routes<br/>[server_routes.go]"]
  node_handlers["Protocol handlers"]
end

subgraph group_runtime["Model runtime"]
  node_translation["Protocol translation"]
  node_pipeline["Translation pipeline<br/>[pipeline.go]"]
  node_executors["Provider executors"]
  node_registry[("Model registry")]
end

subgraph group_accounts["Accounts and config"]
  node_authmanager["Authentication manager<br/>[manager.go]"]
  node_authproviders["Provider authentication"]
  node_watcher["Account watcher<br/>[clients.go]"]
  node_config["Configuration"]
end

subgraph group_extensions["Management and extensions"]
  node_management["Management API<br/>[handler.go]"]
  node_plugins["Plugin host"]
  node_pluginstore["Plugin store"]
  node_home["Home service<br/>[client.go]"]
end

node_client(("API client"))
node_upstream(("AI providers"))

node_client -->|"sends requests"| node_server
node_server -->|"registers routes"| node_routes
node_routes -->|"routes requests"| node_handlers
node_handlers -.->|"dispatches models"| node_executors
node_executors -.->|"calls providers"| node_upstream
node_handlers -.->|"translates requests"| node_pipeline
node_pipeline -->|"applies mappings"| node_translation
node_pipeline -->|"uses translations"| node_registry
node_executors -.->|"uses model catalog"| node_registry
node_authmanager -->|"registers authenticators"| node_authproviders
node_server -.->|"configures authentication"| node_authmanager
node_watcher -.->|"dispatches auth updates"| node_authmanager
node_server -->|"registers management API"| node_management
node_server -->|"configures plugin host"| node_plugins
node_management -->|"manages plugins"| node_pluginstore
node_server -.->|"configures server"| node_config
node_server -.->|"integrates home service"| node_home

click node_server "https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/server.go"
click node_routes "https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/server_routes.go"
click node_handlers "https://github.com/router-for-me/cliproxyapi/tree/main/sdk/api/handlers"
click node_translation "https://github.com/router-for-me/cliproxyapi/tree/main/internal/translator"
click node_pipeline "https://github.com/router-for-me/cliproxyapi/blob/main/sdk/translator/pipeline.go"
click node_executors "https://github.com/router-for-me/cliproxyapi/tree/main/internal/runtime/executor"
click node_registry "https://github.com/router-for-me/cliproxyapi/tree/main/internal/registry"
click node_authmanager "https://github.com/router-for-me/cliproxyapi/blob/main/sdk/auth/manager.go"
click node_authproviders "https://github.com/router-for-me/cliproxyapi/tree/main/internal/auth"
click node_watcher "https://github.com/router-for-me/cliproxyapi/blob/main/internal/watcher/clients.go"
click node_config "https://github.com/router-for-me/cliproxyapi/tree/main/internal/config"
click node_management "https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/handlers/management/handler.go"
click node_plugins "https://github.com/router-for-me/cliproxyapi/tree/main/internal/pluginhost"
click node_pluginstore "https://github.com/router-for-me/cliproxyapi/tree/main/internal/pluginstore"
click node_home "https://github.com/router-for-me/cliproxyapi/blob/main/internal/home/client.go"

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_server,node_routes,node_handlers,node_client toneBlue
class node_translation,node_pipeline,node_executors,node_registry toneAmber
class node_authmanager,node_authproviders,node_watcher,node_config toneMint
class node_management,node_plugins,node_pluginstore,node_home toneRose
class node_upstream toneIndigo
```

## Components

### API entry

- [HTTP server](https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/server.go): `internal/api/server.go`
- [API routes](https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/server_routes.go): `internal/api/server_routes.go`
- [Protocol handlers](https://github.com/router-for-me/cliproxyapi/tree/main/sdk/api/handlers): `sdk/api/handlers`

### Model runtime

- [Protocol translation](https://github.com/router-for-me/cliproxyapi/tree/main/internal/translator): `internal/translator`
- [Translation pipeline](https://github.com/router-for-me/cliproxyapi/blob/main/sdk/translator/pipeline.go): `sdk/translator/pipeline.go`
- [Provider executors](https://github.com/router-for-me/cliproxyapi/tree/main/internal/runtime/executor): `internal/runtime/executor`
- [Model registry](https://github.com/router-for-me/cliproxyapi/tree/main/internal/registry): `internal/registry`

### Accounts and config

- [Authentication manager](https://github.com/router-for-me/cliproxyapi/blob/main/sdk/auth/manager.go): `sdk/auth/manager.go`
- [Provider authentication](https://github.com/router-for-me/cliproxyapi/tree/main/internal/auth): `internal/auth`
- [Account watcher](https://github.com/router-for-me/cliproxyapi/blob/main/internal/watcher/clients.go): `internal/watcher/clients.go`
- [Configuration](https://github.com/router-for-me/cliproxyapi/tree/main/internal/config): `internal/config`

### Management and extensions

- [Management API](https://github.com/router-for-me/cliproxyapi/blob/main/internal/api/handlers/management/handler.go): `internal/api/handlers/management/handler.go`
- [Plugin host](https://github.com/router-for-me/cliproxyapi/tree/main/internal/pluginhost): `internal/pluginhost`
- [Plugin store](https://github.com/router-for-me/cliproxyapi/tree/main/internal/pluginstore): `internal/pluginstore`
- [Home service](https://github.com/router-for-me/cliproxyapi/blob/main/internal/home/client.go): `internal/home/client.go`

### Other components

- **API client**
- **AI providers**

## Connections

- API client → HTTP server: sends requests (evidence: `README.md`)
- HTTP server → API routes: registers routes (evidence: `internal/api/server.go`)
- API routes → Protocol handlers: routes requests (evidence: `internal/api/server_routes.go`)
- Protocol handlers → Provider executors: dispatches models
- Provider executors → AI providers: calls providers
- Protocol handlers → Translation pipeline: translates requests
- Translation pipeline → Protocol translation: applies mappings (evidence: `sdk/translator/pipeline.go`)
- Translation pipeline → Model registry: uses translations (evidence: `sdk/translator/pipeline.go`)
- Provider executors → Model registry: uses model catalog
- Authentication manager → Provider authentication: registers authenticators (evidence: `sdk/auth/manager.go`)
- HTTP server → Authentication manager: configures authentication
- Account watcher → Authentication manager: dispatches auth updates
- HTTP server → Management API: registers management API (evidence: `internal/api/server.go`)
- HTTP server → Plugin host: configures plugin host (evidence: `internal/api/server.go`)
- Management API → Plugin store: manages plugins (evidence: `internal/api/handlers/management/handler.go`)
- HTTP server → Configuration: configures server (evidence: `internal/api/server.go`)
- HTTP server → Home service: integrates home service
