# rmcrackan/libation architecture

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

- Interactive diagram: https://gitdiagram.com/rmcrackan/libation
- Repository: https://github.com/rmcrackan/libation
- Video tour (about a minute): https://gitdiagram.com/rmcrackan/libation/video

## Overview

Libation is a cross-platform desktop and CLI application for scanning and organizing an Audible library, then downloading and decrypting selected audiobooks into managed files. Its main user workflow runs from account access and library discovery through searchable library records to download/decryption and file storage; import, export, and Audiobookshelf upload are related capabilities. Search uses a Lucene index backed by library records. The README establishes the product capabilities; several subsystem connections below are documented or reflected by module responsibilities, but unsampled implementations are not verified in detail.

Main entry points: [`Source/LibationAvalonia/ViewModels/MainVM.cs`](https://github.com/rmcrackan/libation/blob/master/Source/LibationAvalonia/ViewModels/MainVM.cs) (Desktop app), [`Source/FileLiberator/DownloadDecryptBook.cs`](https://github.com/rmcrackan/libation/blob/master/Source/FileLiberator/DownloadDecryptBook.cs) (Book download), [`Source/ApplicationServices/LibraryCommands.cs`](https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/LibraryCommands.cs) (Library scan), [`Source/DataLayer/LibationContext.cs`](https://github.com/rmcrackan/libation/blob/master/Source/DataLayer/LibationContext.cs) (Library records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_desktop["Desktop app<br/>[MainVM.cs]"]
  node_cli["CLI<br/>[Program.cs]"]
end

subgraph group_audible["Audible access"]
  node_accounts["Account auth<br/>[Account.cs]"]
  node_audible_api["Audible API<br/>[ApiExtended.cs]"]
end

subgraph group_library["Library services"]
  node_scan["Library scan<br/>[LibraryCommands.cs]"]
  node_import["Library import"]
  node_catalog[("Library records<br/>[LibationContext.cs]")]
  node_search_commands["Search commands"]
  node_search_index[("Search index<br/>[SearchEngine.cs]")]
  node_export["Library export<br/>[LibraryExporter.cs]"]
end

subgraph group_download["Download and files"]
  node_download_queue["Download queue"]
  node_download["Book download"]
  node_decryption["AAX decryption"]
  node_file_storage["Audio storage"]
  node_file_templates["File organization<br/>[NamingTemplate.cs]"]
end

subgraph group_integrations["Persistence and integrations"]
  node_database["Database provider"]
  node_token_storage["Token storage"]
  node_audiobookshelf["Audiobookshelf"]
  node_csv["CSV export<br/>[CsvWriter.cs]"]
end

node_user(("User"))

node_user -->|"uses"| node_desktop
node_user -->|"uses"| node_cli
node_desktop -->|"requests scan"| node_scan
node_cli -->|"requests scan"| node_scan
node_accounts -->|"authenticates"| node_audible_api
node_scan -->|"retrieves library"| node_audible_api
node_desktop -->|"imports library"| node_import
node_scan -->|"updates records"| node_catalog
node_import -->|"imports records"| node_catalog
node_database -->|"creates context"| node_catalog
node_search_commands -->|"queries and updates"| node_search_index
node_search_index -->|"indexes records"| node_catalog
node_desktop -->|"searches library"| node_search_commands
node_desktop -->|"exports library"| node_export
node_export -->|"writes CSV"| node_csv
node_desktop -->|"queues books"| node_download_queue
node_download_queue -->|"dispatches books"| node_download
node_download -->|"retrieves audio"| node_audible_api
node_download -->|"decrypts audio"| node_decryption
node_download -->|"stores output"| node_file_storage
node_file_templates -->|"names output"| node_download
node_accounts -->|"persists tokens"| node_token_storage
node_download -.->|"uploads book"| node_audiobookshelf

click node_desktop "https://github.com/rmcrackan/libation/blob/master/Source/LibationAvalonia/ViewModels/MainVM.cs"
click node_cli "https://github.com/rmcrackan/libation/blob/master/Source/LibationCli/Program.cs"
click node_accounts "https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/Account.cs"
click node_audible_api "https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/ApiExtended.cs"
click node_scan "https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/LibraryCommands.cs"
click node_import "https://github.com/rmcrackan/libation/blob/master/Source/DtoImporterService/LibraryBookImporter.cs"
click node_catalog "https://github.com/rmcrackan/libation/blob/master/Source/DataLayer/LibationContext.cs"
click node_search_commands "https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/SearchEngineCommands.cs"
click node_search_index "https://github.com/rmcrackan/libation/blob/master/Source/LibationSearchEngine/SearchEngine.cs"
click node_export "https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/LibraryExporter.cs"
click node_download_queue "https://github.com/rmcrackan/libation/blob/master/Source/LibationUiBase/ProcessQueue/ProcessQueueViewModel.cs"
click node_download "https://github.com/rmcrackan/libation/blob/master/Source/FileLiberator/DownloadDecryptBook.cs"
click node_decryption "https://github.com/rmcrackan/libation/blob/master/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs"
click node_file_storage "https://github.com/rmcrackan/libation/blob/master/Source/LibationFileManager/AudibleFileStorage.cs"
click node_file_templates "https://github.com/rmcrackan/libation/blob/master/Source/FileManager/NamingTemplate/NamingTemplate.cs"
click node_database "https://github.com/rmcrackan/libation/blob/master/Source/DataLayer/LibationContextFactory.cs"
click node_token_storage "https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/IdentityTokenStorageWiring.cs"
click node_audiobookshelf "https://github.com/rmcrackan/libation/blob/master/Source/FileLiberator/UploadToAudiobookshelf.cs"
click node_csv "https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/CsvWriter.cs"

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_desktop,node_cli,node_user toneBlue
class node_accounts,node_audible_api toneAmber
class node_scan,node_import,node_catalog,node_search_commands,node_search_index,node_export toneMint
class node_download_queue,node_download,node_decryption,node_file_storage,node_file_templates toneRose
class node_database,node_token_storage,node_audiobookshelf,node_csv toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/rmcrackan/libation/blob/master/Source/LibationAvalonia/ViewModels/MainVM.cs): `Source/LibationAvalonia/ViewModels/MainVM.cs`
- [CLI](https://github.com/rmcrackan/libation/blob/master/Source/LibationCli/Program.cs): `Source/LibationCli/Program.cs`

### Audible access

- [Account auth](https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/Account.cs): `Source/AudibleUtilities/Account.cs`
- [Audible API](https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/ApiExtended.cs): `Source/AudibleUtilities/ApiExtended.cs`

### Library services

- [Library scan](https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/LibraryCommands.cs): `Source/ApplicationServices/LibraryCommands.cs`
- [Library import](https://github.com/rmcrackan/libation/blob/master/Source/DtoImporterService/LibraryBookImporter.cs): `Source/DtoImporterService/LibraryBookImporter.cs`
- [Library records](https://github.com/rmcrackan/libation/blob/master/Source/DataLayer/LibationContext.cs): `Source/DataLayer/LibationContext.cs`
- [Search commands](https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/SearchEngineCommands.cs): `Source/ApplicationServices/SearchEngineCommands.cs`
- [Search index](https://github.com/rmcrackan/libation/blob/master/Source/LibationSearchEngine/SearchEngine.cs): `Source/LibationSearchEngine/SearchEngine.cs`
- [Library export](https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/LibraryExporter.cs): `Source/ApplicationServices/LibraryExporter.cs`

### Download and files

- [Download queue](https://github.com/rmcrackan/libation/blob/master/Source/LibationUiBase/ProcessQueue/ProcessQueueViewModel.cs): `Source/LibationUiBase/ProcessQueue/ProcessQueueViewModel.cs`
- [Book download](https://github.com/rmcrackan/libation/blob/master/Source/FileLiberator/DownloadDecryptBook.cs): `Source/FileLiberator/DownloadDecryptBook.cs`
- [AAX decryption](https://github.com/rmcrackan/libation/blob/master/Source/AaxDecrypter/AaxcDownloadSingleConverter.cs): `Source/AaxDecrypter/AaxcDownloadSingleConverter.cs`
- [Audio storage](https://github.com/rmcrackan/libation/blob/master/Source/LibationFileManager/AudibleFileStorage.cs): `Source/LibationFileManager/AudibleFileStorage.cs`
- [File organization](https://github.com/rmcrackan/libation/blob/master/Source/FileManager/NamingTemplate/NamingTemplate.cs): `Source/FileManager/NamingTemplate/NamingTemplate.cs`

### Persistence and integrations

- [Database provider](https://github.com/rmcrackan/libation/blob/master/Source/DataLayer/LibationContextFactory.cs): `Source/DataLayer/LibationContextFactory.cs`
- [Token storage](https://github.com/rmcrackan/libation/blob/master/Source/AudibleUtilities/IdentityTokenStorageWiring.cs): `Source/AudibleUtilities/IdentityTokenStorageWiring.cs`
- [Audiobookshelf](https://github.com/rmcrackan/libation/blob/master/Source/FileLiberator/UploadToAudiobookshelf.cs): `Source/FileLiberator/UploadToAudiobookshelf.cs`
- [CSV export](https://github.com/rmcrackan/libation/blob/master/Source/ApplicationServices/CsvWriter.cs): `Source/ApplicationServices/CsvWriter.cs`

### Other components

- **User**

## Connections

- User → Desktop app: uses
- User → CLI: uses
- Desktop app → Library scan: requests scan
- CLI → Library scan: requests scan
- Account auth → Audible API: authenticates
- Library scan → Audible API: retrieves library
- Desktop app → Library import: imports library
- Library scan → Library records: updates records
- Library import → Library records: imports records
- Database provider → Library records: creates context
- Search commands → Search index: queries and updates
- Search index → Library records: indexes records
- Desktop app → Search commands: searches library
- Desktop app → Library export: exports library
- Library export → CSV export: writes CSV
- Desktop app → Download queue: queues books
- Download queue → Book download: dispatches books
- Book download → Audible API: retrieves audio
- Book download → AAX decryption: decrypts audio
- Book download → Audio storage: stores output
- File organization → Book download: names output
- Account auth → Token storage: persists tokens
- Book download → Audiobookshelf: uploads book
