How freeok/so-novel works
Main Components to Identify and Represent
• User Interface / Entry Point:
• CLI or script-based interface, given that the installation instructions indicate “解压即用” and separate deployment shell scripts.
• Action Layer:
• Distinct “Action” components (BatchDownloadAction, CheckUpdateAction, SearchAndDownloadAction, ShowSourcesAction). These represent discrete user commands/features.
• That each action channels user input to specific processing flows.
• Core / Crawler Component:
• “Crawler” module under the “core” package, which is responsible for fetching and crawling novel data.
• Alongside, include supporting utilities like ChapterFilter, ChapterFormatter, and CoverUpdater that process the data.
• Parsing and Conversion:
• “parse” components (e.g., BookParser, ChapterParser, SearchParser, TocParser) that extract data from the fetched content.
• “convert” package modules (ChapterConverter, ChineseConverter) that prepare chapter content for various output formats.
• Post-Processing / Handle Module:
• Set of post-handlers (CrawlerPostHandler, EpubMergeHandler, HtmlTocHandler, TxtMergeHandler, etc.) which further process and format the downloaded content.
• Existence of a factory (PostHandlerFactory) that dynamically selects the correct post-handling routine.
• Model and Configuration:
• “model” package components (Book, Chapter, Rule, AppConfig, etc.) which model the domain entities and application configuration.
• Also, capture external configurations such as “config.ini”, “src/main/resources/application.properties”, and rule JSON files (in the “src/main/resources/rule” directory). These files indicate external DSLs or rules that guide the crawling/parsing logic.
• Utilities and Libraries:
• Utility layer (“util” package with FileUtils, JsoupUtils, etc.) which supports the overall logic.
• External libraries (e.g., Jsoup for HTML parsing) integrated through Maven (pom.xml).
Relationships and Interactions Between Components
• Actions invoke the Crawler and Parser modules to fetch and interpret novel data.
• Parser outputs feed into the Conversion layer which prepares content for being output as EPUB, TXT, or HTML.
• Post-Processing handlers (invoked via a Factory pattern) then merge or format the outputs as necessary.
• Throughout the process, configuration and rule sets (provided in JSON and JavaScript files) act as a guiding policy for crawling and parsing.
Highlighting Architectural Patterns and Design Principles
• The project is modular, broken down into clear packages that separate concerns.
• Patterns such as Factory (e.g., PostHandlerFactory) and potentially Chain of Responsibility (for post-handling) can be depicted.
• The design also emphasizes extensibility (support for multiple “书源” — book sources) and adaptability (via external rule files and dynamic configuration).
Specific Elements
• User commands → Actions
• Actions → Crawler / Parsing → Processing
• Processing → Conversion → Post-Handler → Output files
• Core business logic (actions, crawler, parser, converter)
• Supporting configuration (INI, JSON, properties files)
• External deployment components (scripts in bin, Dockerfile)
Final Representation
• Provide a clear separation between configuration resources (stored in the resources folder and external input directory) and the executable modules.