# ranjithrajv/opencode-model-recommender architecture

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

- Interactive diagram: https://gitdiagram.com/ranjithrajv/opencode-model-recommender
- Repository: https://github.com/ranjithrajv/opencode-model-recommender

## Overview

This is an OpenCode plugin that turns the host’s model catalog and current-session model into ranked pricing recommendations, model detail reports, and sidebar picks. The graph follows those distinct user-facing stages and includes the shared pricing-metrics layer. README documents commands and sidebar capabilities whose full implementations were not sampled; those links are shown only where documented, and unsampled internals are not inferred.

Main entry points: [`index.ts`](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts) (Recommendation and details tools), [`tui.tsx`](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx) (Sidebar picks widget), [`metrics.ts`](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/metrics.ts) (Cost metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin tools"]
  node_tools["Recommendation and details tools<br/>[index.ts]"]
  node_rank["Catalog filtering and ranking<br/>[index.ts]"]
  node_reports["Recommendation and price reports<br/>[index.ts]"]
  node_commands["Slash commands<br/>[index.ts]"]
end

subgraph group_pricing["Pricing analysis"]
  node_metrics["Cost metrics<br/>[metrics.ts]"]
end

subgraph group_sidebar["Sidebar experience"]
  node_sidebar["Sidebar picks widget<br/>[tui.tsx]"]
  node_view["Provider view picker<br/>[tui.tsx]"]
  node_cache["Cached catalog picks<br/>[tui.tsx]"]
end

node_user(("OpenCode user"))
node_host["OpenCode host"]
node_catalog[("Model catalog")]
node_kit["Plugin kit"]
node_agent(("OpenCode agent"))

node_user -->|"uses plugin"| node_host
node_host -->|"loads tools"| node_tools
node_tools -->|"lists models"| node_catalog
node_tools -->|"filters and ranks"| node_rank
node_rank -->|"computes costs"| node_metrics
node_tools -->|"formats results"| node_reports
node_reports -->|"returns reports"| node_user
node_host -->|"registers commands"| node_commands
node_commands -->|"prompts agent"| node_agent
node_agent -->|"runs tool"| node_tools
node_host -->|"loads widget"| node_sidebar
node_sidebar -->|"loads cached picks"| node_cache
node_cache -->|"loads models"| node_catalog
node_sidebar -->|"filters picks"| node_view
node_view -->|"uses picker helpers"| node_kit
node_cache -->|"computes costs"| node_metrics
node_sidebar -->|"shows picks"| node_user

click node_tools "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts"
click node_rank "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts"
click node_reports "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts"
click node_commands "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts"
click node_metrics "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/metrics.ts"
click node_sidebar "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx"
click node_view "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx"
click node_cache "https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.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_tools,node_rank,node_reports,node_commands,node_user toneBlue
class node_metrics,node_catalog toneAmber
class node_sidebar,node_view,node_cache toneMint
class node_host,node_kit,node_agent toneIndigo
```

## Components

### Plugin tools

- [Recommendation and details tools](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts): `index.ts`
- [Catalog filtering and ranking](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts): `index.ts`
- [Recommendation and price reports](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts): `index.ts`
- [Slash commands](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/index.ts): `index.ts`

### Pricing analysis

- [Cost metrics](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/metrics.ts): `metrics.ts`

### Sidebar experience

- [Sidebar picks widget](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx): `tui.tsx`
- [Provider view picker](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx): `tui.tsx`
- [Cached catalog picks](https://github.com/ranjithrajv/opencode-model-recommender/blob/main/tui.tsx): `tui.tsx`

### Other components

- **OpenCode user**
- **OpenCode host**
- **Model catalog**
- **Plugin kit**
- **OpenCode agent**

## Connections

- OpenCode user → OpenCode host: uses plugin (evidence: `README.md`)
- OpenCode host → Recommendation and details tools: loads tools (evidence: `index.ts`)
- Recommendation and details tools → Model catalog: lists models (evidence: `index.ts`)
- Recommendation and details tools → Catalog filtering and ranking: filters and ranks (evidence: `index.ts`)
- Catalog filtering and ranking → Cost metrics: computes costs (evidence: `index.ts`)
- Recommendation and details tools → Recommendation and price reports: formats results (evidence: `index.ts`)
- Recommendation and price reports → OpenCode user: returns reports (evidence: `README.md`)
- OpenCode host → Slash commands: registers commands (evidence: `index.ts`)
- Slash commands → OpenCode agent: prompts agent (evidence: `index.ts`)
- OpenCode agent → Recommendation and details tools: runs tool (evidence: `README.md`)
- OpenCode host → Sidebar picks widget: loads widget (evidence: `README.md`)
- Sidebar picks widget → Cached catalog picks: loads cached picks (evidence: `tui.tsx`)
- Cached catalog picks → Model catalog: loads models (evidence: `tui.tsx`)
- Sidebar picks widget → Provider view picker: filters picks (evidence: `tui.tsx`)
- Provider view picker → Plugin kit: uses picker helpers (evidence: `tui.tsx`)
- Cached catalog picks → Cost metrics: computes costs (evidence: `tui.tsx`)
- Sidebar picks widget → OpenCode user: shows picks (evidence: `README.md`)
