# lightconsen/kiwano architecture

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

- Interactive diagram: https://gitdiagram.com/lightconsen/kiwano
- Repository: https://github.com/lightconsen/kiwano

## Overview

Kiwano is a local-first desktop manager for AI providers and coding agents. Users configure providers and routing in the app or CLI, optionally connect agents through takeover, then send requests through a local gateway that normalizes protocols, selects providers, and records usage and logs. The graph also preserves documented capabilities for catalog sync, quota/alerts, imports, and opt-in agent intelligence. Source excerpts are partial, so edges not established by the README or shown references are omitted; unsampled subsystem paths are exact paths from the tree.

Main entry points: [`crates/gateway/src/main.rs`](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/main.rs) (Local gateway), [`app/src/screens/Providers.tsx`](https://github.com/lightconsen/kiwano/blob/main/app/src/screens/Providers.tsx) (Desktop screens), [`crates/cli/src/cli.rs`](https://github.com/lightconsen/kiwano/blob/main/crates/cli/src/cli.rs) (CLI commands), [`crates/gateway/src/forward/mod.rs`](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/forward/mod.rs) (Protocol forwarding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop and CLI"]
  node_desktop["Desktop screens<br/>[Providers.tsx]"]
  node_api["App API client<br/>[client.ts]"]
  node_tauri["Desktop backend<br/>[lib.rs]"]
  node_cli["CLI commands<br/>[cli.rs]"]
end

subgraph group_config["Provider configuration"]
  node_provider["Provider management<br/>[provider_edit.rs]"]
  node_routes["Agent routes<br/>[routes.rs]"]
  node_takeover["Agent takeover<br/>[enable.rs]"]
  node_agent_adapters["Agent adapters<br/>[mod.rs]"]
  node_catalog["Models catalog<br/>[catalog.rs]"]
end

subgraph group_runtime["Gateway runtime"]
  node_gateway["Local gateway<br/>[main.rs]"]
  node_router["Strategy selection<br/>[mod.rs]"]
  node_forward["Protocol forwarding<br/>[mod.rs]"]
  node_adapter_proxy["Protocol adapters<br/>[streaming.rs]"]
  node_store[("Local data store<br/>[mod.rs]")]
end

subgraph group_insight["Usage and intelligence"]
  node_meter["Usage metering<br/>[mod.rs]"]
  node_logs["Request logs<br/>[logs.rs]"]
  node_dashboard["Usage dashboard<br/>[dashboard.rs]"]
  node_intelligence["Agent intelligence<br/>[insights.rs]"]
  node_import["Configuration import<br/>[import.rs]"]
end

subgraph group_integrations["External integrations"]
  node_hub{{"Kiwano Hub"}}
end

node_person(("User"))
node_agent(("Coding agents"))
node_provider_service{{"AI providers"}}

node_person -->|"configures"| node_desktop
node_person -->|"runs commands"| node_cli
node_desktop -->|"requests data"| node_api
node_api -->|"selects backend"| node_tauri
node_desktop -.->|"manages providers"| node_provider
node_cli -->|"changes routes"| node_routes
node_person -->|"enables takeover"| node_takeover
node_takeover -->|"rewrites agent config"| node_agent_adapters
node_desktop -.->|"browses models"| node_catalog
node_catalog -->|"syncs catalog"| node_hub
node_agent -->|"sends requests"| node_gateway
node_gateway -.->|"dispatches request"| node_router
node_router -->|"selects candidate"| node_provider
node_gateway -->|"forwards request"| node_forward
node_forward -->|"normalizes protocol"| node_adapter_proxy
node_forward -->|"sends upstream"| node_provider_service
node_gateway -.->|"reads configuration"| node_store
node_meter -->|"records usage"| node_store
node_gateway -->|"meters requests"| node_meter
node_gateway -->|"records requests"| node_logs
node_person -->|"reviews costs"| node_dashboard
node_dashboard -.->|"reads aggregates"| node_store
node_cli -->|"imports cc-switch"| node_import
node_person -->|"opts in"| node_intelligence
node_intelligence -->|"analyzes requests"| node_logs
node_intelligence -->|"injects advice"| node_agent

click node_desktop "https://github.com/lightconsen/kiwano/blob/main/app/src/screens/Providers.tsx"
click node_api "https://github.com/lightconsen/kiwano/blob/main/app/src/api/client.ts"
click node_tauri "https://github.com/lightconsen/kiwano/blob/main/app/src-tauri/src/lib.rs"
click node_cli "https://github.com/lightconsen/kiwano/blob/main/crates/cli/src/cli.rs"
click node_provider "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/provider_edit.rs"
click node_routes "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/api/routes.rs"
click node_takeover "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/takeover/enable.rs"
click node_agent_adapters "https://github.com/lightconsen/kiwano/blob/main/crates/adapters/src/gateway_takeover/mod.rs"
click node_catalog "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/catalog.rs"
click node_gateway "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/main.rs"
click node_router "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/strategy/mod.rs"
click node_forward "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/forward/mod.rs"
click node_adapter_proxy "https://github.com/lightconsen/kiwano/blob/main/crates/adapters/src/proxy/providers/streaming.rs"
click node_store "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/store/mod.rs"
click node_meter "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/meter/mod.rs"
click node_logs "https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/store/logs.rs"
click node_dashboard "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/dashboard.rs"
click node_intelligence "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/insights.rs"
click node_import "https://github.com/lightconsen/kiwano/blob/main/crates/core/src/import.rs"

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,node_api,node_tauri,node_cli,node_person toneBlue
class node_provider,node_routes,node_takeover,node_agent_adapters,node_catalog toneAmber
class node_gateway,node_router,node_forward,node_adapter_proxy,node_store toneMint
class node_meter,node_logs,node_dashboard,node_intelligence,node_import toneRose
class node_hub,node_agent,node_provider_service toneIndigo
```

## Components

### Desktop and CLI

- [Desktop screens](https://github.com/lightconsen/kiwano/blob/main/app/src/screens/Providers.tsx): `app/src/screens/Providers.tsx`
- [App API client](https://github.com/lightconsen/kiwano/blob/main/app/src/api/client.ts): `app/src/api/client.ts`
- [Desktop backend](https://github.com/lightconsen/kiwano/blob/main/app/src-tauri/src/lib.rs): `app/src-tauri/src/lib.rs`
- [CLI commands](https://github.com/lightconsen/kiwano/blob/main/crates/cli/src/cli.rs): `crates/cli/src/cli.rs`

### Provider configuration

- [Provider management](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/provider_edit.rs): `crates/core/src/vm/provider_edit.rs`
- [Agent routes](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/api/routes.rs): `crates/gateway/src/api/routes.rs`
- [Agent takeover](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/takeover/enable.rs): `crates/core/src/takeover/enable.rs`
- [Agent adapters](https://github.com/lightconsen/kiwano/blob/main/crates/adapters/src/gateway_takeover/mod.rs): `crates/adapters/src/gateway_takeover/mod.rs`
- [Models catalog](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/catalog.rs): `crates/core/src/vm/catalog.rs`

### Gateway runtime

- [Local gateway](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/main.rs): `crates/gateway/src/main.rs`
- [Strategy selection](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/strategy/mod.rs): `crates/gateway/src/strategy/mod.rs`
- [Protocol forwarding](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/forward/mod.rs): `crates/gateway/src/forward/mod.rs`
- [Protocol adapters](https://github.com/lightconsen/kiwano/blob/main/crates/adapters/src/proxy/providers/streaming.rs): `crates/adapters/src/proxy/providers/streaming.rs`
- [Local data store](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/store/mod.rs): `crates/gateway/src/store/mod.rs`

### Usage and intelligence

- [Usage metering](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/meter/mod.rs): `crates/gateway/src/meter/mod.rs`
- [Request logs](https://github.com/lightconsen/kiwano/blob/main/crates/gateway/src/store/logs.rs): `crates/gateway/src/store/logs.rs`
- [Usage dashboard](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/vm/dashboard.rs): `crates/core/src/vm/dashboard.rs`
- [Agent intelligence](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/insights.rs): `crates/core/src/insights.rs`
- [Configuration import](https://github.com/lightconsen/kiwano/blob/main/crates/core/src/import.rs): `crates/core/src/import.rs`

### External integrations

- **Kiwano Hub**

### Other components

- **User**
- **Coding agents**
- **AI providers**

## Connections

- User → Desktop screens: configures (evidence: `README.md`)
- User → CLI commands: runs commands (evidence: `README.md`)
- Desktop screens → App API client: requests data (evidence: `app/src/App.tsx`)
- App API client → Desktop backend: selects backend (evidence: `app/src/api/client.ts`)
- Desktop screens → Provider management: manages providers
- CLI commands → Agent routes: changes routes
- User → Agent takeover: enables takeover (evidence: `README.md`)
- Agent takeover → Agent adapters: rewrites agent config (evidence: `crates/core/src/takeover/enable.rs`)
- Desktop screens → Models catalog: browses models
- Models catalog → Kiwano Hub: syncs catalog (evidence: `README.md`)
- Coding agents → Local gateway: sends requests (evidence: `README.md`)
- Local gateway → Strategy selection: dispatches request
- Strategy selection → Provider management: selects candidate (evidence: `README.md`)
- Local gateway → Protocol forwarding: forwards request (evidence: `README.md`)
- Protocol forwarding → Protocol adapters: normalizes protocol (evidence: `README.md`)
- Protocol forwarding → AI providers: sends upstream (evidence: `README.md`)
- Local gateway → Local data store: reads configuration
- Usage metering → Local data store: records usage (evidence: `README.md`)
- Local gateway → Usage metering: meters requests (evidence: `README.md`)
- Local gateway → Request logs: records requests (evidence: `README.md`)
- User → Usage dashboard: reviews costs (evidence: `README.md`)
- Usage dashboard → Local data store: reads aggregates
- CLI commands → Configuration import: imports cc-switch (evidence: `README.md`)
- User → Agent intelligence: opts in (evidence: `README.md`)
- Agent intelligence → Request logs: analyzes requests (evidence: `README.md`)
- Agent intelligence → Coding agents: injects advice (evidence: `README.md`)
