# sudashiii/sake architecture

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

- Interactive diagram: https://gitdiagram.com/sudashiii/sake
- Repository: https://github.com/sudashiii/sake

## Overview

Sake is a self-hosted reading stack: a web library and reader backed by server APIs, with KOReader synchronization, provider-based book imports, annotations, statistics, and OPDS/WebDAV access. The principal workflow is managing or discovering a book, then reading it and syncing progress across devices. The graph preserves documented capabilities, but many route-to-use-case and UI-to-API connections are not shown in the sampled source, so those links are omitted rather than inferred.

Main entry points: [`sake/src/routes/api/opds/+server.ts`](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/%2Bserver.ts) (OPDS catalog), [`sake/src/lib/server/infrastructure/storage/S3Storage.ts`](https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/infrastructure/storage/S3Storage.ts) (Object storage), [`sake/src/lib/features/library`](https://github.com/sudashiii/sake/tree/master/sake/src/lib/features/library) (Library views), [`sake/src/lib/client/routes`](https://github.com/sudashiii/sake/tree/master/sake/src/lib/client/routes) (Auth client routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webui["Web interface"]
  node_authui["Account access<br/>[authService.ts]"]
  node_authroutes["Auth client routes"]
end

subgraph group_library["Library management"]
  node_libraryui["Library views"]
  node_shelfui["Shelf management"]
  node_libraryapi["Library API"]
  node_librarycases["Library operations"]
  node_annotations["Annotations hub"]
end

subgraph group_reading["Reading and devices"]
  node_readerui["Web reader"]
  node_deviceapi["Device sync API"]
  node_progressapi["Progress sync<br/>[+server.ts]"]
  node_plugin["KOReader plugin delivery"]
end

subgraph group_discovery["Discovery and insights"]
  node_searchui["Book search<br/>[searchView.ts]"]
  node_searchapi["Search API<br/>[+server.ts]"]
  node_stats["Reading statistics<br/>[statsView.ts]"]
  node_opds["OPDS catalog<br/>[+server.ts]"]
  node_webdav["WebDAV access<br/>[+server.ts]"]
end

subgraph group_server["Server and integrations"]
  node_serverapp["Application services"]
  node_config["Infrastructure config"]
  node_storage["Object storage<br/>[S3Storage.ts]"]
  node_opdsfeed["Feed renderer<br/>[feedBuilder.ts]"]
  node_opdsauth["Basic auth<br/>[auth.ts]"]
  node_s3pagination["Object listing"]
end

node_reader(("Web user"))
node_s3[("S3-compatible storage")]

node_reader -->|"uses"| node_webui
node_reader -->|"manages books"| node_libraryui
node_reader -->|"finds books"| node_searchui
node_reader -->|"reads books"| node_readerui
node_reader -->|"manages notes"| node_annotations
node_reader -->|"reviews activity"| node_stats
node_reader -->|"browses catalog"| node_opds
node_reader -->|"uses access"| node_webdav
node_authui -->|"calls"| node_authroutes
node_authroutes -.->|"requests account access"| node_reader
node_libraryui -.->|"manages collection"| node_libraryapi
node_libraryapi -.->|"dispatches operations"| node_librarycases
node_shelfui -.->|"organizes shelves"| node_libraryui
node_searchui -.->|"searches catalog"| node_searchapi
node_deviceapi -.->|"syncs progress"| node_progressapi
node_readerui -.->|"syncs reading state"| node_progressapi
node_plugin -.->|"supports KOReader"| node_deviceapi
node_opds -->|"checks access"| node_opdsauth
node_opds -->|"renders navigation"| node_opdsfeed
node_config -->|"configures"| node_storage
node_storage -->|"reads and writes"| node_s3
node_storage -->|"lists objects"| node_s3pagination

click node_webui "https://github.com/sudashiii/sake/tree/master/sake/src/lib/components"
click node_authui "https://github.com/sudashiii/sake/blob/master/sake/src/lib/client/services/authService.ts"
click node_authroutes "https://github.com/sudashiii/sake/tree/master/sake/src/lib/client/routes"
click node_libraryui "https://github.com/sudashiii/sake/tree/master/sake/src/lib/features/library"
click node_shelfui "https://github.com/sudashiii/sake/blob/master/sake/src/lib/components/sidebar/Sidebar/sidebarShelfManager.svelte.ts"
click node_libraryapi "https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/library"
click node_librarycases "https://github.com/sudashiii/sake/tree/master/sake/src/lib/server/application/use-cases"
click node_annotations "https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/annotations"
click node_readerui "https://github.com/sudashiii/sake/tree/master/sake/src/lib/features/reader"
click node_deviceapi "https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/devices"
click node_progressapi "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/library/progress/%2Bserver.ts"
click node_plugin "https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/application/use-cases/GetKoreaderPluginDownloadUseCase.ts"
click node_searchui "https://github.com/sudashiii/sake/blob/master/sake/src/lib/features/search/searchView.ts"
click node_searchapi "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/search/%2Bserver.ts"
click node_stats "https://github.com/sudashiii/sake/blob/master/sake/src/lib/features/stats/statsView.ts"
click node_opds "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/%2Bserver.ts"
click node_webdav "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/dav/%5B...path%5D/%2Bserver.ts"
click node_serverapp "https://github.com/sudashiii/sake/tree/master/sake/src/lib/server/application"
click node_config "https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/config/infrastructure.shared.js"
click node_storage "https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/infrastructure/storage/S3Storage.ts"
click node_opdsfeed "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/feedBuilder.ts"
click node_opdsauth "https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/auth.ts"
click node_s3pagination "https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/infrastructure/storage/S3ListPagination.ts"

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_authui,node_authroutes,node_reader toneBlue
class node_libraryui,node_shelfui,node_libraryapi,node_librarycases,node_annotations,node_s3 toneAmber
class node_readerui,node_deviceapi,node_progressapi,node_plugin toneMint
class node_searchui,node_searchapi,node_stats,node_opds,node_webdav toneRose
class node_serverapp,node_config,node_storage,node_opdsfeed,node_opdsauth,node_s3pagination toneIndigo
```

## Components

### Web application

- [Web interface](https://github.com/sudashiii/sake/tree/master/sake/src/lib/components): `sake/src/lib/components`
- [Account access](https://github.com/sudashiii/sake/blob/master/sake/src/lib/client/services/authService.ts): `sake/src/lib/client/services/authService.ts`
- [Auth client routes](https://github.com/sudashiii/sake/tree/master/sake/src/lib/client/routes): `sake/src/lib/client/routes`

### Library management

- [Library views](https://github.com/sudashiii/sake/tree/master/sake/src/lib/features/library): `sake/src/lib/features/library`
- [Shelf management](https://github.com/sudashiii/sake/blob/master/sake/src/lib/components/sidebar/Sidebar/sidebarShelfManager.svelte.ts): `sake/src/lib/components/sidebar/Sidebar/sidebarShelfManager.svelte.ts`
- [Library API](https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/library): `sake/src/routes/api/library`
- [Library operations](https://github.com/sudashiii/sake/tree/master/sake/src/lib/server/application/use-cases): `sake/src/lib/server/application/use-cases`
- [Annotations hub](https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/annotations): `sake/src/routes/api/annotations`

### Reading and devices

- [Web reader](https://github.com/sudashiii/sake/tree/master/sake/src/lib/features/reader): `sake/src/lib/features/reader`
- [Device sync API](https://github.com/sudashiii/sake/tree/master/sake/src/routes/api/devices): `sake/src/routes/api/devices`
- [Progress sync](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/library/progress/%2Bserver.ts): `sake/src/routes/api/library/progress/+server.ts`
- [KOReader plugin delivery](https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/application/use-cases/GetKoreaderPluginDownloadUseCase.ts): `sake/src/lib/server/application/use-cases/GetKoreaderPluginDownloadUseCase.ts`

### Discovery and insights

- [Book search](https://github.com/sudashiii/sake/blob/master/sake/src/lib/features/search/searchView.ts): `sake/src/lib/features/search/searchView.ts`
- [Search API](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/search/%2Bserver.ts): `sake/src/routes/api/search/+server.ts`
- [Reading statistics](https://github.com/sudashiii/sake/blob/master/sake/src/lib/features/stats/statsView.ts): `sake/src/lib/features/stats/statsView.ts`
- [OPDS catalog](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/%2Bserver.ts): `sake/src/routes/api/opds/+server.ts`
- [WebDAV access](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/dav/%5B...path%5D/%2Bserver.ts): `sake/src/routes/api/dav/[...path]/+server.ts`

### Server and integrations

- [Application services](https://github.com/sudashiii/sake/tree/master/sake/src/lib/server/application): `sake/src/lib/server/application`
- [Infrastructure config](https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/config/infrastructure.shared.js): `sake/src/lib/server/config/infrastructure.shared.js`
- [Object storage](https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/infrastructure/storage/S3Storage.ts): `sake/src/lib/server/infrastructure/storage/S3Storage.ts`
- [Feed renderer](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/feedBuilder.ts): `sake/src/routes/api/opds/feedBuilder.ts`
- [Basic auth](https://github.com/sudashiii/sake/blob/master/sake/src/routes/api/opds/auth.ts): `sake/src/routes/api/opds/auth.ts`
- [Object listing](https://github.com/sudashiii/sake/blob/master/sake/src/lib/server/infrastructure/storage/S3ListPagination.ts): `sake/src/lib/server/infrastructure/storage/S3ListPagination.ts`

### Other components

- **Web user**
- **S3-compatible storage**

## Connections

- Web user → Web interface: uses
- Web user → Library views: manages books
- Web user → Book search: finds books
- Web user → Web reader: reads books
- Web user → Annotations hub: manages notes
- Web user → Reading statistics: reviews activity
- Web user → OPDS catalog: browses catalog
- Web user → WebDAV access: uses access
- Account access → Auth client routes: calls (evidence: `sake/src/lib/client/services/authService.ts`)
- Auth client routes → Web user: requests account access
- Library views → Library API: manages collection
- Library API → Library operations: dispatches operations
- Shelf management → Library views: organizes shelves
- Book search → Search API: searches catalog
- Device sync API → Progress sync: syncs progress
- Web reader → Progress sync: syncs reading state
- KOReader plugin delivery → Device sync API: supports KOReader
- OPDS catalog → Basic auth: checks access (evidence: `sake/src/routes/api/opds/+server.ts`)
- OPDS catalog → Feed renderer: renders navigation (evidence: `sake/src/routes/api/opds/+server.ts`)
- Infrastructure config → Object storage: configures (evidence: `sake/src/lib/server/infrastructure/storage/S3Storage.ts`)
- Object storage → S3-compatible storage: reads and writes (evidence: `sake/src/lib/server/infrastructure/storage/S3Storage.ts`)
- Object storage → Object listing: lists objects (evidence: `sake/src/lib/server/infrastructure/storage/S3Storage.ts`)
