# lithops-zty/hsrequest architecture

> Architecture diagram of the GitHub repository lithops-zty/hsrequest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lithops-zty/hsrequest
- Repository: https://github.com/lithops-zty/hsrequest

## Overview

This is a Python downloader library with a Tkinter progress interface. A caller supplies a URL, destination, headers, and options; the public download workflow checks response size and range support, schedules concurrent byte-range retrieval, assembles temporary pieces into the destination, and reports per-worker progress and status. The range tracker reallocates unfinished spans, supporting recovery during a running download, while the interface derives speed and timing statistics. The excerpts omit some function bodies, so links for undocumented resume behavior and UI lifecycle details are limited to the documented capabilities and visible calls.

Main entry points: [`__init__.py`](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py) (Download dispatcher), [`interface.py`](https://github.com/lithops-zty/hsrequest/blob/master/interface.py) (Tk progress UI), [`Speedometer.py`](https://github.com/lithops-zty/hsrequest/blob/master/Speedometer.py) (Speed and timing), [`utils.py`](https://github.com/lithops-zty/hsrequest/blob/master/utils.py) (Download utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Download API"]
  node_api["Download entry point<br/>[__init__.py]"]
  node_preflight["Request preflight<br/>[__init__.py]"]
end

subgraph group_engine["Download engine"]
  node_dispatcher["Download dispatcher<br/>[__init__.py]"]
  node_ranges["Range tracker<br/>[__init__.py]"]
  node_worker["Range worker<br/>[__init__.py]"]
  node_debris[("Temporary chunks<br/>[__init__.py]")]
  node_merge["Chunk assembly<br/>[__init__.py]"]
end

subgraph group_monitor["Progress interface"]
  node_interface["Tk progress UI<br/>[interface.py]"]
  node_speedometer["Speed and timing<br/>[Speedometer.py]"]
end

subgraph group_support["Runtime support"]
  node_utils["Download utilities<br/>[utils.py]"]
end

node_caller(("Application caller"))
node_http(("HTTP service"))
node_destination[("Downloaded file")]

node_caller -->|"calls"| node_api
node_api -->|"preflights"| node_preflight
node_preflight -->|"checks response"| node_http
node_preflight -->|"dispatches download"| node_dispatcher
node_preflight -->|"validates response"| node_utils
node_dispatcher -->|"initializes ranges"| node_ranges
node_dispatcher -->|"starts workers"| node_worker
node_dispatcher -->|"opens progress UI"| node_interface
node_worker -->|"claims next span"| node_ranges
node_worker -->|"requests byte ranges"| node_http
node_worker -->|"writes chunks"| node_debris
node_worker -->|"reports progress"| node_interface
node_dispatcher -->|"assembles chunks"| node_merge
node_merge -->|"reads chunks"| node_debris
node_merge -->|"writes result"| node_destination
node_interface -->|"records progress"| node_speedometer

click node_api "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_preflight "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_dispatcher "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_ranges "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_worker "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_debris "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_merge "https://github.com/lithops-zty/hsrequest/blob/master/__init__.py"
click node_interface "https://github.com/lithops-zty/hsrequest/blob/master/interface.py"
click node_speedometer "https://github.com/lithops-zty/hsrequest/blob/master/Speedometer.py"
click node_utils "https://github.com/lithops-zty/hsrequest/blob/master/utils.py"

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_api,node_preflight toneBlue
class node_dispatcher,node_ranges,node_worker,node_debris,node_merge,node_destination toneAmber
class node_interface,node_speedometer toneMint
class node_utils toneRose
class node_caller,node_http toneIndigo
```

## Components

### Download API

- [Download entry point](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`
- [Request preflight](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`

### Download engine

- [Download dispatcher](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`
- [Range tracker](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`
- [Range worker](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`
- [Temporary chunks](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`
- [Chunk assembly](https://github.com/lithops-zty/hsrequest/blob/master/__init__.py): `__init__.py`

### Progress interface

- [Tk progress UI](https://github.com/lithops-zty/hsrequest/blob/master/interface.py): `interface.py`
- [Speed and timing](https://github.com/lithops-zty/hsrequest/blob/master/Speedometer.py): `Speedometer.py`

### Runtime support

- [Download utilities](https://github.com/lithops-zty/hsrequest/blob/master/utils.py): `utils.py`

### Other components

- **Application caller**
- **HTTP service**
- **Downloaded file**

## Connections

- Application caller → Download entry point: calls
- Download entry point → Request preflight: preflights
- Request preflight → HTTP service: checks response
- Request preflight → Download dispatcher: dispatches download
- Request preflight → Download utilities: validates response
- Download dispatcher → Range tracker: initializes ranges
- Download dispatcher → Range worker: starts workers
- Download dispatcher → Tk progress UI: opens progress UI
- Range worker → Range tracker: claims next span
- Range worker → HTTP service: requests byte ranges
- Range worker → Temporary chunks: writes chunks
- Range worker → Tk progress UI: reports progress
- Download dispatcher → Chunk assembly: assembles chunks
- Chunk assembly → Temporary chunks: reads chunks
- Chunk assembly → Downloaded file: writes result
- Tk progress UI → Speed and timing: records progress
