How gotson/komga works
Main Components
• Frontend (komga-webui): This is the client-facing part, built using modern web technologies (Vue.js, TypeScript, etc.). It communicates with the backend via RESTful endpoints and also supports OPDS feeds.
• Backend (komga): The central server implemented in Kotlin. It is organized using a rich domain-driven design. Notice the “domain”, “application”, “infrastructure”, and “interfaces” packages that clearly show the layered structure.
• Komga Tray: A desktop tray application that wraps around some UI aspects for local usage. It has its own source set and libraries.
• Database & Migrations: With numerous Flyway migration scripts and configuration files, it appears that a relational database (likely SQLite by default) is in use.
• External Integrations:
– API integrations for external clients (readers, Kobo sync, KOReader sync, OPDS endpoints).
– Messaging and event-driven subsystems (e.g., SSE endpoints, tasks, and JMS-based components) provide asynchronous processing.
– Metadata handling components for comic and ebook metadata retrieval from comicrack, mylar, local artwork libraries, etc.
• Utilities & Infrastructure: Infrastructure packages include caching, security (including API key, OAuth2, and session management), search (using Lucene for full-text and multilingual search), and file system scanning for duplicate files or pages.
Relationships and Data Flows
• The Frontend communicates via REST API calls to the Backend (which is also responsible for serving OPDS feeds).
• The Backend’s “interfaces” layer exposes REST, SOAP, OPDS, and SSE endpoints. Note the clear separation with dedicated packages for REST controllers, API DTOs, and API security.
• The “domain” layer models the business logic of libraries, series, books, users, and tasks. Services in this layer are orchestrated by application service classes and call into the “infrastructure” layer for persistence and external integrations.
• The Infrastructure layer handles concerns such as:
– Database access via persistence repositories (Jooq, Spring Data, or similar).
– External resources; e.g., file system, media type detection, metadata extraction, and hash calculations.
– Caching and security operations.
• Background tasks and schedulers (in the application layer) coordinate operations like library scans, metadata updates, and maintenance tasks.
• The Komga Tray likely acts as a client connecting directly to the backend or wrapping portions of the frontend code for desktop-specific functionality.
Architectural Patterns and Design Principles
• Layered / Hexagonal architecture: The clear division between Domain, Application, Infrastructure, and Interfaces indicates Domain-Driven Design.
• Micro-modular and plug-in based: The “plugins” directory in the frontend and modular services in the backend suggest extensibility.
• Event-driven: Use of event publishers, SSE endpoints, and asynchronous scheduling reflects that the application reacts to internal events.
• RESTful design: Based on the controllers and DTOs provided.
Detail What to Highlight
– Stress the layered architecture (interfaces → application → domain → infrastructure).
– Emphasize critical functions such as library scanning, metadata aggregation, and user management.
– Call out external integrations (Kobo / KOReader sync, OPDS support, etc.) in separate blocks.
– Optionally, add a “Utility Components” section for error logging, caching, and search indexing.
– Additionally, if desired, include a small inset that shows the process flow for a typical user request (from login through to reading a book).