# 7sarus/calibre-lib architecture

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

- Interactive diagram: https://gitdiagram.com/7sarus/calibre-lib
- Repository: https://github.com/7sarus/calibre-lib

## Overview

Calibre LibGen Downloader is a Calibre UI action plugin for searching LibGen mirrors, queueing and downloading books, and reviewing files before library import. The principal workflow runs from the toolbar or library context menu through search and filtering, then selected or queued downloads and import review. It also provides mirror health and configuration controls, plus optional Hardcover reading-list lookup. Edges reflect the excerpts, source-index references, and README; the dialog’s unsampled implementation limits finer-grained control-flow claims.

Main entry points: [`dialog.py`](https://github.com/7sarus/calibre-lib/blob/master/dialog.py) (Downloader dialog), [`scraper.py`](https://github.com/7sarus/calibre-lib/blob/master/scraper.py) (LibGen scraper), [`hardcover.py`](https://github.com/7sarus/calibre-lib/blob/master/hardcover.py) (Hardcover client), [`ui.py`](https://github.com/7sarus/calibre-lib/blob/master/ui.py) (Toolbar action)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Calibre interface"]
  node_action["Toolbar action<br/>[ui.py]"]
  node_dialog["Downloader dialog<br/>[dialog.py]"]
  node_progress["Progress renderer"]
end

subgraph group_search["Search and mirrors"]
  node_searchui["Search controls<br/>[dialog.py]"]
  node_scraper["LibGen scraper<br/>[scraper.py]"]
  node_mirrorui["Mirror health UI<br/>[dialog.py]"]
end

subgraph group_downloads["Downloads and import"]
  node_queue["Bulk download queue<br/>[dialog.py]"]
  node_transfer["Download transfer<br/>[scraper.py]"]
  node_review["Import review<br/>[dialog.py]"]
end

subgraph group_integrations["Settings and integrations"]
  node_config["Preferences and config<br/>[config.py]"]
  node_hardcover["Hardcover client<br/>[hardcover.py]"]
end

node_user(("Calibre user"))
node_calibre[("Calibre library")]
node_mirrors{{"LibGen mirrors"}}
node_hardcoverapi{{"Hardcover API"}}

node_user -->|"opens"| node_action
node_user -->|"starts author search"| node_action
node_action -->|"opens"| node_dialog
node_dialog -->|"shows"| node_searchui
node_searchui -->|"searches"| node_scraper
node_scraper -->|"queries"| node_mirrors
node_mirrorui -->|"tests mirrors"| node_scraper
node_scraper -->|"probes"| node_mirrors
node_dialog -->|"manages"| node_queue
node_queue -->|"starts downloads"| node_transfer
node_transfer -->|"uses"| node_scraper
node_transfer -->|"fetches files"| node_mirrors
node_dialog -->|"presents files"| node_review
node_review -->|"imports selected books"| node_calibre
node_dialog -->|"renders progress with"| node_progress
node_dialog -->|"reads preferences"| node_config
node_scraper -->|"reads mirror settings"| node_config
node_config -->|"configures mirror list"| node_mirrors
node_dialog -->|"requests reading lists"| node_hardcover
node_hardcover -->|"queries"| node_hardcoverapi
node_hardcover -->|"supports duplicate skipping"| node_calibre

click node_action "https://github.com/7sarus/calibre-lib/blob/master/ui.py"
click node_dialog "https://github.com/7sarus/calibre-lib/blob/master/dialog.py"
click node_progress "https://github.com/7sarus/calibre-lib/blob/master/progress_delegate.py"
click node_searchui "https://github.com/7sarus/calibre-lib/blob/master/dialog.py"
click node_scraper "https://github.com/7sarus/calibre-lib/blob/master/scraper.py"
click node_mirrorui "https://github.com/7sarus/calibre-lib/blob/master/dialog.py"
click node_queue "https://github.com/7sarus/calibre-lib/blob/master/dialog.py"
click node_transfer "https://github.com/7sarus/calibre-lib/blob/master/scraper.py"
click node_review "https://github.com/7sarus/calibre-lib/blob/master/dialog.py"
click node_config "https://github.com/7sarus/calibre-lib/blob/master/config.py"
click node_hardcover "https://github.com/7sarus/calibre-lib/blob/master/hardcover.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_action,node_dialog,node_progress,node_user toneBlue
class node_searchui,node_scraper,node_mirrorui,node_calibre toneAmber
class node_queue,node_transfer,node_review,node_hardcoverapi toneMint
class node_config,node_hardcover toneRose
class node_mirrors toneIndigo
```

## Components

### Calibre interface

- [Toolbar action](https://github.com/7sarus/calibre-lib/blob/master/ui.py): `ui.py`
- [Downloader dialog](https://github.com/7sarus/calibre-lib/blob/master/dialog.py): `dialog.py`
- [Progress renderer](https://github.com/7sarus/calibre-lib/blob/master/progress_delegate.py): `progress_delegate.py`

### Search and mirrors

- [Search controls](https://github.com/7sarus/calibre-lib/blob/master/dialog.py): `dialog.py`
- [LibGen scraper](https://github.com/7sarus/calibre-lib/blob/master/scraper.py): `scraper.py`
- [Mirror health UI](https://github.com/7sarus/calibre-lib/blob/master/dialog.py): `dialog.py`

### Downloads and import

- [Bulk download queue](https://github.com/7sarus/calibre-lib/blob/master/dialog.py): `dialog.py`
- [Download transfer](https://github.com/7sarus/calibre-lib/blob/master/scraper.py): `scraper.py`
- [Import review](https://github.com/7sarus/calibre-lib/blob/master/dialog.py): `dialog.py`

### Settings and integrations

- [Preferences and config](https://github.com/7sarus/calibre-lib/blob/master/config.py): `config.py`
- [Hardcover client](https://github.com/7sarus/calibre-lib/blob/master/hardcover.py): `hardcover.py`

### Other components

- **Calibre user**
- **Calibre library**
- **LibGen mirrors**
- **Hardcover API**

## Connections

- Calibre user → Toolbar action: opens (evidence: `README.md`)
- Calibre user → Toolbar action: starts author search (evidence: `README.md`)
- Toolbar action → Downloader dialog: opens (evidence: `ui.py`)
- Downloader dialog → Search controls: shows (evidence: `README.md`)
- Search controls → LibGen scraper: searches (evidence: `README.md`)
- LibGen scraper → LibGen mirrors: queries (evidence: `scraper.py`)
- Mirror health UI → LibGen scraper: tests mirrors (evidence: `README.md`)
- LibGen scraper → LibGen mirrors: probes (evidence: `README.md`)
- Downloader dialog → Bulk download queue: manages (evidence: `README.md`)
- Bulk download queue → Download transfer: starts downloads (evidence: `README.md`)
- Download transfer → LibGen scraper: uses (evidence: `scraper.py`)
- Download transfer → LibGen mirrors: fetches files (evidence: `README.md`)
- Downloader dialog → Import review: presents files (evidence: `README.md`)
- Import review → Calibre library: imports selected books (evidence: `README.md`)
- Downloader dialog → Progress renderer: renders progress with (evidence: `dialog.py`)
- Downloader dialog → Preferences and config: reads preferences (evidence: `dialog.py`)
- LibGen scraper → Preferences and config: reads mirror settings (evidence: `scraper.py`)
- Preferences and config → LibGen mirrors: configures mirror list (evidence: `README.md`)
- Downloader dialog → Hardcover client: requests reading lists (evidence: `README.md`)
- Hardcover client → Hardcover API: queries (evidence: `hardcover.py`)
- Hardcover client → Calibre library: supports duplicate skipping (evidence: `README.md`)
