How guozhigq/pilipala works
Main Components
• Frontend (Flutter UI)
– The majority of the app’s presentation lives in the lib/pages directory, which is organized by features (e.g., home, video, dynamic, login, member, etc.)
– lib/common also contains shared widgets and utility components.
• Business Logic & State Management
– Controllers inside each page directory orchestrate user interactions, data fetching, and navigation flows.
– The project uses providers/service locators (see lib/services/service_locator.dart) for dependency management.
• Data Access Layer
– HTTP API communications are abstracted in lib/http (API endpoints for bangumi, dynamics, video, user, login, etc.).
– Data models are well-organized in lib/models which mirror the domain objects that come from BiliBili APIs.
• Plugins & Custom Modules
– Custom plugins in lib/plugin (e.g., pl_gallery, pl_player, pl_popup, pl_socket) encapsulate reusable functionality like custom media viewing and socket communication.
• Platform Integrations
– Directories for android, ios, macos, linux, windows contain native project configurations and platform-specific code.
• Assets & Resources
– Assets folder holds fonts, images, and JSON files that support theming and media in the UI.
• Build, CI/CD and Deployment
– .github/workflows, fastlane and pubspec files indicate automated build and release processes.
Relationships and Interactions
• Controllers call upon service classes in lib/services and HTTP helper classes (lib/http) to fetch data from external APIs (BiliBili official endpoints as mentioned in the README).
• The data retrieved is then transformed into model objects (in lib/models) and passed back to the UI.
• Custom plugins (lib/plugin) are invoked by both UI and service layers to provide enhanced functionalities such as video playback, popup dialogs, or socket events.
• External API Services: Even if not maintained internally, a note should be drawn that the mobile client interacts with BiliBili’s API endpoints.
Architectural Patterns and Design Principles
• Modularization: The clear separation of pages, models, controllers, services, and plugins allows independent development and testing.
• Layered/MVC Pattern:
• The “View” is implemented in Flutter’s UI (pages, widgets)
• “Controllers” manage user actions and data flows.
• “Models” represent structured data from API calls.
• Dependency Injection: (Service Locator in lib/services/service_locator.dart) simplifies testing and enhances modular design.
• Responsive Design: The project’s multiple directories (android, ios, web, desktop) indicate that the app is built for cross-platform support.
– Ensure every component is clearly labeled.
– Create additional callouts for builds/CI systems (e.g., GitHub Actions, Fastlane) if needed.
– The high level should not overwhelm minor details – focus on showing how many components collaborate to provide the features listed (e.g., video playback controls, dynamic feed, blacklisting, live streaming support).