# bariskisir/opencodemodelupdater architecture

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

- Interactive diagram: https://gitdiagram.com/bariskisir/opencodemodelupdater
- Repository: https://github.com/bariskisir/opencodemodelupdater

## Overview

OpenCode Model Updater is a CLI that fetches model listings from selected providers, preserves existing provider settings, and writes generated entries to OpenCode configuration. Its other user-facing branches list providers and remove generated entries. The sampled source shows the command orchestration, config operations, provider registry, and shared OpenAI-compatible fetch implementation; README documents 24 providers, whose individual adapter implementations were not all sampled.

Main entry points: [`src/index.ts`](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/index.ts) (Command workflow), [`src/config.ts`](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/config.ts) (Config operations), [`src/providers/index.ts`](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/index.ts) (Provider registry), [`src/providers/openai-compatible-factory.ts`](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/openai-compatible-factory.ts) (Compatible fetcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_command["Command workflow<br/>[index.ts]"]
end

subgraph group_providers["Provider integration"]
  node_registry["Provider registry<br/>[index.ts]"]
  node_adapters["24 provider adapters"]
  node_factory["Compatible fetcher"]
end

subgraph group_config["Configuration"]
  node_config_ops["Config operations<br/>[config.ts]"]
  node_types["Domain types<br/>[types.ts]"]
end

node_user(("CLI user"))
node_provider_apis{{"Provider model APIs"}}
node_config_file[("OpenCode config file")]
node_backup_file[("Timestamped backup")]
node_opencode_result["Updated OpenCode config"]

node_user -->|"runs"| node_command
node_command -->|"selects providers"| node_registry
node_command -->|"reads config"| node_config_ops
node_command -->|"backs up config"| node_config_ops
node_command -->|"merges or removes"| node_config_ops
node_command -->|"writes config"| node_config_ops
node_registry -->|"resolves handlers"| node_adapters
node_command -->|"invokes handler fetch"| node_factory
node_factory -->|"fetches models"| node_provider_apis
node_config_ops -->|"reads"| node_config_file
node_config_ops -->|"copies"| node_backup_file
node_config_ops -->|"writes"| node_config_file
node_config_ops -->|"produces config"| node_opencode_result
node_command -->|"reports result"| node_opencode_result

click node_command "https://github.com/bariskisir/opencodemodelupdater/blob/master/src/index.ts"
click node_registry "https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/index.ts"
click node_adapters "https://github.com/bariskisir/opencodemodelupdater/tree/master/src/providers"
click node_factory "https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/openai-compatible-factory.ts"
click node_config_ops "https://github.com/bariskisir/opencodemodelupdater/blob/master/src/config.ts"
click node_types "https://github.com/bariskisir/opencodemodelupdater/blob/master/src/types.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_command,node_user toneBlue
class node_registry,node_adapters,node_factory,node_config_file,node_backup_file toneAmber
class node_config_ops,node_types,node_provider_apis toneMint
class node_opencode_result toneIndigo
```

## Components

### CLI workflow

- [Command workflow](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/index.ts): `src/index.ts`

### Provider integration

- [Provider registry](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/index.ts): `src/providers/index.ts`
- [24 provider adapters](https://github.com/bariskisir/opencodemodelupdater/tree/master/src/providers): `src/providers`
- [Compatible fetcher](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/providers/openai-compatible-factory.ts): `src/providers/openai-compatible-factory.ts`

### Configuration

- [Config operations](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/config.ts): `src/config.ts`
- [Domain types](https://github.com/bariskisir/opencodemodelupdater/blob/master/src/types.ts): `src/types.ts`

### Other components

- **CLI user**
- **Provider model APIs**
- **OpenCode config file**
- **Timestamped backup**
- **Updated OpenCode config**

## Connections

- CLI user → Command workflow: runs
- Command workflow → Provider registry: selects providers
- Command workflow → Config operations: reads config
- Command workflow → Config operations: backs up config
- Command workflow → Config operations: merges or removes
- Command workflow → Config operations: writes config
- Provider registry → 24 provider adapters: resolves handlers
- Command workflow → Compatible fetcher: invokes handler fetch
- Compatible fetcher → Provider model APIs: fetches models
- Config operations → OpenCode config file: reads
- Config operations → Timestamped backup: copies
- Config operations → OpenCode config file: writes
- Config operations → Updated OpenCode config: produces config
- Command workflow → Updated OpenCode config: reports result
