How booklore-app/booklore works
1. Repository shape
- This is a two-part monorepo: a Spring Boot backend in booklore-api and an Angular frontend in booklore-ui.
- The backend is the system of record for library state, user data, metadata, tasks, and sync state. The frontend is a rich client that talks to the backend over REST and WebSocket.
2. Backend runtime and persistence
- booklore-api is a Java/Gradle application (BookloreApplication) built around the usual controller → service → repository → entity layering.
- Persistence is in MariaDB, with schema management via Flyway migrations under src/main/resources/db/migration.
- The model is heavily normalized around books, files, metadata, shelves, users, progress, tasks, devices, and settings.
3. Core domain boundary
- The main domain boundary is the library catalog: books, files, authors, categories/tags, shelves, library paths, and user-specific state.
- DTOs, entities, mappers, and repositories are all split explicitly, so the diagram should show:
- REST controllers at the edge
- services orchestrating use cases
- repositories handling DB access
- file/metadata/device subsystems hanging off the core catalog
4. File system and import pipeline
- Book files live outside the database on mounted storage; the app reads and sometimes writes them depending on storage mode.
- The library ingestion pipeline is a major subsystem:
- file watching / monitoring
- file processing and fingerprinting
- grouping and library assignment
- metadata extraction
- persistence of book/file records
- bookdrop is a distinct import path: watched folder → parsed files → metadata enrichment → review/finalize → library import.
5. Metadata enrichment and writing
- Metadata handling is its own subsystem with extractors, parsers, writers, matchers, and refresh tasks.
- The backend supports multiple file types and metadata formats through specialized processors for EPUB, PDF, CBZ, AZW3, MOBI, FB2, and audiobooks.
- External metadata providers include services like Google Books, Open Library/OpenLibrary-style lookups, Amazon, Audible/Audnexus, Hardcover, ComicVine, RanobeDb, Douban, Goodreads, LubimyCzytac, and similar sources.
- Metadata can be stored in DB, written back into files, or persisted as sidecar metadata, depending on settings and format.
6. Reader/streaming subsystem
- Reading is not just download: the backend exposes reader-oriented services for EPUB, PDF, comics/CBZ, and audiobooks.
- There are dedicated reader services for streaming content, serving page/audio data, and managing reading progress, bookmarks, annotations, notes, and viewer preferences.
- The templates/epub and assets/foliate resources indicate server-side EPUB generation plus a browser reader integration layer.
7. Device and interoperability integrations
- Several integrations are first-class architecture boundaries:
- Kobo sync and device auth
- OPDS feeds and users
- KOReader sync/progress compatibility
- optional Komga compatibility / clean-mode handling
- email sending for “share book” workflows
- Hardcover sync for external catalog enrichment
- These are exposed as dedicated controllers/services and have their own DTOs, repositories, and security flows.
8. Authentication, authorization, and security
- Security is a major cross-cutting subsystem with:
- local login / JWT
- refresh tokens
- rate limiting
- OIDC login/callback/backchannel logout
- per-resource access control via annotations and aspects
- There are specialized filters for different protected resources, plus WebSocket auth and device-specific auth flows.
- Authorization is domain-aware: access checks can be tied to libraries or books, not just general roles.
9. Asynchronous work and scheduled tasks
- Long-running work is separated into tasks and cron/scheduler services rather than handled inline in request threads.
- Important background jobs include:
- library scan/rescan
- metadata refresh and cleanup
- deleted-book cleanup
- recommendation updates
- BookDrop periodic scans
- OIDC/session cleanup
- Task history and progress are persisted, and the frontend can monitor them.
10. Real-time notifications
- The backend publishes live events over WebSocket/STOMP-style messaging for things like log notifications, task progress, book add/remove events, and library health updates.
- This is the main push channel the UI uses to reflect asynchronous backend work without polling everywhere.
11. Frontend structure
- The Angular app is organized by feature folders: books, metadata, readers, settings, stats, bookdrop, notebook, author/series browsers, and library creation.
- Each feature typically has:
- route-facing container components
- smaller presentational components
- feature-specific services/state helpers
- Shared concerns live in src/app/shared and src/app/core:
- auth/OIDC/bootstrap
- API config
- reusable layout
- websocket client
- shared UI primitives and helpers
12. Frontend/backend interaction model
- The UI relies on backend APIs for all authoritative state: library browsing, metadata editing, reader actions, stats, tasks, settings, and device sync.
- It also consumes live notifications for progress and system events.
- Feature services wrap the HTTP API, while reader features additionally manage browser-side state for progress, notes, selection, and display preferences.
13. Operational packaging
- The repo is designed for self-hosting: Dockerfiles, compose examples, Helm chart example, and podman examples are all included.
- The README makes a key deployment constraint explicit: local filesystem storage is expected for write-heavy file operations; network storage can be used only in a reduced “metadata-only” mode where file writes/reorganization are disabled.
14. What to emphasize in an architecture diagram
- Draw the system as:
- Browser UI
- → Spring Boot API
- → MariaDB
- → filesystem/book library paths
- with side integrations to metadata providers, OIDC identity providers, Kobo/OPDS/KOReader devices, email, and background schedulers
- Add a separate lane for real-time WebSocket notifications and another for async tasks/watchers so the import, sync, and refresh flows are visually distinct from normal request/response traffic.
Main entry points: controller REST edge · src Browser UI · migration MariaDB · metadata Metadata engine
Components 20
Booklore
Two-part monorepo with backend API, Angular UI, and deployment assets.
- External services · OIDC providers, book metadata sources, device endpoints, and email infrastructure.
Backend
Spring Boot application with layered domain services and persistence.
- Spring API · Main backend application exposing REST, WebSocket, and protected file endpoints.
booklore-api/src/main/java/org/booklore/BookloreApplication.java - REST edge · Controllers for books, libraries, metadata, readers, tasks, auth, and integrations.
booklore-api/src/main/java/org/booklore/controller - Catalog services · Book, shelf, author, notebook, recommendation, and user-facing catalog orchestration.
booklore-api/src/main/java/org/booklore/service/book - Library pipeline · Library scans, file watching, grouping, processing, deletions, and bookdrop import.
booklore-api/src/main/java/org/booklore/service/library - Metadata engine · Metadata extraction, provider lookups, matching, refresh, sidecar handling, and writers.
booklore-api/src/main/java/org/booklore/service/metadata - Reader services · EPUB, PDF, comic, and audiobook streaming plus progress and annotations.
booklore-api/src/main/java/org/booklore/service/reader - Device sync · Kobo, OPDS, KOReader, Komga compatibility, email sharing, and Hardcover sync.
booklore-api/src/main/java/org/booklore/service/kobo - Security · JWT login, refresh tokens, OIDC, rate limiting, resource access checks, and WebSocket auth.
booklore-api/src/main/java/org/booklore/config/security - Async tasks · Scheduled scans, metadata refresh, cleanup, recommendations, and task history.
booklore-api/src/main/java/org/booklore/service/task - MariaDB · Persistent system of record for users, books, metadata, tasks, sync state, and settings.
booklore-api/src/main/resources/db/migration - Library files · Mounted book storage, import folders, sidecars, covers, and generated files.
Frontend
Angular client organized by feature areas and shared application services.
- Browser UI · Rich web client for browsing, reading, metadata editing, tasks, and settings.
booklore-ui/src - Core shell · Bootstrap, auth, API config, layout, websocket client, and shared services.
booklore-ui/src/app/core - Library features · Book browsing, shelves, authors, series, library creation, and book actions.
booklore-ui/src/app/features/book - Metadata UI · Metadata search, review, bulk edit, cover tools, and sidecar management.
booklore-ui/src/app/features/metadata - Readers · Ebook, PDF, comic, and audiobook readers with local viewing state.
booklore-ui/src/app/features/readers - Settings · Security, devices, email, metadata, reader preferences, tasks, and users.
booklore-ui/src/app/features/settings - Live feed · Client-side notification and progress stream for backend events.
booklore-ui/src/app/shared/websocket
Ops
Build, packaging, and deployment support for self-hosted installs.
- Packaging · Container, compose, chart, and example deployment assets for self-hosting.
Dockerfile
Connections 33
- Browser UI → Core shell: bootstraps · App shell initializes auth, layout, config, and notifications.
- Browser UI → Library features: navigates · Primary catalog browsing and library actions.
- Browser UI → Metadata UI: edits · Metadata search, merge, and bulk update workflows.
- Browser UI → Readers: reads · Launches ebook, PDF, comic, and audiobook viewers.
- Browser UI → Settings: administers · Settings and management screens.
- Core shell → Live feed: subscribes · Receives task progress and system notifications.
- Browser UI → REST edge: REST · All authoritative state is fetched and mutated through backend APIs.
- Live feed → Spring API: WS/STOMP · Live notifications are pushed from the backend.
- Spring API → REST edge: exposes · HTTP and WebSocket entry points.
- REST edge → Security: guards · Protected endpoints and auth flows are enforced at the edge.
- REST edge → Catalog services: delegates · Controllers hand off catalog use cases to services.
- REST edge → Library pipeline: delegates · Library import, scan, and file management endpoints.
- REST edge → Metadata engine: delegates · Metadata edit, lookup, refresh, and sidecar endpoints.
- REST edge → Reader services: delegates · Streaming and reader-specific endpoints.
- REST edge → Device sync: delegates · Kobo, OPDS, KOReader, email, and compatibility endpoints.
- REST edge → Async tasks: delegates · Task creation, monitoring, and history endpoints.
- Catalog services → MariaDB: persists · Books, shelves, users, progress, notes, and permissions.
- Library pipeline → Library files: watches · Reads mounted storage and reacts to file changes.
- Library pipeline → MariaDB: records · Persists file, grouping, and library state.
- Metadata engine → External services: queries · Calls external metadata and enrichment sources.
- Metadata engine → Library files: writes · Can write metadata, sidecars, covers, and reorganized files.
- Metadata engine → MariaDB: stores · Persists metadata, proposals, jobs, and settings.
- Reader services → Library files: streams · Serves book content and generated reader assets.
- Reader services → MariaDB: tracks · Stores progress, bookmarks, annotations, and preferences.
- Device sync → External services: syncs with · Device ecosystems and external sync targets.
- Device sync → MariaDB: persists · Device auth, snapshots, settings, and sync state.
- Async tasks → MariaDB: tracks · Task history, cron configuration, and progress.
- Async tasks → Library pipeline: runs · Scheduled scans and periodic bookdrop work.
- Async tasks → Metadata engine: refreshes · Metadata refresh, cleanup, and recommendation updates.
- Security → External services: OIDC · Login, callback, and backchannel logout integrate with identity providers.
- Security → MariaDB: stores · Refresh tokens, secrets, sessions, and auth mappings.
- Spring API → Library files: serves files · Reader and file operations depend on local filesystem storage.
- Spring API → Packaging: packaged by · Container and platform assets deploy the application.