# schlibra/op-cli architecture

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

- Interactive diagram: https://gitdiagram.com/schlibra/op-cli
- Repository: https://github.com/schlibra/op-cli

## Overview

op-cli is a Go terminal client for OpenList, offering both a Cobra command interface and an interactive menu. Users configure a server URL, authenticate, then query account information or browse files and metadata; the interactive browser can download files with progress reporting. The graph follows documented capabilities and sampled call sites. Some command and menu implementations were not sampled, so their internal wiring is shown only where the README or sampled entry points support it.

Main entry points: [`cmd/root.go`](https://github.com/schlibra/op-cli/blob/master/cmd/root.go) (Cobra commands), [`utils/request.go`](https://github.com/schlibra/op-cli/blob/master/utils/request.go) (File API calls), [`utils/config.go`](https://github.com/schlibra/op-cli/blob/master/utils/config.go) (Config operations), [`tui/home.go`](https://github.com/schlibra/op-cli/blob/master/tui/home.go) (Interactive home)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_main["Program entry<br/>[main.go]"]
  node_commands["Cobra commands<br/>[root.go]"]
  node_urlcmd["URL commands<br/>[url.go]"]
  node_usercmd["User commands<br/>[user.go]"]
  node_listcmd["List command<br/>[ls.go]"]
  node_filecmd["File command<br/>[file.go]"]
  node_downloadcmd["Download command<br/>[download.go]"]
  node_versioncmd["Version command<br/>[version.go]"]
  node_home["Interactive home<br/>[home.go]"]
  node_servermenu["Server settings<br/>[server.go]"]
  node_authmenu["Account menu<br/>[auth.go]"]
end

subgraph group_account["Configuration and account"]
  node_authflow["Authentication actions<br/>[user.go]"]
end

subgraph group_files["File operations"]
  node_browser["File browser<br/>[file.go]"]
  node_downloader["Progress downloader<br/>[download.go]"]
end

subgraph group_runtime["API and local state"]
  node_accountapi["Account API calls<br/>[request.go]"]
  node_filesapi["File API calls<br/>[request.go]"]
  node_models["API data models<br/>[file.go]"]
  node_authmodels["Auth data models<br/>[auth.go]"]
  node_config["Config operations<br/>[config.go]"]
  node_configfile[("Local config")]
end

node_user(("Terminal user"))
node_filesystem[("Downloaded files")]
node_openlist(("OpenList server"))

node_user -->|"starts"| node_main
node_main -->|"opens without arguments"| node_home
node_main -->|"dispatches arguments"| node_commands
node_user -->|"runs commands"| node_commands
node_commands -->|"registers commands"| node_urlcmd
node_commands -->|"registers commands"| node_usercmd
node_commands -->|"registers commands"| node_listcmd
node_commands -->|"registers commands"| node_filecmd
node_commands -->|"registers commands"| node_downloadcmd
node_commands -->|"registers commands"| node_versioncmd
node_home -->|"opens settings"| node_servermenu
node_home -->|"opens account menu"| node_authmenu
node_home -->|"opens browser"| node_browser
node_servermenu -->|"loads and saves URL"| node_config
node_urlcmd -->|"loads and saves URL"| node_config
node_usercmd -->|"invokes"| node_authflow
node_authmenu -->|"requests account actions"| node_accountapi
node_authflow -->|"requests account actions"| node_accountapi
node_accountapi -->|"encodes login data"| node_authmodels
node_accountapi -->|"calls account endpoints"| node_openlist
node_accountapi -->|"reads token and clears logout token"| node_config
node_config -->|"reads and writes"| node_configfile
node_listcmd -->|"lists path"| node_filesapi
node_filecmd -->|"gets metadata"| node_filesapi
node_downloadcmd -.->|"requests file data"| node_filesapi
node_browser -->|"lists and gets metadata"| node_filesapi
node_filesapi -->|"calls filesystem endpoints"| node_openlist
node_filesapi -->|"reads token and URL"| node_config
node_filesapi -->|"encodes requests and decodes results"| node_models
node_browser -->|"downloads raw URL"| node_downloader
node_downloader -->|"writes stream"| node_filesystem

click node_main "https://github.com/schlibra/op-cli/blob/master/main.go"
click node_commands "https://github.com/schlibra/op-cli/blob/master/cmd/root.go"
click node_urlcmd "https://github.com/schlibra/op-cli/blob/master/cmd/url.go"
click node_usercmd "https://github.com/schlibra/op-cli/blob/master/cmd/user.go"
click node_listcmd "https://github.com/schlibra/op-cli/blob/master/cmd/ls.go"
click node_filecmd "https://github.com/schlibra/op-cli/blob/master/cmd/file.go"
click node_downloadcmd "https://github.com/schlibra/op-cli/blob/master/cmd/download.go"
click node_versioncmd "https://github.com/schlibra/op-cli/blob/master/cmd/version.go"
click node_home "https://github.com/schlibra/op-cli/blob/master/tui/home.go"
click node_servermenu "https://github.com/schlibra/op-cli/blob/master/tui/server.go"
click node_authmenu "https://github.com/schlibra/op-cli/blob/master/tui/auth.go"
click node_browser "https://github.com/schlibra/op-cli/blob/master/tui/file.go"
click node_authflow "https://github.com/schlibra/op-cli/blob/master/cmd/user.go"
click node_accountapi "https://github.com/schlibra/op-cli/blob/master/utils/request.go"
click node_filesapi "https://github.com/schlibra/op-cli/blob/master/utils/request.go"
click node_models "https://github.com/schlibra/op-cli/blob/master/model/file.go"
click node_authmodels "https://github.com/schlibra/op-cli/blob/master/model/auth.go"
click node_config "https://github.com/schlibra/op-cli/blob/master/utils/config.go"
click node_downloader "https://github.com/schlibra/op-cli/blob/master/utils/download.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_main,node_commands,node_urlcmd,node_usercmd,node_listcmd,node_filecmd,node_downloadcmd,node_versioncmd,node_home,node_servermenu,node_authmenu,node_user toneBlue
class node_authflow,node_filesystem toneAmber
class node_browser,node_downloader,node_openlist toneMint
class node_accountapi,node_filesapi,node_models,node_authmodels,node_config,node_configfile toneRose
```

## Components

### User interfaces

- [Program entry](https://github.com/schlibra/op-cli/blob/master/main.go): `main.go`
- [Cobra commands](https://github.com/schlibra/op-cli/blob/master/cmd/root.go): `cmd/root.go`
- [URL commands](https://github.com/schlibra/op-cli/blob/master/cmd/url.go): `cmd/url.go`
- [User commands](https://github.com/schlibra/op-cli/blob/master/cmd/user.go): `cmd/user.go`
- [List command](https://github.com/schlibra/op-cli/blob/master/cmd/ls.go): `cmd/ls.go`
- [File command](https://github.com/schlibra/op-cli/blob/master/cmd/file.go): `cmd/file.go`
- [Download command](https://github.com/schlibra/op-cli/blob/master/cmd/download.go): `cmd/download.go`
- [Version command](https://github.com/schlibra/op-cli/blob/master/cmd/version.go): `cmd/version.go`
- [Interactive home](https://github.com/schlibra/op-cli/blob/master/tui/home.go): `tui/home.go`
- [Server settings](https://github.com/schlibra/op-cli/blob/master/tui/server.go): `tui/server.go`
- [Account menu](https://github.com/schlibra/op-cli/blob/master/tui/auth.go): `tui/auth.go`

### Configuration and account

- [Authentication actions](https://github.com/schlibra/op-cli/blob/master/cmd/user.go): `cmd/user.go`

### File operations

- [File browser](https://github.com/schlibra/op-cli/blob/master/tui/file.go): `tui/file.go`
- [Progress downloader](https://github.com/schlibra/op-cli/blob/master/utils/download.go): `utils/download.go`

### API and local state

- [Account API calls](https://github.com/schlibra/op-cli/blob/master/utils/request.go): `utils/request.go`
- [File API calls](https://github.com/schlibra/op-cli/blob/master/utils/request.go): `utils/request.go`
- [API data models](https://github.com/schlibra/op-cli/blob/master/model/file.go): `model/file.go`
- [Auth data models](https://github.com/schlibra/op-cli/blob/master/model/auth.go): `model/auth.go`
- [Config operations](https://github.com/schlibra/op-cli/blob/master/utils/config.go): `utils/config.go`
- **Local config**

### Other components

- **Terminal user**
- **Downloaded files**
- **OpenList server**

## Connections

- Terminal user → Program entry: starts
- Program entry → Interactive home: opens without arguments
- Program entry → Cobra commands: dispatches arguments
- Terminal user → Cobra commands: runs commands
- Cobra commands → URL commands: registers commands
- Cobra commands → User commands: registers commands
- Cobra commands → List command: registers commands
- Cobra commands → File command: registers commands
- Cobra commands → Download command: registers commands
- Cobra commands → Version command: registers commands
- Interactive home → Server settings: opens settings
- Interactive home → Account menu: opens account menu
- Interactive home → File browser: opens browser
- Server settings → Config operations: loads and saves URL
- URL commands → Config operations: loads and saves URL
- User commands → Authentication actions: invokes
- Account menu → Account API calls: requests account actions
- Authentication actions → Account API calls: requests account actions
- Account API calls → Auth data models: encodes login data
- Account API calls → OpenList server: calls account endpoints
- Account API calls → Config operations: reads token and clears logout token
- Config operations → Local config: reads and writes
- List command → File API calls: lists path
- File command → File API calls: gets metadata
- Download command → File API calls: requests file data
- File browser → File API calls: lists and gets metadata
- File API calls → OpenList server: calls filesystem endpoints
- File API calls → Config operations: reads token and URL
- File API calls → API data models: encodes requests and decodes results
- File browser → Progress downloader: downloads raw URL
- Progress downloader → Downloaded files: writes stream
