How kienminho/anymex works
Main Layers and Components
• User Interface (Presentation) Layer:
• Represented by the “lib/screens” and “lib/widgets” directories.
• This layer manages the visual components including screens (anime, manga, novel, library, profile, settings) and reusable widgets (animations, headers, navigation bars).
• Also includes platform-specific UI configuration present under android, ios, macos, windows, linux, and web directories.
• Business Logic Layer:
• Located in “lib/controllers” and “lib/models.”
• Controllers such as “anilist,” “offline,” “settings,” “source,” and “theme” drive the app’s behavior.
• Models define the data structures for content (anime, manga, novels) and support offline storage (Hive models).
• Data & API Integration Layer:
• Found in “lib/api.”
• This layer contains code for content extraction, API communication, and source handling. Notably, the “Mangayomi” directory under “lib/api” encapsulates various routines:
• Evaluation engine components (subdirectories Eval/dart, Eval/javascript, Eval/compiler, etc.)
• Extensions for fetching sources (extensions providers, anime and manga extractors).
• HTTP clients (in “lib/api/Mangayomi/http”) with specialized submodules such as RHTTP and rust-based API integrations.
• This layer is responsible for interfacing with external data sources, processing content, and handling the necessary parsing and extraction tasks.
• Offline Storage & Persistence:
• Look in “lib/controllers/offline” and “lib/models/Offline.”
• The offline functionality—using Hive-based models—is an essential component enabling local caching of user data and media information.
• External Service Integrations:
• The project integrates with external APIs (for example, AniList sync is mentioned in the README).
• These interactions can be visualized as separate services that interact with the API layer (sending requests and receiving data).
Relationships and Data Flow
• Start at the top with the UI layer handling user input and presentation.
• User interactions trigger events in the business logic controllers (for example, a user selects an anime or manga).
• The controllers communicate with the API layer to fetch or update content. In this process, the API integration layer uses custom extraction logic and HTTP clients to fetch information from external sources.
• Data is then passed back to the controllers, which update the UI accordingly and may also save data for offline access.
• Offline storage components are accessed throughout the flow for caching and local data persistence.
• Additionally, platform-specific modules (Android, iOS, etc.) are essentially Flutter “shells” that call into the same shared code in lib/, which can be represented as an underlying cross-platform infrastructure supporting all these components.
Important Architectural Patterns and Technologies
• Layered Architecture (Separation of Concerns):
• Clearly separate presentation (UI/screens/widgets), domain logic (controllers/models), and data access (API/extraction services).
• Modular Design:
• The distinct packages under lib (like controllers, api, models, widgets) suggest a modular architecture where each component can be developed and tested independently.
• Multi-platform Support:
• The presence of platform-specific directories indicates that while most code is shared in Flutter (lib/), platform-specific adaptations exist.
• Use of Code Generation:
• Files with “.g.dart” indicate that some models/controllers leverage Dart’s build tools for code generation.
• Custom HTTP Client & Extraction Engines:
• The API substructure (with components like evaluation, extraction, HTTP client integration) is central to obtaining and processing content.