$ show cnwxi/epub_tool
This repository implements a desktop application for batch processing EPUB ebooks, including reformatting, encryption/decryption (filename obfuscation), font encryption/decryption with OCR-based recognition, image compression and conversion, cover replacement, and Chinese text conversion. The application is built with Tauri 2 (Rust) as the desktop shell, Vue 3 with TypeScript for the frontend, and a Python sidecar for the heavy processing tasks. Communication between the frontend and Python backend uses a JSON Lines protocol over stdin/stdout, with protobuf schemas defining the message envelopes. The architecture follows a clear separation of concerns: the Rust layer manages the application lifecycle, window effects, and sidecar process; the Vue frontend provides a drag-and-drop interface with task panels, persistent state management, and custom UI components; the Python backend implements a task runner that dispatches work to specialized service modules for EPUB structure manipulation, font obfuscation with ONNX OCR inference, image processing, and text conversion. The system includes a comprehensive test suite covering unit tests, integration tests, and protocol contract tests. Notable design patterns include a reusable EPUB workspace abstraction with security validation, a protocol layer with dataclass-based request/response models, safe JSON serialization handling edge cases like lone surrogates, and Vue composables for persistent state and Tauri IPC bridging. The font encryption/decryption services demonstrate advanced CSS cascade emulation and glyph rendering with OCR, though they contain significant code duplication. The README explicitly states that this repository is historical and that EPUB capabilities have been migrated to a Rust implementation (epub_tool_rust). As such, the project is deprecated and no longer actively developed, but the codebase remains a well-structured example of a cross-platform desktop application with a Python sidecar.
The LLM identified 5 files worth highlighting for reuse:
Provides a safe, validated interface for reading and writing EPUB archives. Handles ZIP extraction with path traversal prevention, size limits, and proper MIME type storage. Can be extracted and reused in any Python project that needs to manipulate EPUB files securely.
Defines the core dataclasses (TaskRequest, TaskEvent, TaskResult) used for communication between the frontend and Python backend. This protocol is self-contained and could be reused in other task-oriented systems that require a structured request/response/event model.
Implements safe JSON serialization that correctly handles lone surrogates and other problematic Unicode sequences. This is a small but critical utility that demonstrates attention to edge cases and can be reused in any Python project requiring robust JSON output.
A Vue 3 composable that provides reactive persistent state with localStorage and Tauri native storage backends. Includes normalization functions for schema migration and fallback defaults. This pattern can be extracted and reused in other Vue applications that need dual-storage state management.
A Vue 3 composable that abstracts all Tauri IPC commands (file collection, task execution, font scanning, etc.) behind a clean interface. It handles streaming events, error propagation, and state management. This pattern is reusable for any Tauri + Vue project that needs a structured bridge to the backend.