# axel-download-accelerator/axel architecture

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

- Interactive diagram: https://gitdiagram.com/axel-download-accelerator/axel
- Repository: https://github.com/axel-download-accelerator/axel

## Overview

#### Purpose and executable entry point
Axel is a lightweight native C command-line download accelerator. It downloads one file through multiple concurrent connections and can distribute work across alternate servers. The main program and shared state definitions are in `src/axel.c` and `src/axel.h`; the built executable is declared by `src/Makefile.am`.

#### Startup, options, and configuration
Startup parses command-line inputs, loads configuration, selects output behavior, and establishes a download job. Configuration handling and persistent user settings are centered in `src/conf.c` and `src/conf.h`. Credential lookup from `.netrc` is isolated in `src/netrc.c` and `src/netrc.h`, separating local authentication sources from protocol clients.

#### Download orchestration and segmentation
The core controller divides a remote object into byte ranges, assigns ranges to connections, tracks their progress, and handles completion/retry coordination. This orchestration belongs primarily to `src/axel.c`, with transfer connection state and lifecycle in `src/conn.c` and `src/conn.h`. Search and selection of mirrors/alternate sources is represented by `src/search.c` and `src/search.h`.

#### Protocol boundary
Protocol-specific request, response, and remote-file operations are split by scheme:
- HTTP/HTTPS: `src/http.c`, `src/http.h`
- FTP/FTPS: `src/ftp.c`, `src/ftp.h`

These modules sit above the shared connection abstraction, allowing the scheduler to work with protocol-independent transfer ranges while protocol code handles server dialogue and metadata.

#### Network and TLS transport
TCP socket establishment and I/O are encapsulated in `src/tcp.c` and `src/tcp.h`. Optional SSL/TLS wrapping is implemented in `src/ssl.c`, `src/ssl.h`, and certificate verification logic in `src/ssl_verify.c`. OpenSSL, LibreSSL, or a compatible library is an optional external dependency; `configure.ac` controls whether TLS support is compiled. Platform compatibility layers include `compat-ssl.h`, `compat-android.h`, and `compat-bsd.h`.

#### File assembly, integrity, and user-visible progress
Downloaded ranges are written and mapped into the destination through `src/stfile.c` and `src/stfile.h`, which forms the local persistence boundary needed for segmented downloads and resume-like state handling. Hash functionality is in `src/hash.c` and `src/hash.h`. Terminal/status text and localization-facing output are handled by `src/text.c`; translations live under `po/`.

#### Build and runtime model
This is a Unix-oriented, single executable C project built with GNU Autotools: `configure.ac` probes platform capabilities and dependencies, while `Makefile.am` and `src/Makefile.am` define build targets. Runtime dependencies are standard networking/POSIX facilities, with gettext for localized messages and optional SSL libraries for HTTPS/FTPS. No server, database, browser, or cloud infrastructure is present.

