# chika3742/genshin_material architecture

> Architecture diagram of the GitHub repository chika3742/genshin_material, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chika3742/genshin_material
- Repository: https://github.com/chika3742/genshin_material

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UIComponents["UI Widgets - lib/components"]:::ui
        UIPages["Pages - lib/pages"]:::ui
    end

    %% State Management / Business Logic
    subgraph "State Management / Business Logic"
        direction TB
        Providers["Riverpod Providers - lib/providers"]:::state
        CoreServices["Core Services - lib/core"]:::state
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DBMain["Drift DB - lib/database.dart"]:::data
        DBFreezed["DB Models - lib/database.freezed.dart"]:::data
        DBG["DB Generation - lib/database.g.dart"]:::data
        DBSteps["Schema Steps - lib/database.steps.dart"]:::data
        DBDir["DB Directory - lib/db"]:::data
        DriftSchemas["Drift Schemas - drift_schemas/db"]:::data
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        HoyolabAPI["Hoyolab API Client - lib/core/hoyolab_api.dart"]:::integration
        PigeonGen["Pigeon Gen - lib/pigeon.g.dart"]:::integration
        subgraph "Android Pigeon Impl"
            direction TB
            AndroidImpl["HoyolabIntegrationApiImpl.kt"]:::platform
            AndroidMsg["Messages.g.kt"]:::platform
        end
        subgraph "iOS Pigeon Impl"
            direction TB
            IOSImpl["PigeonImpls.swift"]:::platform
            IOSMsg["Messages.g.swift"]:::platform
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        HoyolabREST["Hoyolab REST API"]:::external
        Firebase["Firebase Services"]:::external
    end

    %% Platform Projects
    subgraph "Platform Projects"
        direction TB
        AndroidProject["Android Project - android/"]:::platform
        AndroidBuild["build.gradle.kts"]:::platform
        AndroidFastlane["Android Fastlane"]:::platform
        IOSProject["iOS Project - ios/"]:::platform
        IOSFastlane["iOS Fastlane"]:::platform
    end

    %% Local Package
    Packages["Timeline Package - packages/timelines"]:::package

    %% CI/CD & Automation
    subgraph "CI/CD & Automation"
        direction TB
        CICDTest["test.yaml"]:::ci
        CICDDeploy["deploy.yaml"]:::ci
        ScriptPigeon["run_pigeon.sh"]:::ci
        ScriptScreens["take_screenshots.sh"]:::ci
        ScriptWatch["watchers.sh"]:::ci
    end

    %% Connections
    UIComponents -->|uses| Providers
    UIPages -->|observes| Providers
    Providers -->|calls| CoreServices
    CoreServices -->|reads/writes| DBMain
    CoreServices -->|reads/writes| DBFreezed
    CoreServices -->|reads/writes| DBG
    CoreServices -->|reads/writes| DBSteps
    CoreServices -->|reads/writes| DBDir
    CoreServices -->|migrations| DriftSchemas
    CoreServices -->|calls| HoyolabAPI
    CoreServices -->|invokes| PigeonGen
    HoyolabAPI -->|HTTP| HoyolabREST
    CoreServices -->|uses| Firebase
    PigeonGen -->|Dart↔Native| AndroidImpl
    PigeonGen -->|Dart↔Native| AndroidMsg
    PigeonGen -->|Dart↔Native| IOSImpl
    PigeonGen -->|Dart↔Native| IOSMsg
    AndroidImpl -->|part of| AndroidProject
    AndroidMsg -->|part of| AndroidProject
    IOSImpl -->|part of| IOSProject
    IOSMsg -->|part of| IOSProject
    AndroidProject -->|build with| AndroidBuild
    AndroidProject -->|deploy via| AndroidFastlane
    IOSProject -->|build with Xcode| IOSFastlane
    Packages -->|used by| UIPages
    CICDTest -->|runs tests| Providers
    CICDTest -->|runs tests| UIComponents
    CICDDeploy -->|deploys via| AndroidFastlane
    CICDDeploy -->|deploys via| IOSFastlane
    ScriptPigeon -->|generates| PigeonGen
    ScriptScreens -->|captures| UIPages
    ScriptWatch -->|watches| CoreServices

    %% Click Events
    click UIComponents "https://github.com/chika3742/genshin_material/tree/main/lib/components"
    click UIPages "https://github.com/chika3742/genshin_material/tree/main/lib/pages"
    click Providers "https://github.com/chika3742/genshin_material/tree/main/lib/providers"
    click CoreServices "https://github.com/chika3742/genshin_material/tree/main/lib/core"
    click DBMain "https://github.com/chika3742/genshin_material/blob/main/lib/database.dart"
    click DBFreezed "https://github.com/chika3742/genshin_material/blob/main/lib/database.freezed.dart"
    click DBG "https://github.com/chika3742/genshin_material/blob/main/lib/database.g.dart"
    click DBSteps "https://github.com/chika3742/genshin_material/blob/main/lib/database.steps.dart"
    click DBDir "https://github.com/chika3742/genshin_material/tree/main/lib/db"
    click DriftSchemas "https://github.com/chika3742/genshin_material/tree/main/drift_schemas/db"
    click HoyolabAPI "https://github.com/chika3742/genshin_material/blob/main/lib/core/hoyolab_api.dart"
    click PigeonGen "https://github.com/chika3742/genshin_material/blob/main/lib/pigeon.g.dart"
    click AndroidImpl "https://github.com/chika3742/genshin_material/blob/main/android/app/src/main/kotlin/net/chikach/genshinmaterial/HoyolabIntegrationApiImpl.kt"
    click AndroidMsg "https://github.com/chika3742/genshin_material/blob/main/android/app/src/main/kotlin/net/chikach/genshinmaterial/Messages.g.kt"
    click IOSImpl "https://github.com/chika3742/genshin_material/blob/main/ios/Runner/PigeonImpls.swift"
    click IOSMsg "https://github.com/chika3742/genshin_material/blob/main/ios/Runner/Messages.g.swift"
    click AndroidProject "https://github.com/chika3742/genshin_material/tree/main/android/"
    click AndroidBuild "https://github.com/chika3742/genshin_material/blob/main/android/app/build.gradle.kts"
    click AndroidFastlane "https://github.com/chika3742/genshin_material/tree/main/android/fastlane"
    click IOSProject "https://github.com/chika3742/genshin_material/tree/main/ios/"
    click IOSFastlane "https://github.com/chika3742/genshin_material/tree/main/ios/fastlane"
    click Packages "https://github.com/chika3742/genshin_material/tree/main/packages/timelines"
    click CICDTest "https://github.com/chika3742/genshin_material/blob/main/.github/workflows/test.yaml"
    click CICDDeploy "https://github.com/chika3742/genshin_material/blob/main/.github/workflows/deploy.yaml"
    click ScriptPigeon "https://github.com/chika3742/genshin_material/blob/main/scripts/run_pigeon.sh"
    click ScriptScreens "https://github.com/chika3742/genshin_material/blob/main/scripts/take_screenshots.sh"
    click ScriptWatch "https://github.com/chika3742/genshin_material/blob/main/scripts/watchers.sh"

    %% Styles
    classDef ui fill:#D0EBFF,stroke:#2B6CB0,color:#000
    classDef state fill:#E3F9E5,stroke:#2F855A,color:#000
    classDef data fill:#FFF3E0,stroke:#DD6B20,color:#000
    classDef integration fill:#FAF5FF,stroke:#805AD5,color:#000
    classDef external fill:#F0FFF4,stroke:#38A169,color:#000
    classDef platform fill:#EDF2F7,stroke:#4A5568,color:#000
    classDef ci fill:#F7FAFC,stroke:#718096,color:#000
    classDef package fill:#FFF5F7,stroke:#D53F8C,color:#000
```
