Architecture
This page provides a high-level overview of kotatsu-dl's architecture, explaining the core components and how they interact to download manga from various sources. For detailed usage instructions, see Usage Guide, and for developer-focused implementation details, see Developer Guide.
System Overview
Kotatsu-dl is a command-line manga downloader built using Kotlin. Its architecture follows a clean separation of concerns with distinct layers handling different aspects of the download process.
Core Components
The system is organized around several key components that work together to download and organize manga content:
Component | Purpose | Key Files |
---|---|---|
Main Command | Entry point that parses CLI options and orchestrates the download process | Main.kt |
Link Resolver | Resolves manga URLs to specific sources and retrieves manga metadata | Referenced in Main.kt |
Manga Downloader | Coordinates downloading chapters and pages | Referenced in Main.kt |
Local Manga Output | Abstract interface for saving manga to different formats | Referenced in diagrams |
Manga Loader Context | Provides access to manga parsers | Referenced in Main.kt |
Dependencies and Build System
Kotatsu-dl is built with Gradle using the Shadow plugin to create a self-contained executable JAR file.
The build system is configured to:
- Compile Kotlin code
- Package all dependencies into a single JAR file
- Set the main class to
org.koitharu.kotatsu.dl.MainKt
- Minimize the JAR by removing unused classes
Error Handling
The application implements robust error handling:
- Input Validation: Command-line options are validated before processing
- Source Resolution: Checks if the manga source is supported
- Manga Resolution: Verifies the manga can be found
- Chapter Availability: Ensures manga has downloadable chapters
- Download Errors: Handles HTTP errors during download
Error messages are displayed to the user in a clear, human-readable format, often with color highlighting to improve readability.
Concurrency Model
Kotatsu-dl employs Kotlin Coroutines for asynchronous operations, allowing efficient parallel downloads:
- The
parallelism
parameter controls the number of concurrent downloads - The
throttle
option can slow down requests to avoid IP blocking - A dispatcher is used to execute downloads on background threads
- Progress reporting is handled simultaneously with downloads
This approach provides efficient resource usage while maintaining responsiveness.
Conclusion
Kotatsu-dl's architecture demonstrates a well-organized command-line application with clear separation of concerns:
- Command Interface Layer: Handles user input and provides feedback
- Download Orchestration Layer: Coordinates the download process
- Output Management Layer: Handles saving content in various formats
- Parser Integration Layer: Interfaces with manga sources
This modular design supports extensibility for new manga sources and output formats while maintaining a straightforward user experience.
For details on core components and their implementation, see Core Components. For information about the download process, see Download Process.