# antoineyrem/livingpaper architecture

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

- Interactive diagram: https://gitdiagram.com/antoineyrem/livingpaper
- Repository: https://github.com/antoineyrem/livingpaper

## Overview

LivingPaper is a self-hosted web app for importing EPUB/PDF books, analyzing them into summaries, scenes and character profiles, then chatting with a selected character. The main flow runs from web book actions through background analysis to a persisted, browsable book; settings configure the OpenAI-compatible model used for analysis and chat. The README documents examples, prompt editing and import/export as additional capabilities. Evidence is limited to the README, SOURCE INDEX references and excerpts; unshown subsystem links are omitted where their caller is not established.

Main entry points: [`src/LivingPaper.Application/BookService.cs`](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/BookService.cs) (Book service), [`src/LivingPaper.Application/LlmSettingsService.cs`](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/LlmSettingsService.cs) (Settings service), [`src/LivingPaper.Application/CharacterChatService.cs`](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/CharacterChatService.cs) (Chat service), [`src/LivingPaper.Web/BookAnalysisWorker.cs`](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/BookAnalysisWorker.cs) (Analysis worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webui["Book pages<br/>[Index.cshtml.cs]"]
  node_chatpage["Character chat<br/>[Chat.cshtml.cs]"]
  node_settingspage["Settings page<br/>[Settings.cshtml.cs]"]
  node_examples["Example books<br/>[Examples.cshtml.cs]"]
  node_importexport["Book transfer<br/>[ExportEndpoint.cs]"]
end

subgraph group_books["Book processing"]
  node_bookservice["Book service<br/>[BookService.cs]"]
  node_worker["Analysis worker"]
  node_analyzer["Book analyzer<br/>[BookAnalyzer.cs]"]
  node_extractor["Text extraction"]
end

subgraph group_models["Models and chat"]
  node_chatservice["Chat service"]
  node_chatmodel["Compatible chat model"]
  node_settingsservice["Settings service"]
  node_connectiontest["Connection tester"]
  node_modelcatalog["Model catalog"]
end

subgraph group_storage["Persistence"]
  node_bookrepo[("Book repository")]
  node_settingsrepo[("Settings repository")]
  node_promptfiles["Prompt files<br/>[PromptFile.cs]"]
end

subgraph group_domain["Domain model"]
  node_bookdomain["Book and characters<br/>[Book.cs]"]
end

node_reader(("Reader"))
node_modelprovider{{"Model provider"}}

node_reader -->|"manages books"| node_webui
node_webui -->|"requests book actions"| node_bookservice
node_bookservice -->|"extracts text"| node_extractor
node_bookservice -->|"stores books"| node_bookrepo
node_bookservice -.->|"schedules analysis"| node_worker
node_worker -->|"recovers work"| node_bookservice
node_worker -->|"runs analysis"| node_analyzer
node_reader -->|"chats with character"| node_chatpage
node_chatpage -->|"sends conversation"| node_chatservice
node_chatservice -->|"selects chat model"| node_settingsservice
node_chatservice -->|"renders prompt"| node_promptfiles
node_chatservice -->|"streams reply"| node_chatmodel
node_chatmodel -->|"calls API"| node_modelprovider
node_reader -->|"configures models"| node_settingspage
node_settingspage -->|"manages providers"| node_settingsservice
node_settingsservice -->|"loads and saves"| node_settingsrepo
node_settingsservice -->|"tests connection"| node_connectiontest
node_settingsservice -->|"fetches models"| node_modelcatalog
node_reader -->|"reads examples"| node_examples
node_reader -->|"moves books"| node_importexport
node_bookrepo -->|"persists book data"| node_bookdomain

click node_webui "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Books/Index.cshtml.cs"
click node_bookservice "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/BookService.cs"
click node_worker "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/BookAnalysisWorker.cs"
click node_analyzer "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/BookAnalyzer.cs"
click node_extractor "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/BookTextExtractor.cs"
click node_chatpage "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Books/Chat.cshtml.cs"
click node_chatservice "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/CharacterChatService.cs"
click node_chatmodel "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/OpenAiCompatibleChatModel.cs"
click node_settingspage "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Settings.cshtml.cs"
click node_settingsservice "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/LlmSettingsService.cs"
click node_connectiontest "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/LlmConnectionTester.cs"
click node_modelcatalog "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/OpenAiCompatibleModelCatalog.cs"
click node_examples "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Examples.cshtml.cs"
click node_importexport "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/ExportEndpoint.cs"
click node_bookrepo "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/JsonBookRepository.cs"
click node_settingsrepo "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/JsonLlmSettingsRepository.cs"
click node_promptfiles "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/PromptFile.cs"
click node_bookdomain "https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Domain/Book.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_webui,node_chatpage,node_settingspage,node_examples,node_importexport toneBlue
class node_bookservice,node_worker,node_analyzer,node_extractor toneAmber
class node_chatservice,node_chatmodel,node_settingsservice,node_connectiontest,node_modelcatalog toneMint
class node_bookrepo,node_settingsrepo,node_promptfiles toneRose
class node_bookdomain,node_reader,node_modelprovider toneIndigo
```

## Components

### Web experience

- [Book pages](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Books/Index.cshtml.cs): `src/LivingPaper.Web/Pages/Books/Index.cshtml.cs`
- [Character chat](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Books/Chat.cshtml.cs): `src/LivingPaper.Web/Pages/Books/Chat.cshtml.cs`
- [Settings page](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Settings.cshtml.cs): `src/LivingPaper.Web/Pages/Settings.cshtml.cs`
- [Example books](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/Pages/Examples.cshtml.cs): `src/LivingPaper.Web/Pages/Examples.cshtml.cs`
- [Book transfer](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/ExportEndpoint.cs): `src/LivingPaper.Web/ExportEndpoint.cs`

### Book processing

- [Book service](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/BookService.cs): `src/LivingPaper.Application/BookService.cs`
- [Analysis worker](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Web/BookAnalysisWorker.cs): `src/LivingPaper.Web/BookAnalysisWorker.cs`
- [Book analyzer](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/BookAnalyzer.cs): `src/LivingPaper.Application/BookAnalyzer.cs`
- [Text extraction](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/BookTextExtractor.cs): `src/LivingPaper.Infrastructure/BookTextExtractor.cs`

### Models and chat

- [Chat service](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/CharacterChatService.cs): `src/LivingPaper.Application/CharacterChatService.cs`
- [Compatible chat model](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/OpenAiCompatibleChatModel.cs): `src/LivingPaper.Infrastructure/OpenAiCompatibleChatModel.cs`
- [Settings service](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/LlmSettingsService.cs): `src/LivingPaper.Application/LlmSettingsService.cs`
- [Connection tester](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Application/LlmConnectionTester.cs): `src/LivingPaper.Application/LlmConnectionTester.cs`
- [Model catalog](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Infrastructure/OpenAiCompatibleModelCatalog.cs): `src/LivingPaper.Infrastructure/OpenAiCompatibleModelCatalog.cs`

### Persistence

- [Book repository](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/JsonBookRepository.cs): `src/LivingPaper.Persistence/JsonBookRepository.cs`
- [Settings repository](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/JsonLlmSettingsRepository.cs): `src/LivingPaper.Persistence/JsonLlmSettingsRepository.cs`
- [Prompt files](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Persistence/PromptFile.cs): `src/LivingPaper.Persistence/PromptFile.cs`

### Domain model

- [Book and characters](https://github.com/antoineyrem/livingpaper/blob/main/src/LivingPaper.Domain/Book.cs): `src/LivingPaper.Domain/Book.cs`

### Other components

- **Reader**
- **Model provider**

## Connections

- Reader → Book pages: manages books
- Book pages → Book service: requests book actions (evidence: `src/LivingPaper.Web/Pages/Books/Index.cshtml.cs`)
- Book service → Text extraction: extracts text (evidence: `src/LivingPaper.Application/BookService.cs`)
- Book service → Book repository: stores books (evidence: `src/LivingPaper.Application/BookService.cs`)
- Book service → Analysis worker: schedules analysis (evidence: `src/LivingPaper.Web/BookAnalysisWorker.cs`)
- Analysis worker → Book service: recovers work (evidence: `src/LivingPaper.Web/BookAnalysisWorker.cs`)
- Analysis worker → Book analyzer: runs analysis (evidence: `src/LivingPaper.Web/BookAnalysisWorker.cs`)
- Reader → Character chat: chats with character
- Character chat → Chat service: sends conversation
- Chat service → Settings service: selects chat model (evidence: `src/LivingPaper.Application/CharacterChatService.cs`)
- Chat service → Prompt files: renders prompt (evidence: `src/LivingPaper.Application/CharacterChatService.cs`)
- Chat service → Compatible chat model: streams reply (evidence: `src/LivingPaper.Application/CharacterChatService.cs`)
- Compatible chat model → Model provider: calls API (evidence: `src/LivingPaper.Infrastructure/OpenAiCompatibleChatModel.cs`)
- Reader → Settings page: configures models
- Settings page → Settings service: manages providers (evidence: `src/LivingPaper.Web/Pages/Settings.cshtml.cs`)
- Settings service → Settings repository: loads and saves (evidence: `src/LivingPaper.Application/LlmSettingsService.cs`)
- Settings service → Connection tester: tests connection (evidence: `src/LivingPaper.Application/LlmSettingsService.cs`)
- Settings service → Model catalog: fetches models (evidence: `src/LivingPaper.Application/LlmSettingsService.cs`)
- Reader → Example books: reads examples
- Reader → Book transfer: moves books
- Book repository → Book and characters: persists book data (evidence: `src/LivingPaper.Persistence/JsonBookRepository.cs`)
