Architecture Overview
Relevant source files
The following files were used as context for generating this wiki page:
abx-dl is an all-in-one CLI tool and web server designed to auto-detect and download content from URLs using the ArchiveBox plugin ecosystem. It provides a simplified interface to the ABX Plugin Library, allowing for the execution of various scraping and downloading tools like wget, yt-dlp, and headless browsers through a unified execution pipeline.
The system is built on a decoupled architecture where a core orchestrator manages the lifecycle of a "Crawl," which consists of multiple "Snapshots" processed by various plugins. These plugins interact with the core system via a standardized hook system, emitting structured JSONL records and events that are consumed by the CLI's TUI or a REST API server.
Sources: README.md:1-15, README.md:33-40, abx_dl/models.py:1-12
Core Execution Pipeline
The execution of abx-dl follows a strictly defined phase-based lifecycle. Each phase triggers specific hooks within the enabled plugins.
- Install Phase: Reads
config.jsonfrom plugins to identifyrequired_binariesand emitsBinaryRequestEvents. - Binary Resolution:
on_BinaryRequest__*hooks from provider plugins resolve or install missing binaries. - Crawl Setup Phase:
on_CrawlSetup__*hooks launch daemons (like headless Chrome) and configure shared runtime state. - Snapshot Phase:
on_Snapshot__*hooks run per URL to extract content and emitArchiveResult,Snapshot, andTagrecords. - Cleanup Phase: Handles the shutdown of background daemons and finalizes output manifests.
The following diagram illustrates the flow from a user request to the finalized output.
Sources: README.md:40-52, TODOs.md:3-33, abx_dl/cli.py:532-555
Plugin System and Hook Mechanism
Plugins are self-contained directories containing a config.json and executable scripts following a specific naming convention. The system treats hooks as "black-box" executables, enabling language-agnostic plugin development.
Hook Naming Convention
Hooks are identified and ordered based on their filename:
on_{Event}__[{order}_]{description}[.finite][.daemon][.bg].{ext}
- Event: The lifecycle family (BinaryRequest, CrawlSetup, Snapshot).
- Order: Integer determining execution priority.
- .bg: Marks a hook as a background process.
- .daemon: A background hook that runs until explicitly killed.
- .finite: A background hook that exits on its own.
Sources: abx_dl/models.py:46-64, abx_dl/models.py:330-348
Key Data Models
| Model | Purpose |
|---|---|
Plugin | Represents a discovered plugin directory and its metadata. |
Hook | An executable script within a plugin mapped to a lifecycle event. |
Process | A single subprocess execution of a hook. |
Snapshot | Metadata for a specific URL being archived. |
ArchiveResult | The final result record emitted by a snapshot hook, including status and output file paths. |
Sources: abx_dl/models.py:99-130, abx_dl/models.py:228-285
Configuration Management
Configuration is handled through a layered approach, keeping user preferences separate from runtime-derived data.
config.env: Stores user-provided values (e.g.,TIMEOUT,USER_AGENT). Located at~/.config/abx/config.env.derived.env: A cache for runtime-derived data, such as resolved absolute paths for binaries and install timestamps (ABX_INSTALL_CACHE).MachineService: Ensures these layers remain separate during execution to prevent derived data from polluting user configuration.
Sources: README.md:57-75, CLAUDE.md:65-70
Web Architecture
The project includes a Flask-based web server that provides both a UI and a REST API for remote operation.
REST API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/download | POST | Submits a URL for processing. Accepts url, plugins, and timeout. |
/api/sessions | GET | Lists all active and recent sessions. |
/api/session/<id> | GET | Returns status, progress records (from index.jsonl), and file listings. |
/download/<id>/zip | GET | Bundles all session outputs into a single ZIP archive. |
Sources: server/server.py:317-434
Data Persistence and Output Structure
By default, abx-dl writes results to the current working directory or a specified --output directory. Each run produces a standardized structure:
index.jsonl: A manifest containingArchiveResult,Snapshot, andTagrecords.- Plugin Subdirectories: Each plugin (e.g.,
wget/,screenshot/) stores its raw output files in its own folder. - Logs: Internal logs (stdout/stderr) for each hook are stored within the session directory for debugging.
Sources: README.md:144-165, server/server.py:204-225
Conclusion
The abx-dl architecture is designed for extensibility and reliability. By leveraging a structured event bus and a strictly phased hook system, it allows developers to integrate disparate web downloading tools into a single, cohesive pipeline while maintaining clear separation between core orchestration and plugin implementation.
Sources: README.md:213-221, TODOs.md:95-102