How chika3742/genshin_material works
Project Type & Purpose
• This is a cross‐platform Flutter mobile application (“genshin_material”) that provides a material bookmark & database for Genshin Impact.
• It bundles UI code (lib/), local data storage via Drift/SQLite, integration with Hoyolab’s API, Firebase services, and platform-specific bridges (Pigeon).
High-Level File-Structure Analysis
• Top-level folders
– android/ & ios/: Native platform projects, Pigeon interop, Fastlane scripts, Gradle/Xcode configs
– lib/: Dart source code split into UI widgets (components, pages), state management (providers), core logic, database schema (database.*, db/), models, utils, routes
– drift_schemas/: JSON schemas for migrations
– integration_test/, test/, test_driver/: E2E and unit/widget tests
– packages/timelines/: Local Flutter package for timeline UI
– scripts/: Automation helpers (Pigeon codegen, screenshots)
– .github/workflows/: CI/CD pipelines (test, deploy)
• Key configuration
– pubspec.yaml, build.yaml, flutterfire (Firebase) configs
– Gemfile / Fastlane (iOS/Android release pipelines)
– analysis_options.yaml, devtools_options.yaml
README-Derived Insights
• Requires Firebase setup via FlutterFire CLI (Auth, Remote Config, Analytics)
• Generated files (Freezed, Riverpod, Pigeon) are checked in for readability
Diagramming the System
a. Main Components
1. Presentation Layer
• Flutter UI widgets (lib/components, lib/pages)
2. State Management / Business Logic
• Riverpod providers (lib/providers), Core services (lib/core: asset_loader, hoyolab_api, secure_storage, kv_preferences)
3. Data Layer
• Local DB: Drift (lib/database.*, lib/db/**/*), drift_schemas for migrations
4. Integration Layer
• Remote HTTP calls to Hoyolab API (lib/core/hoyolab_api)
• Firebase SDK (Auth, Remote Config) via FlutterFire
• Native platform features bridged via Pigeon (android/.../HoyolabIntegrationApiImpl.kt, ios/.../PigeonImpls.swift)
5. External Services
• Hoyolab REST API
• Firebase project services
6. Platform Projects
• Android (Kotlin, Gradle scripts, Fastlane)
• iOS (Swift/Obj-C bridging, Xcode, Fastlane)
7. CI/CD & Automation
• GitHub Actions (test.yaml, deploy.yaml)
• scripts/ (code generation, screenshots)
b. Relationships & Interactions
• UI Widgets ←→ Riverpod Providers (one-way data flow, reactive updates)
• Providers → Core Services →
• Local DB (read/write via Drift)
• Remote API (Hoyolab or Firebase)
• Pigeon Bridge: Dart API calls → Native implementations → Device OS features (e.g., secure storage, platform dialogs)
• CI/CD pipelines automatically run tests (unit, widget, integration) and deploy builds via Fastlane
c. Architectural Patterns & Principles
• Layered architecture: clear separation of UI, state/logic, data, integration
• Reactive programming with Riverpod
• Repository-style wrappers around database and API calls
• Code generation (Freezed for immutable models/pattern-matching, Riverpod generators, Pigeon for FFI)
d. Technology & Framework Callouts
• Flutter & Dart
• Riverpod state management
• Freezed & json_serializable
• Drift (Moor) for SQLite
• Firebase (Auth, Remote Config, Analytics)
• Pigeon for Dart-native interop
• Kotlin (Android), Swift (iOS)
• GitHub Actions, Fastlane for CI/CD