# leone25/sanoma-downloader architecture

> Architecture diagram of the GitHub repository leone25/sanoma-downloader, 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/leone25/sanoma-downloader
- Repository: https://github.com/leone25/sanoma-downloader

## Overview

Sanoma-downloader is a command-line tool that authenticates to Sanoma, lets the user choose a book, downloads its page archive, converts the extracted SVG pages to PDFs with Inkscape, and merges them into one output PDF. The runtime is entirely in index.js; the graph separates its workflow stages by responsibility. Source inspection is limited to that file, so undocumented service behavior and internal API details are omitted.

Main entry points: [`index.js`](https://github.com/leone25/sanoma-downloader/blob/main/index.js) (Account authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and selection"]
  node_cli["CLI options and prompts<br/>[index.js]"]
  node_selection["Book selection<br/>[index.js]"]
end

subgraph group_acquisition["Sanoma acquisition"]
  node_auth["Account authentication<br/>[index.js]"]
  node_catalog["Book catalog fetch<br/>[index.js]"]
  node_download["Archive download<br/>[index.js]"]
  node_workspace["Temporary workspace<br/>[index.js]"]
end

subgraph group_pdf["PDF production"]
  node_extract["Page extraction<br/>[index.js]"]
  node_svgpages["Extracted SVG pages<br/>[index.js]"]
  node_convert["Page conversion<br/>[index.js]"]
  node_merge["PDF page merging<br/>[index.js]"]
  node_output["PDF output<br/>[index.js]"]
  node_cleanup["Workspace cleanup<br/>[index.js]"]
end

node_user(("User"))
node_sanoma["Sanoma API"]
node_inkscape["Inkscape"]

node_user -->|"provides options"| node_cli
node_cli -->|"requests login"| node_auth
node_auth -->|"posts credentials"| node_sanoma
node_auth -->|"passes token"| node_catalog
node_catalog -->|"fetches books"| node_sanoma
node_catalog -->|"provides book list"| node_selection
node_user -->|"chooses book"| node_selection
node_selection -->|"selects archive"| node_download
node_download -->|"fetches archive"| node_sanoma
node_download -->|"writes ZIP"| node_workspace
node_workspace -->|"reads ZIP"| node_extract
node_extract -->|"writes SVG pages"| node_svgpages
node_svgpages -->|"supplies page files"| node_convert
node_convert -->|"converts pages"| node_inkscape
node_convert -->|"writes page PDFs"| node_merge
node_merge -->|"saves merged PDF"| node_output
node_merge -->|"finishes output"| node_cleanup
node_cleanup -->|"removes workspace"| node_workspace

click node_cli "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_auth "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_catalog "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_selection "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_download "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_workspace "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_extract "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_svgpages "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_convert "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_merge "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_output "https://github.com/leone25/sanoma-downloader/blob/main/index.js"
click node_cleanup "https://github.com/leone25/sanoma-downloader/blob/main/index.js"

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_selection,node_user toneBlue
class node_auth,node_catalog,node_download,node_workspace toneAmber
class node_extract,node_svgpages,node_convert,node_merge,node_output,node_cleanup,node_sanoma toneMint
class node_inkscape toneIndigo
```

## Components

### CLI and selection

- [CLI options and prompts](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Book selection](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`

### Sanoma acquisition

- [Account authentication](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Book catalog fetch](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Archive download](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Temporary workspace](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`

### PDF production

- [Page extraction](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Extracted SVG pages](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Page conversion](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [PDF page merging](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [PDF output](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`
- [Workspace cleanup](https://github.com/leone25/sanoma-downloader/blob/main/index.js): `index.js`

### Other components

- **User**
- **Sanoma API**
- **Inkscape**

## Connections

- User → CLI options and prompts: provides options
- CLI options and prompts → Account authentication: requests login
- Account authentication → Sanoma API: posts credentials
- Account authentication → Book catalog fetch: passes token
- Book catalog fetch → Sanoma API: fetches books
- Book catalog fetch → Book selection: provides book list
- User → Book selection: chooses book
- Book selection → Archive download: selects archive
- Archive download → Sanoma API: fetches archive
- Archive download → Temporary workspace: writes ZIP
- Temporary workspace → Page extraction: reads ZIP
- Page extraction → Extracted SVG pages: writes SVG pages
- Extracted SVG pages → Page conversion: supplies page files
- Page conversion → Inkscape: converts pages
- Page conversion → PDF page merging: writes page PDFs
- PDF page merging → PDF output: saves merged PDF
- PDF page merging → Workspace cleanup: finishes output
- Workspace cleanup → Temporary workspace: removes workspace
