How tachibana-shin/hoyomi works
Project Type and Purpose
• This is a Flutter-based multi-platform mobile/desktop application designed for reading manga and watching anime.
• The README emphasizes free multi-source content and detailed Firebase configuration for authentication.
• In addition to the client app (in /lib, with Android, iOS, Web, Linux, macOS, Windows directories), a separate “serverless” folder contains backend API endpoints (for actions such as “get-watch-time”, user logic and database interactions).
File Structure
• Client Application:
• The “lib” directory is extensive, containing pages, controllers, widgets, and services (e.g., comic and eiga services) that implement the UI and core functionalities.
• Platform-specific directories (android, ios, linux, macos, windows, web) include configuration and platform-specific build files.
• Firebase integration is evident via the configuration files (google-services.json, GoogleService-Info.plist) and usage of “flutterfire” CLI commands.
• Serverless Backend:
• The “serverless” directory hosts API endpoints built (e.g., in TypeScript) that likely interact with a Xata database and apply Firebase Admin configuration.
• SQL migrations, Xata configurations, and Drizzle configurations suggest a relational (or SQL-like) backend layered on serverless functions.
• CI/CD:
• The “.github/workflows” directory includes GitHub Actions for analysis, auto-format/fix, and releases, indicating a CI/CD pipeline managing quality and releases.
A. Client Application Component:
• Flutter Mobile/Desktop/Web Client:
• Composed of UI layers (pages, widgets) that include comic reading screens, detail pages, search pages, library views, and more.
• Organized with controllers, mixins, and services (found in the “lib” directory) to handle business logic and API interaction.
• Firebase Integration:
• Handles authentication (Google sign-in) and possibly other real-time or backend services.
B. Serverless Backend Component:
• API Services:
• Contains endpoints (found in serverless/api and related directories) such as “get-watch-time”, “set-watch-time”, etc.
• Written in TypeScript and interacts with business logic and external services.
• Database Service (Xata):
• The serverless folder includes database configurations (e.g., “serverless/db”, “drizzle”, “xata.ts”) indicating the use of the Xata database along with migrations.
• Firebase Admin Integration:
• Uses Firebase Admin (configured via service-account-key.json) for secure server-side operations.
C. CI/CD and Build Infrastructure:
• GitHub Workflows:
• Automated pipelines (analysis, formatting, releasing) that bundle with the repository.
• Shown as separate tooling that ties in with both client and serverless deployments.
Relationships and Interactions
• User Flow:
• End users interact with the Flutter client app.
• The client sends requests (API calls) to the serverless backend endpoints.
• The serverless backend processes requests, interacts with the Xata database, and may also perform server-side Firebase Admin operations.
• Data Flow:
• CI/CD:
Architectural Patterns and Design Principles
• Multi-Tiered Architecture:
• Clear separation between the client (UI/UX, business logic) and the backend (API processing, database interactions).
• Modular Design:
• The directory structure (pages, widgets, controllers in “lib”) demonstrates modularity in the client.
• The “serverless” folder’s separation into API, database, and logic further stresses modular backend design.
• Dependency Injection and Reusable Services:
• Use of “composable” elements and services likely align with best practices for dependency injection and code reuse.
• Cross-Platform Support:
• The existence of multiple platform-specific directories (Android, iOS, etc.) signifies careful planning for cross-platform compatibility.
Instructing the Principal Software Engineer
• Be very detailed: capture all essential architectural elements such as API endpoints in “serverless”, the multiple configuration files in the mobile project (Firebase, OAuth, etc.), and the CI/CD pipelines.
• Additionally annotating these components with key technologies and tools (e.g., Flutter for UI, Firebase for authentication, Xata with Drizzle for the database, GitHub Actions for CI/CD).
– A multi-platform Flutter client with components (pages, widgets, services, controllers), integrated with Firebase for authentication.
– A serverless backend containing API endpoints that handle anime and manga content requests, which interface with a Xata-managed database and use Firebase Admin for secure operations.
– CI/CD pipelines ensuring code quality and automated deployments.