Surge is a high-performance, keyboard-driven download manager written in Go. It is designed for power users, offering a sophisticated Terminal User Interface (TUI), a headless server mode for remote environments, and a robust concurrent download engine that maximizes bandwidth utilization through multi-connection chunking and multi-mirror support.
Surge distinguishes itself from standard browser downloaders by implementing several advanced optimization strategies:
Content-Disposition headers, query parameters, URL paths, and ZIP header sniffing to resolve the correct filename internal/utils/filename.go23-123The system is divided into a backend engine (the "Server") and various frontend interfaces. Communication between these layers occurs via an HTTP API and Server-Sent Events (SSE).
System Component Map
Sources: README.md20-38 go.mod5-20 cmd/cmd_test.go24-28 internal/tui/view_test.go133 main.go10-15
Surge can be operated in several modes depending on the environment and use case. For a detailed guide on setup and flags, see Getting Started.
| Mode | Command | Description |
|---|---|---|
| Interactive TUI | surge | Launches the full dashboard for managing and visualizing downloads README.md86 |
| Headless Server | surge server | Runs the engine as a background daemon with an enabled HTTP API README.md106 |
| Remote TUI | surge connect | Connects a local TUI instance to a remote Surge daemon README.md154 |
| CLI Automation | surge add <url> | Direct command-line interaction for scripting and batching docs/USAGE.md12 |
| System Service | surge service install | Manages Surge as a background system daemon README.md121 |
The following diagram illustrates how the major code entities interact during a typical download lifecycle, bridging the gap between UI commands and the SQLite persistence layer.
Engine Entity Interaction
Sources: README.md35 go.mod5-20 cmd/cmd_test.go24-28 docs/SETTINGS.md97
Surge utilizes a modern CI/CD pipeline to ensure cross-platform compatibility and automated asset delivery.
GoReleaser to compile binaries for Linux, Windows, and Darwin with specific ldflags for versioning README.md49internal/version that queries the GitHub Releases API to notify users of updates internal/version/version.go14-39 docs/SETTINGS.md118github.com/gofrs/flock to ensure only one instance of the engine runs at a time go.mod13XDG_RUNTIME_DIR or %TEMP%) to allow CLI tools to discover and control the running daemon cmd/cmd_test.go105-137 cmd/cmd_test.go205-232 docs/SETTINGS.md100corsMiddleware to allow browser extension integration cmd/cmd_test.go143-157For technical details on the build process and contribution guidelines, see Build System and CI/CD.
SURGE_TOKEN, SURGE_HOST), and basic usage examples.