# lastpass/lastpass-cli architecture

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

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

## Overview

LastPass CLI is a local command-line client for managing an encrypted LastPass vault and its shared folders. The principal workflow is to authenticate, load the session and vault, perform a requested operation, then display or synchronize the result. The tree and excerpts identify the command families, session persistence, encrypted-blob handling, HTTP endpoints, and share operations; wiring not shown in the sampled command sources is represented only where the command responsibilities or excerpts support it.

Main entry points: [`lpass.c`](https://github.com/lastpass/lastpass-cli/blob/master/lpass.c) (CLI dispatcher), [`blob.c`](https://github.com/lastpass/lastpass-cli/blob/master/blob.c) (Encrypted vault), [`cmd-login.c`](https://github.com/lastpass/lastpass-cli/blob/master/cmd-login.c) (Login/logout), [`cmd-show.c`](https://github.com/lastpass/lastpass-cli/blob/master/cmd-show.c) (Show entries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI commands"]
  node_entry["CLI dispatcher<br/>[lpass.c]"]
  node_authcmd["Login/logout<br/>[cmd-login.c]"]
  node_vaultcmd["Vault operations<br/>[cmd-add.c]"]
  node_showcmd["Show entries<br/>[cmd-show.c]"]
  node_sharecmd["Share management<br/>[cmd-share.c]"]
  node_syncmd["Sync command<br/>[cmd-sync.c]"]
  node_othercmd["Import/export<br/>[cmd-import.c]"]
end

subgraph group_identity["Identity and crypto"]
  node_session["Session state<br/>[session.c]"]
  node_config[("Local configuration<br/>[config.c]")]
  node_agent["Key agent<br/>[agent.c]"]
  node_kdf["Key derivation<br/>[kdf.c]"]
  node_cipher["Encryption<br/>[cipher.c]"]
end

subgraph group_vault["Vault and sync"]
  node_blob["Encrypted vault<br/>[blob.c]"]
  node_edit["Entry editing<br/>[edit.c]"]
  node_format["Output formats<br/>[format.c]"]
  node_clipboard["Clipboard<br/>[clipboard.c]"]
end

subgraph group_service["Service integration"]
  node_upload["Upload queue<br/>[upload-queue.c]"]
  node_endpoints["Vault endpoints<br/>[endpoints.c]"]
  node_shareendpoints["Share endpoints<br/>[endpoints-share.c]"]
  node_loginendpoints["Login endpoints<br/>[endpoints-login.c]"]
  node_http["HTTP transport<br/>[http.c]"]
  node_xml["XML parsing<br/>[xml.c]"]
end

node_user(("CLI user"))
node_lastpass{{"LastPass service"}}
node_clipboardapp(("System clipboard"))

node_user -->|"runs commands"| node_entry
node_entry -->|"dispatches"| node_authcmd
node_entry -->|"dispatches"| node_vaultcmd
node_entry -->|"dispatches"| node_showcmd
node_entry -->|"dispatches"| node_sharecmd
node_entry -->|"dispatches"| node_syncmd
node_entry -->|"dispatches"| node_othercmd
node_authcmd -->|"derives key"| node_kdf
node_authcmd -->|"authenticates"| node_loginendpoints
node_authcmd -->|"manages session"| node_session
node_session -->|"reads/writes"| node_config
node_session -->|"decrypts key"| node_cipher
node_session -->|"clears agent"| node_agent
node_vaultcmd -->|"edits entries"| node_edit
node_vaultcmd -->|"updates vault"| node_blob
node_showcmd -->|"searches entries"| node_blob
node_showcmd -->|"copies fields"| node_clipboard
node_showcmd -->|"formats output"| node_format
node_clipboard -.->|"writes"| node_clipboardapp
node_syncmd -->|"synchronizes vault"| node_blob
node_blob -->|"decrypts/encrypts"| node_cipher
node_sharecmd -->|"manages sharing"| node_shareendpoints
node_sharecmd -->|"uses vault data"| node_blob
node_shareendpoints -->|"posts requests"| node_http
node_endpoints -->|"queues updates"| node_upload
node_upload -->|"sends requests"| node_http
node_loginendpoints -->|"posts requests"| node_http
node_http -->|"exchanges data"| node_lastpass
node_shareendpoints -->|"parses replies"| node_xml
node_loginendpoints -->|"parses replies"| node_xml

click node_entry "https://github.com/lastpass/lastpass-cli/blob/master/lpass.c"
click node_authcmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-login.c"
click node_vaultcmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-add.c"
click node_showcmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-show.c"
click node_sharecmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-share.c"
click node_syncmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-sync.c"
click node_othercmd "https://github.com/lastpass/lastpass-cli/blob/master/cmd-import.c"
click node_session "https://github.com/lastpass/lastpass-cli/blob/master/session.c"
click node_config "https://github.com/lastpass/lastpass-cli/blob/master/config.c"
click node_agent "https://github.com/lastpass/lastpass-cli/blob/master/agent.c"
click node_kdf "https://github.com/lastpass/lastpass-cli/blob/master/kdf.c"
click node_cipher "https://github.com/lastpass/lastpass-cli/blob/master/cipher.c"
click node_blob "https://github.com/lastpass/lastpass-cli/blob/master/blob.c"
click node_edit "https://github.com/lastpass/lastpass-cli/blob/master/edit.c"
click node_format "https://github.com/lastpass/lastpass-cli/blob/master/format.c"
click node_clipboard "https://github.com/lastpass/lastpass-cli/blob/master/clipboard.c"
click node_upload "https://github.com/lastpass/lastpass-cli/blob/master/upload-queue.c"
click node_endpoints "https://github.com/lastpass/lastpass-cli/blob/master/endpoints.c"
click node_shareendpoints "https://github.com/lastpass/lastpass-cli/blob/master/endpoints-share.c"
click node_loginendpoints "https://github.com/lastpass/lastpass-cli/blob/master/endpoints-login.c"
click node_http "https://github.com/lastpass/lastpass-cli/blob/master/http.c"
click node_xml "https://github.com/lastpass/lastpass-cli/blob/master/xml.c"

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_entry,node_authcmd,node_vaultcmd,node_showcmd,node_sharecmd,node_syncmd,node_othercmd,node_user toneBlue
class node_session,node_config,node_agent,node_kdf,node_cipher toneAmber
class node_blob,node_edit,node_format,node_clipboard toneMint
class node_upload,node_endpoints,node_shareendpoints,node_loginendpoints,node_http,node_xml toneRose
class node_lastpass,node_clipboardapp toneIndigo
```

## Components

### CLI commands

- [CLI dispatcher](https://github.com/lastpass/lastpass-cli/blob/master/lpass.c): `lpass.c`
- [Login/logout](https://github.com/lastpass/lastpass-cli/blob/master/cmd-login.c): `cmd-login.c`
- [Vault operations](https://github.com/lastpass/lastpass-cli/blob/master/cmd-add.c): `cmd-add.c`
- [Show entries](https://github.com/lastpass/lastpass-cli/blob/master/cmd-show.c): `cmd-show.c`
- [Share management](https://github.com/lastpass/lastpass-cli/blob/master/cmd-share.c): `cmd-share.c`
- [Sync command](https://github.com/lastpass/lastpass-cli/blob/master/cmd-sync.c): `cmd-sync.c`
- [Import/export](https://github.com/lastpass/lastpass-cli/blob/master/cmd-import.c): `cmd-import.c`

### Identity and crypto

- [Session state](https://github.com/lastpass/lastpass-cli/blob/master/session.c): `session.c`
- [Local configuration](https://github.com/lastpass/lastpass-cli/blob/master/config.c): `config.c`
- [Key agent](https://github.com/lastpass/lastpass-cli/blob/master/agent.c): `agent.c`
- [Key derivation](https://github.com/lastpass/lastpass-cli/blob/master/kdf.c): `kdf.c`
- [Encryption](https://github.com/lastpass/lastpass-cli/blob/master/cipher.c): `cipher.c`

### Vault and sync

- [Encrypted vault](https://github.com/lastpass/lastpass-cli/blob/master/blob.c): `blob.c`
- [Entry editing](https://github.com/lastpass/lastpass-cli/blob/master/edit.c): `edit.c`
- [Output formats](https://github.com/lastpass/lastpass-cli/blob/master/format.c): `format.c`
- [Clipboard](https://github.com/lastpass/lastpass-cli/blob/master/clipboard.c): `clipboard.c`

### Service integration

- [Upload queue](https://github.com/lastpass/lastpass-cli/blob/master/upload-queue.c): `upload-queue.c`
- [Vault endpoints](https://github.com/lastpass/lastpass-cli/blob/master/endpoints.c): `endpoints.c`
- [Share endpoints](https://github.com/lastpass/lastpass-cli/blob/master/endpoints-share.c): `endpoints-share.c`
- [Login endpoints](https://github.com/lastpass/lastpass-cli/blob/master/endpoints-login.c): `endpoints-login.c`
- [HTTP transport](https://github.com/lastpass/lastpass-cli/blob/master/http.c): `http.c`
- [XML parsing](https://github.com/lastpass/lastpass-cli/blob/master/xml.c): `xml.c`

### Other components

- **CLI user**
- **LastPass service**
- **System clipboard**

## Connections

- CLI user → CLI dispatcher: runs commands
- CLI dispatcher → Login/logout: dispatches
- CLI dispatcher → Vault operations: dispatches
- CLI dispatcher → Show entries: dispatches
- CLI dispatcher → Share management: dispatches
- CLI dispatcher → Sync command: dispatches
- CLI dispatcher → Import/export: dispatches
- Login/logout → Key derivation: derives key
- Login/logout → Login endpoints: authenticates
- Login/logout → Session state: manages session
- Session state → Local configuration: reads/writes
- Session state → Encryption: decrypts key
- Session state → Key agent: clears agent
- Vault operations → Entry editing: edits entries
- Vault operations → Encrypted vault: updates vault
- Show entries → Encrypted vault: searches entries
- Show entries → Clipboard: copies fields
- Show entries → Output formats: formats output
- Clipboard → System clipboard: writes
- Sync command → Encrypted vault: synchronizes vault
- Encrypted vault → Encryption: decrypts/encrypts
- Share management → Share endpoints: manages sharing
- Share management → Encrypted vault: uses vault data
- Share endpoints → HTTP transport: posts requests
- Vault endpoints → Upload queue: queues updates
- Upload queue → HTTP transport: sends requests
- Login endpoints → HTTP transport: posts requests
- HTTP transport → LastPass service: exchanges data
- Share endpoints → XML parsing: parses replies
- Login endpoints → XML parsing: parses replies
