# samirkoirala/speedy-cli architecture

> Architecture diagram of the GitHub repository samirkoirala/speedy-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/samirkoirala/speedy-cli
- Repository: https://github.com/samirkoirala/speedy-cli

## Overview

speedy-cli is a terminal toolkit whose commands route user requests to diagnostic or stock-data logic and display results as text or JSON. The graph follows the sampled entry point and command handlers into their internal packages, including the documented environment and fun commands whose handler implementations were not sampled. The speed-test and stock packages make the shown external HTTP requests; other unsampled wiring is omitted.

Main entry points: [`cmd/root.go`](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/root.go) (Command root), [`cmd/speed.go`](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/speed.go) (Speed command), [`internal/common/result.go`](https://github.com/samirkoirala/speedy-cli/blob/main/internal/common/result.go) (Result model), [`cmd/ports.go`](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/ports.go) (Ports command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI commands"]
  node_main["Program entry<br/>[main.go]"]
  node_root["Command root<br/>[root.go]"]
  node_speedcmd["Speed command<br/>[speed.go]"]
  node_portcmd["Ports command<br/>[ports.go]"]
  node_envcmd["Env command<br/>[env.go]"]
  node_funcmd["Fun command<br/>[fun.go]"]
  node_stockcmd["Stocks command<br/>[stocks.go]"]
end

subgraph group_diagnostics["Diagnostics"]
  node_speedtest["Speed measurements<br/>[speed.go]"]
  node_portcheck["Port inspection<br/>[ports.go]"]
  node_envcheck["Environment validation<br/>[env.go]"]
  node_animation["Terminal animation<br/>[anim.go]"]
end

subgraph group_stocks["Stock updates"]
  node_stocklogic["Stock retrieval<br/>[stocks.go]"]
end

subgraph group_shared["Shared output"]
  node_common["Result model<br/>[result.go]"]
end

node_user(("User"))
node_terminal(("Terminal"))
node_network(("Internet services"))
node_nepseapi(("NEPSE API"))
node_host(("Host processes"))
node_envfile["Env file"]

node_user -->|"starts"| node_main
node_main -->|"calls"| node_root
node_root -->|"dispatches"| node_speedcmd
node_root -->|"dispatches"| node_portcmd
node_root -->|"dispatches"| node_envcmd
node_root -->|"dispatches"| node_funcmd
node_root -->|"dispatches"| node_stockcmd
node_speedcmd -->|"runs tests"| node_speedtest
node_speedcmd -->|"starts spinner"| node_animation
node_portcmd -->|"checks ports"| node_portcheck
node_envcmd -->|"validates vars"| node_envcheck
node_funcmd -->|"uses animations"| node_animation
node_stockcmd -->|"gets movers"| node_stocklogic
node_speedtest -->|"HTTP tests"| node_network
node_stocklogic -->|"requests prices"| node_nepseapi
node_portcheck -->|"inspects listeners"| node_host
node_envcheck -->|"loads file"| node_envfile
node_speedtest -->|"builds result"| node_common
node_portcheck -->|"builds result"| node_common
node_envcheck -->|"builds result"| node_common
node_stocklogic -->|"builds result"| node_common
node_speedcmd -->|"prints output"| node_terminal
node_portcmd -->|"prints output"| node_terminal
node_envcmd -->|"prints output"| node_terminal
node_funcmd -->|"shows animation"| node_terminal
node_stockcmd -->|"prints output"| node_terminal

click node_main "https://github.com/samirkoirala/speedy-cli/blob/main/main.go"
click node_root "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/root.go"
click node_speedcmd "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/speed.go"
click node_portcmd "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/ports.go"
click node_envcmd "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/env.go"
click node_funcmd "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/fun.go"
click node_stockcmd "https://github.com/samirkoirala/speedy-cli/blob/main/cmd/stocks.go"
click node_speedtest "https://github.com/samirkoirala/speedy-cli/blob/main/internal/speedtest/speed.go"
click node_portcheck "https://github.com/samirkoirala/speedy-cli/blob/main/internal/portcheck/ports.go"
click node_envcheck "https://github.com/samirkoirala/speedy-cli/blob/main/internal/envcheck/env.go"
click node_animation "https://github.com/samirkoirala/speedy-cli/blob/main/internal/animation/anim.go"
click node_stocklogic "https://github.com/samirkoirala/speedy-cli/blob/main/internal/stocks/stocks.go"
click node_common "https://github.com/samirkoirala/speedy-cli/blob/main/internal/common/result.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_root,node_speedcmd,node_portcmd,node_envcmd,node_funcmd,node_stockcmd,node_user toneBlue
class node_speedtest,node_portcheck,node_envcheck,node_animation toneAmber
class node_stocklogic,node_nepseapi toneMint
class node_common toneRose
class node_terminal,node_network,node_host,node_envfile toneIndigo
```

## Components

### CLI commands

- [Program entry](https://github.com/samirkoirala/speedy-cli/blob/main/main.go): `main.go`
- [Command root](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/root.go): `cmd/root.go`
- [Speed command](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/speed.go): `cmd/speed.go`
- [Ports command](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/ports.go): `cmd/ports.go`
- [Env command](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/env.go): `cmd/env.go`
- [Fun command](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/fun.go): `cmd/fun.go`
- [Stocks command](https://github.com/samirkoirala/speedy-cli/blob/main/cmd/stocks.go): `cmd/stocks.go`

### Diagnostics

- [Speed measurements](https://github.com/samirkoirala/speedy-cli/blob/main/internal/speedtest/speed.go): `internal/speedtest/speed.go`
- [Port inspection](https://github.com/samirkoirala/speedy-cli/blob/main/internal/portcheck/ports.go): `internal/portcheck/ports.go`
- [Environment validation](https://github.com/samirkoirala/speedy-cli/blob/main/internal/envcheck/env.go): `internal/envcheck/env.go`
- [Terminal animation](https://github.com/samirkoirala/speedy-cli/blob/main/internal/animation/anim.go): `internal/animation/anim.go`

### Stock updates

- [Stock retrieval](https://github.com/samirkoirala/speedy-cli/blob/main/internal/stocks/stocks.go): `internal/stocks/stocks.go`

### Shared output

- [Result model](https://github.com/samirkoirala/speedy-cli/blob/main/internal/common/result.go): `internal/common/result.go`

### Other components

- **User**
- **Terminal**
- **Internet services**
- **NEPSE API**
- **Host processes**
- **Env file**

## Connections

- User → Program entry: starts
- Program entry → Command root: calls
- Command root → Speed command: dispatches
- Command root → Ports command: dispatches
- Command root → Env command: dispatches
- Command root → Fun command: dispatches
- Command root → Stocks command: dispatches
- Speed command → Speed measurements: runs tests
- Speed command → Terminal animation: starts spinner
- Ports command → Port inspection: checks ports
- Env command → Environment validation: validates vars
- Fun command → Terminal animation: uses animations
- Stocks command → Stock retrieval: gets movers
- Speed measurements → Internet services: HTTP tests
- Stock retrieval → NEPSE API: requests prices
- Port inspection → Host processes: inspects listeners
- Environment validation → Env file: loads file
- Speed measurements → Result model: builds result
- Port inspection → Result model: builds result
- Environment validation → Result model: builds result
- Stock retrieval → Result model: builds result
- Speed command → Terminal: prints output
- Ports command → Terminal: prints output
- Env command → Terminal: prints output
- Fun command → Terminal: shows animation
- Stocks command → Terminal: prints output