Main entry points: [`src/axel.c`](https://github.com/axel-download-accelerator/axel/blob/master/src/axel.c) (Axel CLI & scheduler), [`src/ssl.c`](https://github.com/axel-download-accelerator/axel/blob/master/src/ssl.c) (TLS wrapper), [`src/conn.c`](https://github.com/axel-download-accelerator/axel/blob/master/src/conn.c) (Connection lifecycle), [`src/http.c`](https://github.com/axel-download-accelerator/axel/blob/master/src/http.c) (HTTP/HTTPS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Download Core"]
  node_cli["Axel CLI &amp; scheduler<br/>C program<br/>[axel.c]"]
  node_shared["Shared download state<br/>C header<br/>[axel.h]"]
  node_config["Configuration<br/>C module<br/>[conf.c]"]
  node_netrc["Credential lookup<br/>C module<br/>[netrc.c]"]
  node_connections["Connection lifecycle<br/>C module<br/>[conn.c]"]
  node_mirrors["Mirror selection<br/>C module<br/>[search.c]"]
end

subgraph group_protocols["Protocol Clients"]
  node_http["HTTP/HTTPS client<br/>C module<br/>[http.c]"]
  node_ftp["FTP/FTPS client<br/>C module<br/>[ftp.c]"]
end

subgraph group_transport["Network Transport"]
  node_tcp["TCP sockets<br/>C module<br/>[tcp.c]"]
  node_tls["TLS wrapper<br/>C module<br/>[ssl.c]"]
  node_verify["Certificate verification<br/>C module<br/>[ssl_verify.c]"]
  node_ssl_library{{"SSL library<br/>external dependency"}}
end

subgraph group_local["Local State &amp; Output"]
  node_destination["Segmented destination file<br/>C module<br/>[stfile.c]"]
  node_hash["Integrity hashes<br/>C module<br/>[hash.c]"]
  node_text["Status &amp; localized text<br/>C module<br/>[text.c]"]
  node_translations["Translations<br/>gettext catalog"]
end

subgraph group_build["Build &amp; Dependencies"]
  node_configure["Autotools configuration<br/>Autoconf<br/>[configure.ac]"]
  node_build_target["Axel executable target<br/>Automake target<br/>[Makefile.am]"]
end

node_cli -->|"uses shared state"| node_shared
node_cli -->|"loads settings"| node_config
node_config -->|"obtains credentials"| node_netrc
node_cli -->|"selects sources"| node_mirrors
node_cli -->|"assigns byte ranges"| node_connections
node_connections -->|"HTTP&#40;S&#41; transfers"| node_http
node_connections -->|"FTP&#40;S&#41; transfers"| node_ftp
node_http -->|"network I/O"| node_tcp
node_ftp -->|"network I/O"| node_tcp
node_http -.->|"HTTPS"| node_tls
node_ftp -.->|"FTPS"| node_tls
node_tls -->|"wraps"| node_tcp
node_tls -->|"verifies certificates"| node_verify
node_tls -.->|"links when enabled"| node_ssl_library
node_connections -->|"writes completed ranges"| node_destination
node_cli -->|"checks integrity"| node_hash
node_cli -->|"reports progress"| node_text
node_text -->|"localizes messages"| node_translations
node_configure -.->|"enables optional support"| node_tls
node_configure -->|"generates build settings"| node_build_target
node_build_target -->|"builds"| node_cli

click node_cli "https://github.com/axel-download-accelerator/axel/blob/master/src/axel.c"
click node_shared "https://github.com/axel-download-accelerator/axel/blob/master/src/axel.h"
click node_config "https://github.com/axel-download-accelerator/axel/blob/master/src/conf.c"
click node_netrc "https://github.com/axel-download-accelerator/axel/blob/master/src/netrc.c"
click node_connections "https://github.com/axel-download-accelerator/axel/blob/master/src/conn.c"
click node_mirrors "https://github.com/axel-download-accelerator/axel/blob/master/src/search.c"
click node_http "https://github.com/axel-download-accelerator/axel/blob/master/src/http.c"
click node_ftp "https://github.com/axel-download-accelerator/axel/blob/master/src/ftp.c"
click node_tcp "https://github.com/axel-download-accelerator/axel/blob/master/src/tcp.c"
click node_tls "https://github.com/axel-download-accelerator/axel/blob/master/src/ssl.c"
click node_verify "https://github.com/axel-download-accelerator/axel/blob/master/src/ssl_verify.c"
click node_destination "https://github.com/axel-download-accelerator/axel/blob/master/src/stfile.c"
click node_hash "https://github.com/axel-download-accelerator/axel/blob/master/src/hash.c"
click node_text "https://github.com/axel-download-accelerator/axel/blob/master/src/text.c"
click node_configure "https://github.com/axel-download-accelerator/axel/blob/master/configure.ac"
click node_build_target "https://github.com/axel-download-accelerator/axel/blob/master/src/Makefile.am"

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_shared,node_config,node_netrc,node_connections,node_mirrors toneBlue
class node_http,node_ftp toneAmber
class node_tcp,node_tls,node_verify,node_ssl_library toneMint
class node_destination,node_hash,node_text,node_translations toneRose
class node_configure,node_build_target toneIndigo
```

## Components

### Download Core

CLI setup and segmented transfer coordination.

- [Axel CLI & scheduler](https://github.com/axel-download-accelerator/axel/blob/master/src/axel.c): C program · Parses inputs, creates jobs, and coordinates byte ranges. · `src/axel.c`
- [Shared download state](https://github.com/axel-download-accelerator/axel/blob/master/src/axel.h): C header · `src/axel.h`
- [Configuration](https://github.com/axel-download-accelerator/axel/blob/master/src/conf.c): C module · Loads persistent user settings. · `src/conf.c`
- [Credential lookup](https://github.com/axel-download-accelerator/axel/blob/master/src/netrc.c): C module · Reads local .netrc credentials. · `src/netrc.c`
- [Connection lifecycle](https://github.com/axel-download-accelerator/axel/blob/master/src/conn.c): C module · Maintains transfer connection state. · `src/conn.c`
- [Mirror selection](https://github.com/axel-download-accelerator/axel/blob/master/src/search.c): C module · Finds and selects alternate sources. · `src/search.c`

### Protocol Clients

Scheme-specific remote operations.

- [HTTP/HTTPS client](https://github.com/axel-download-accelerator/axel/blob/master/src/http.c): C module · Handles HTTP requests, metadata, and range transfers. · `src/http.c`
- [FTP/FTPS client](https://github.com/axel-download-accelerator/axel/blob/master/src/ftp.c): C module · Handles FTP remote-file operations. · `src/ftp.c`

### Network Transport

TCP and optional TLS layers.

- [TCP sockets](https://github.com/axel-download-accelerator/axel/blob/master/src/tcp.c): C module · Encapsulates socket establishment and I/O. · `src/tcp.c`
- [TLS wrapper](https://github.com/axel-download-accelerator/axel/blob/master/src/ssl.c): C module · Optional SSL/TLS transport wrapping. · `src/ssl.c`
- [Certificate verification](https://github.com/axel-download-accelerator/axel/blob/master/src/ssl_verify.c): C module · `src/ssl_verify.c`
- **SSL library**: external dependency · OpenSSL, LibreSSL, or compatible TLS implementation.

### Local State & Output

Persistence, integrity, and user-facing output.

- [Segmented destination file](https://github.com/axel-download-accelerator/axel/blob/master/src/stfile.c): C module · Writes ranges and maintains resume-like file state. · `src/stfile.c`
- [Integrity hashes](https://github.com/axel-download-accelerator/axel/blob/master/src/hash.c): C module · `src/hash.c`
- [Status & localized text](https://github.com/axel-download-accelerator/axel/blob/master/src/text.c): C module · Produces terminal and localization-facing output. · `src/text.c`
- **Translations**: gettext catalog

### Build & Dependencies

Autotools feature selection and executable build.

- [Autotools configuration](https://github.com/axel-download-accelerator/axel/blob/master/configure.ac): Autoconf · Probes platform capabilities and optional TLS support. · `configure.ac`
- [Axel executable target](https://github.com/axel-download-accelerator/axel/blob/master/src/Makefile.am): Automake target · Defines the built native executable. · `src/Makefile.am`

## Connections

- Axel CLI & scheduler → Shared download state: uses shared state
- Axel CLI & scheduler → Configuration: loads settings
- Configuration → Credential lookup: obtains credentials
- Axel CLI & scheduler → Mirror selection: selects sources
- Axel CLI & scheduler → Connection lifecycle: assigns byte ranges
- Connection lifecycle → HTTP/HTTPS client: HTTP(S) transfers
- Connection lifecycle → FTP/FTPS client: FTP(S) transfers
- HTTP/HTTPS client → TCP sockets: network I/O
- FTP/FTPS client → TCP sockets: network I/O
- HTTP/HTTPS client → TLS wrapper: HTTPS
- FTP/FTPS client → TLS wrapper: FTPS
- TLS wrapper → TCP sockets: wraps
- TLS wrapper → Certificate verification: verifies certificates
- TLS wrapper → SSL library: links when enabled
- Connection lifecycle → Segmented destination file: writes completed ranges
- Axel CLI & scheduler → Integrity hashes: checks integrity
- Axel CLI & scheduler → Status & localized text: reports progress
- Status & localized text → Translations: localizes messages
- Autotools configuration → TLS wrapper: enables optional support
- Autotools configuration → Axel executable target: generates build settings
- Axel executable target → Axel CLI & scheduler: builds
