How anxcye/anx-reader works
Main Components
• User Interface (UI) Layer: Represented by the Flutter components. In the "lib/page" and "lib/widgets" directories, you have pages for the homepage, settings, book player, reading view, and various UI controls for notes, customization, and statistics. This layer handles user interaction on all supported platforms.
• Service/Business Logic Layer: Housed in subdirectories like "lib/service" and "lib/providers". This includes modules for AI integration (under “lib/service/ai”), book management, translation (using Google/Microsoft integrations), text-to-speech, file conversion (e.g., TXT and PDF conversion), synchronization, and statistical analysis.
• Data Access Layer: Look in "lib/dao", which contains data access objects for books, book notes, reading times, and themes, and in "lib/config" for shared preferences. This layer manages local database operations and configuration settings.
• External Integrations and APIs: External services such as WebDAV for syncing, AI services (OpenAI, Claude, Gemini, and DeepSeek), and translation APIs are integrated in the service modules.
• Platform Specific Layers: Native directories (android, ios, macos, windows, linux, web) indicate that the app leverages platform-specific embedding and configuration using the Flutter engine. These directories form the bridge between the Flutter code and native platform capabilities.
Relationships & Interactions
• The UI layer (Flutter pages and widgets) interacts with the service layer via providers. For instance, a user action like highlighting a text or switching themes is propagated through UI widgets to the service modules.
• The service modules implement the business logic. For example, the book player service communicates with the UI to render content, and the convert_to_epub service converts various formats.
• The data access layer interacts with both UI (for local data display) and service modules (for updating state, persisting changes, and syncing).
• External services (AI, translation, sync via WebDAV) are called from within respective service modules, and responses are then managed and passed back to the UI.
• Additional configuration and logging utilities (found under “lib/utils” and “lib/providers”) assist in error handling, analytics, and version management.
Architectural Patterns and Design Principles
• The project is modular and adopts a layered (or MVVM/MVC-like) architecture where the presentation (UI) is decoupled from the business logic and data access.
• Provider packages (Riverpod code generation is mentioned in the README) are used for state management and dependency injection, promoting clean separation of concerns.
• Cross-platform design: Although Flutter manages the majority of the presentation, native directories handle platform-specific settings and adaptations.
Including Relevant Technologies
• Flutter & Dart as the main framework and language.
• Riverpod for state management and code generation (indicated by usage of build_runner).
• Native integration files for Android, iOS, etc., highlighting platform-specific adaptations.
• Integrated AI and translation services with various submodules in the service layer.
• File conversion libraries for EPUB, MOBI, PDF, TXT formats and web-based ebook renderers from “assets/foliate-js”.
• Name each component explicitly using the folder structure as guidance (e.g., label “lib/page” as "UI Pages", “lib/service/ai” as "AI Services", “lib/dao” as "Data Access Objects", etc.).
• Integration points (e.g., WebDAV sync, translation APIs) and annotate key functions like “TTS”, “Conversion Services”, and “Reading Analytics”.
• Modularity—note that improvements or changes in one module (like switching AI services) have minimal impact on others due to the clear layered separation.