# superjack2050/1688-cli architecture

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

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

## Overview

1688 CLI supports a buyer workflow from product or supplier discovery through inquiry, cart, checkout, order tracking, and seller follow-up. The CLI routes commands through a profile-aware dispatcher, which uses either a persistent daemon or an inline browser session; command results are rendered for human terminals or machine-readable consumers. README-documented capabilities are retained, but unsampled command internals and their specific dependencies are not inferred.

Main entry points: [`src/session/dispatch.ts`](https://github.com/superjack2050/1688-cli/blob/main/src/session/dispatch.ts) (Command dispatch), [`src/commands/search.ts`](https://github.com/superjack2050/1688-cli/blob/main/src/commands/search.ts) (Product search), [`src/commands/supplier-search.ts`](https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-search.ts) (Supplier search), [`src/session/recovery.ts`](https://github.com/superjack2050/1688-cli/blob/main/src/session/recovery.ts) (Browser recovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and output"]
  node_cli["Command interface<br/>[cli.ts]"]
  node_output["JSON and TTY output<br/>[output.ts]"]
end

subgraph group_sourcing["Sourcing"]
  node_product_search["Product search<br/>[search.ts]"]
  node_product_research["Product research<br/>[research.ts]"]
  node_image_search["Image search<br/>[image-search.ts]"]
  node_offer["Offer details<br/>[offer.ts]"]
  node_supplier_search["Supplier search<br/>[supplier-search.ts]"]
  node_supplier_research["Supplier research<br/>[supplier-search.ts]"]
  node_supplier_inspect["Supplier inspection"]
end

subgraph group_buying["Buying and orders"]
  node_cart["Cart operations<br/>[cart-list.ts]"]
  node_checkout_prepare["Checkout preview"]
  node_checkout_confirm["Place order"]
  node_order_tracking["Order tracking<br/>[order-list.ts]"]
end

subgraph group_seller["Seller conversations"]
  node_inquiry["Seller inquiry<br/>[seller-inquire.ts]"]
  node_seller_chat["Seller chat and messages<br/>[seller-chat.ts]"]
end

subgraph group_runtime["Browser runtime"]
  node_dispatch["Command dispatch<br/>[dispatch.ts]"]
  node_daemon["Profile daemon<br/>[manager.ts]"]
  node_daemon_client["Daemon socket client<br/>[client.ts]"]
  node_browser_session["Browser session<br/>[context.ts]"]
  node_recovery["Browser recovery<br/>[recovery.ts]"]
  node_profile_state["Profile state and paths<br/>[paths.ts]"]
end

node_buyer(("Buyer or agent"))

node_buyer -->|"runs commands"| node_cli
node_cli -->|"routes commands"| node_dispatch
node_dispatch -->|"checks or calls"| node_daemon_client
node_dispatch -->|"runs inline"| node_browser_session
node_daemon -->|"checks or calls"| node_daemon_client
node_daemon_client -->|"resolves socket"| node_profile_state
node_daemon -->|"manages profile files"| node_profile_state
node_product_search -->|"wraps collection"| node_recovery
node_image_search -->|"dispatches command"| node_dispatch
node_image_search -->|"uses recovery"| node_recovery
node_offer -->|"dispatches command"| node_dispatch
node_offer -->|"wraps collection"| node_recovery
node_supplier_search -->|"wraps collection"| node_recovery
node_product_research -->|"uses search"| node_product_search
node_product_research -->|"enriches offers"| node_offer
node_supplier_research -.->|"discovers suppliers"| node_supplier_search
node_supplier_research -.->|"enriches suppliers"| node_supplier_inspect
node_buyer -->|"sources products"| node_product_search
node_buyer -->|"finds suppliers"| node_supplier_search
node_buyer -->|"asks seller"| node_inquiry
node_buyer -->|"manages cart"| node_cart
node_buyer -->|"previews checkout"| node_checkout_prepare
node_buyer -->|"confirms checkout"| node_checkout_confirm
node_buyer -->|"tracks orders"| node_order_tracking
node_buyer -->|"follows up"| node_seller_chat
node_checkout_confirm -->|"uses cart items"| node_cart
node_checkout_confirm -->|"uses preview"| node_checkout_prepare
node_cli -->|"configures output"| node_output
node_product_search -.->|"emits results"| node_output
node_supplier_search -.->|"emits results"| node_output

click node_cli "https://github.com/superjack2050/1688-cli/blob/main/src/cli.ts"
click node_dispatch "https://github.com/superjack2050/1688-cli/blob/main/src/session/dispatch.ts"
click node_output "https://github.com/superjack2050/1688-cli/blob/main/src/io/output.ts"
click node_product_search "https://github.com/superjack2050/1688-cli/blob/main/src/commands/search.ts"
click node_product_research "https://github.com/superjack2050/1688-cli/blob/main/src/commands/research.ts"
click node_image_search "https://github.com/superjack2050/1688-cli/blob/main/src/commands/image-search.ts"
click node_offer "https://github.com/superjack2050/1688-cli/blob/main/src/commands/offer.ts"
click node_supplier_search "https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-search.ts"
click node_supplier_research "https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-search.ts"
click node_supplier_inspect "https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-inspect.ts"
click node_inquiry "https://github.com/superjack2050/1688-cli/blob/main/src/commands/seller-inquire.ts"
click node_cart "https://github.com/superjack2050/1688-cli/blob/main/src/commands/cart-list.ts"
click node_checkout_prepare "https://github.com/superjack2050/1688-cli/blob/main/src/commands/checkout-prepare.ts"
click node_checkout_confirm "https://github.com/superjack2050/1688-cli/blob/main/src/commands/checkout-confirm.ts"
click node_order_tracking "https://github.com/superjack2050/1688-cli/blob/main/src/commands/order-list.ts"
click node_seller_chat "https://github.com/superjack2050/1688-cli/blob/main/src/commands/seller-chat.ts"
click node_daemon "https://github.com/superjack2050/1688-cli/blob/main/src/daemon/manager.ts"
click node_daemon_client "https://github.com/superjack2050/1688-cli/blob/main/src/daemon/client.ts"
click node_browser_session "https://github.com/superjack2050/1688-cli/blob/main/src/session/context.ts"
click node_recovery "https://github.com/superjack2050/1688-cli/blob/main/src/session/recovery.ts"
click node_profile_state "https://github.com/superjack2050/1688-cli/blob/main/src/session/paths.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_cli,node_output toneBlue
class node_product_search,node_product_research,node_image_search,node_offer,node_supplier_search,node_supplier_research,node_supplier_inspect toneAmber
class node_cart,node_checkout_prepare,node_checkout_confirm,node_order_tracking toneMint
class node_inquiry,node_seller_chat toneRose
class node_dispatch,node_daemon,node_daemon_client,node_browser_session,node_recovery,node_profile_state,node_buyer toneIndigo
```

## Components

### CLI and output

- [Command interface](https://github.com/superjack2050/1688-cli/blob/main/src/cli.ts): `src/cli.ts`
- [JSON and TTY output](https://github.com/superjack2050/1688-cli/blob/main/src/io/output.ts): `src/io/output.ts`

### Sourcing

- [Product search](https://github.com/superjack2050/1688-cli/blob/main/src/commands/search.ts): `src/commands/search.ts`
- [Product research](https://github.com/superjack2050/1688-cli/blob/main/src/commands/research.ts): `src/commands/research.ts`
- [Image search](https://github.com/superjack2050/1688-cli/blob/main/src/commands/image-search.ts): `src/commands/image-search.ts`
- [Offer details](https://github.com/superjack2050/1688-cli/blob/main/src/commands/offer.ts): `src/commands/offer.ts`
- [Supplier search](https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-search.ts): `src/commands/supplier-search.ts`
- [Supplier research](https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-search.ts): `src/commands/supplier-search.ts`
- [Supplier inspection](https://github.com/superjack2050/1688-cli/blob/main/src/commands/supplier-inspect.ts): `src/commands/supplier-inspect.ts`

### Buying and orders

- [Cart operations](https://github.com/superjack2050/1688-cli/blob/main/src/commands/cart-list.ts): `src/commands/cart-list.ts`
- [Checkout preview](https://github.com/superjack2050/1688-cli/blob/main/src/commands/checkout-prepare.ts): `src/commands/checkout-prepare.ts`
- [Place order](https://github.com/superjack2050/1688-cli/blob/main/src/commands/checkout-confirm.ts): `src/commands/checkout-confirm.ts`
- [Order tracking](https://github.com/superjack2050/1688-cli/blob/main/src/commands/order-list.ts): `src/commands/order-list.ts`

### Seller conversations

- [Seller inquiry](https://github.com/superjack2050/1688-cli/blob/main/src/commands/seller-inquire.ts): `src/commands/seller-inquire.ts`
- [Seller chat and messages](https://github.com/superjack2050/1688-cli/blob/main/src/commands/seller-chat.ts): `src/commands/seller-chat.ts`

### Browser runtime

- [Command dispatch](https://github.com/superjack2050/1688-cli/blob/main/src/session/dispatch.ts): `src/session/dispatch.ts`
- [Profile daemon](https://github.com/superjack2050/1688-cli/blob/main/src/daemon/manager.ts): `src/daemon/manager.ts`
- [Daemon socket client](https://github.com/superjack2050/1688-cli/blob/main/src/daemon/client.ts): `src/daemon/client.ts`
- [Browser session](https://github.com/superjack2050/1688-cli/blob/main/src/session/context.ts): `src/session/context.ts`
- [Browser recovery](https://github.com/superjack2050/1688-cli/blob/main/src/session/recovery.ts): `src/session/recovery.ts`
- [Profile state and paths](https://github.com/superjack2050/1688-cli/blob/main/src/session/paths.ts): `src/session/paths.ts`

### Other components

- **Buyer or agent**

## Connections

- Buyer or agent → Command interface: runs commands (evidence: `README.md`)
- Command interface → Command dispatch: routes commands (evidence: `src/session/dispatch.ts`)
- Command dispatch → Daemon socket client: checks or calls (evidence: `src/session/dispatch.ts`)
- Command dispatch → Browser session: runs inline (evidence: `src/session/dispatch.ts`)
- Profile daemon → Daemon socket client: checks or calls (evidence: `src/daemon/manager.ts`)
- Daemon socket client → Profile state and paths: resolves socket (evidence: `src/daemon/client.ts`)
- Profile daemon → Profile state and paths: manages profile files (evidence: `src/daemon/manager.ts`)
- Product search → Browser recovery: wraps collection (evidence: `src/commands/search.ts`)
- Image search → Command dispatch: dispatches command (evidence: `src/commands/image-search.ts`)
- Image search → Browser recovery: uses recovery (evidence: `src/commands/image-search.ts`)
- Offer details → Command dispatch: dispatches command (evidence: `src/commands/offer.ts`)
- Offer details → Browser recovery: wraps collection (evidence: `src/commands/offer.ts`)
- Supplier search → Browser recovery: wraps collection (evidence: `src/commands/supplier-search.ts`)
- Product research → Product search: uses search (evidence: `src/commands/research.ts`)
- Product research → Offer details: enriches offers (evidence: `src/commands/research.ts`)
- Supplier research → Supplier search: discovers suppliers (evidence: `README.md`)
- Supplier research → Supplier inspection: enriches suppliers (evidence: `README.md`)
- Buyer or agent → Product search: sources products (evidence: `README.md`)
- Buyer or agent → Supplier search: finds suppliers (evidence: `README.md`)
- Buyer or agent → Seller inquiry: asks seller (evidence: `README.md`)
- Buyer or agent → Cart operations: manages cart (evidence: `README.md`)
- Buyer or agent → Checkout preview: previews checkout (evidence: `README.md`)
- Buyer or agent → Place order: confirms checkout (evidence: `README.md`)
- Buyer or agent → Order tracking: tracks orders (evidence: `README.md`)
- Buyer or agent → Seller chat and messages: follows up (evidence: `README.md`)
- Place order → Cart operations: uses cart items (evidence: `src/commands/checkout-confirm.ts`)
- Place order → Checkout preview: uses preview (evidence: `src/commands/checkout-confirm.ts`)
- Command interface → JSON and TTY output: configures output (evidence: `src/cli.ts`)
- Product search → JSON and TTY output: emits results (evidence: `src/commands/search.ts`)
- Supplier search → JSON and TTY output: emits results (evidence: `src/commands/supplier-search.ts`)
