# autsunset/vidbee_flutter architecture

> Architecture diagram of the GitHub repository autsunset/vidbee_flutter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/autsunset/vidbee_flutter
- Repository: https://github.com/autsunset/vidbee_flutter

## Overview

#### Purpose and Entry Points
VidBee is a Flutter Material 3 client for parsing and downloading video/audio through yt-dlp, primarily targeting Android while carrying a Windows runner. The Dart application starts at `lib/main.dart`; Android embeds Flutter through `android/app/src/main/kotlin/com/vidbee/vidbee_flutter/MainActivity.kt`. Android packages a `ytdlp` executable at `android/app/src/main/res/raw/ytdlp`.

#### Application Composition
Feature pages organize the primary user workflows:
- Add and parse a URL, select formats, and manage active downloads: `lib/features/download/add_url_dialog.dart`, `lib/features/download/downloads_page.dart`.
- View persisted completed/failed items and retry or open/share files: `lib/features/history/history_page.dart`.
- Configure cookies, WebView-based logins, logs, and app settings: `lib/features/settings/settings_page.dart`, `lib/features/settings/cookie_settings_section.dart`, `lib/features/settings/webview_login_page.dart`.

Shared task presentation lives in `lib/shared/widgets/task_widgets.dart`; localized UI resources are centralized under `lib/shared/i18n/`.

#### State, Models, and Dependency Boundary
Riverpod providers form the dependency and state-management boundary, wiring services to UI instead of allowing pages to directly own infrastructure concerns: `lib/core/providers/service_providers.dart`, `lib/core/providers/providers.dart`. Core transfer/domain records include task lifecycle state and parsed video/playlist metadata: `lib/core/models/download_task.dart`, `lib/core/models/video_info.dart`, `lib/core/models/playlist_info.dart`.

#### Download Pipeline
The download flow accepts a URL, invokes the yt-dlp/extractor integration to inspect available media, creates `DownloadTask` records, and executes/downloads while exposing progress to the UI. `lib/core/services/ytdlp_service.dart` is the external-engine adapter; `lib/core/services/download_service.dart` coordinates transfer lifecycle; `lib/core/utils/download_filename.dart` and `lib/core/utils/media_scanner.dart` handle output naming and device media visibility. yt-dlp provides multi-site extraction, while FFmpeg is an expected multimedia-processing dependency.

#### Persistence and Recovery
Download history is local SQLite managed through Drift. The schema/database layer is `lib/core/database/app_database.dart`; query and history-specific persistence are in `lib/core/database/download_history_dao.dart`; generated Drift bindings are checked in as `lib/core/database/app_database.g.dart`. `lib/core/services/history_service.dart` bridges persisted history to task restoration, deduplication, retry, and file actions after application restart.

#### Authentication, Files, and Device Services
Cookie storage/import and custom request identity are handled behind `lib/core/services/cookie_service.dart`, supporting Netscape-format cookies for authenticated extraction. Settings may launch embedded platform logins via `lib/features/settings/bilibili_login_page.dart` and `lib/features/settings/webview_login_page.dart`. Platform boundaries—permissions, external file opening/sharing, and notifications—are isolated in `lib/core/utils/permission_helper.dart`, `lib/core/utils/file_opener.dart`, and `lib/core/services/notification_service.dart`.

#### Platform and Release Infrastructure
The Android project supplies manifests, network/file-provider policy, and the bundled native downloader: `android/app/src/main/AndroidManifest.xml`, `android/app/src/main/res/xml/network_security_config.xml`, `android/app/src/main/res/xml/file_paths.xml`. Windows is a conventional Flutter desktop host under `windows/runner/main.cpp`. Update checks are encapsulated in `lib/core/services/app_update_service.dart`, likely consuming release infrastructure rather than being part of download execution. CI build automation is defined in `.github/workflows/build.yml`.

Main entry points: [`lib/core/providers/service_providers.dart`](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/providers/service_providers.dart) (Riverpod boundary), [`lib/core/services/download_service.dart`](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/download_service.dart) (Download coordinator), [`lib/features/download/downloads_page.dart`](https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/download/downloads_page.dart) (Download workflow), [`lib/core/services/history_service.dart`](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/history_service.dart) (History recovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter client"]
  node_entry(("App entry<br/>Dart bootstrap<br/>[main.dart]"))
  node_download_ui["Download workflow<br/>feature UI"]
  node_add_url["URL parser dialog<br/>feature UI"]
  node_history_ui["History page<br/>feature UI<br/>[history_page.dart]"]
  node_settings_ui["Settings &amp; login<br/>feature UI<br/>[settings_page.dart]"]
  node_task_widgets["Task presentation<br/>shared widgets<br/>[task_widgets.dart]"]
  node_providers{{"Riverpod boundary<br/>providers"}}
  node_domain_models["Tasks &amp; media metadata<br/>domain models<br/>[download_task.dart]"]
end

subgraph group_pipeline["Download pipeline"]
  node_download_service["Download coordinator"]
  node_ytdlp{{"yt-dlp adapter<br/>engine adapter<br/>[ytdlp_service.dart]"}}
  node_output_handling["Output &amp; media scan<br/>device utilities"]
end

subgraph group_storage["Persistence &amp; device"]
  node_history_service["History recovery"]
  node_history_dao["History DAO<br/>Drift DAO"]
  node_database[("SQLite database<br/>Drift database<br/>[app_database.dart]")]
  node_cookies["Cookie service<br/>authentication service"]
  node_device_services["Notifications &amp; file actions<br/>platform services"]
end

subgraph group_platform["Platform &amp; release"]
  node_native_ytdlp{{"Bundled yt-dlp<br/>native executable"}}
  node_android_host["Android host &amp; policy<br/>Android integration"]
  node_windows_host["Windows host<br/>desktop runner<br/>[main.cpp]"]
  node_updates["Update checks<br/>release service"]
  node_ci["Build CI<br/>GitHub Actions<br/>[build.yml]"]
end

node_entry -->|"initializes"| node_providers
node_entry -->|"renders"| node_download_ui
node_download_ui -->|"opens"| node_add_url
node_download_ui -->|"uses"| node_task_widgets
node_history_ui -->|"uses"| node_task_widgets
node_download_ui -->|"consumes state"| node_providers
node_history_ui -->|"consumes state"| node_providers
node_settings_ui -->|"consumes state"| node_providers
node_providers -->|"provides"| node_download_service
node_providers -->|"provides"| node_history_service
node_providers -->|"provides"| node_cookies
node_providers -->|"provides"| node_updates
node_download_service -->|"creates and updates"| node_domain_models
node_download_service -->|"extracts and downloads"| node_ytdlp
node_download_service -->|"writes output"| node_output_handling
node_download_service -->|"persists lifecycle"| node_history_service
node_download_service -->|"reports completion"| node_device_services
node_ytdlp -->|"uses authenticated requests"| node_cookies
node_ytdlp -->|"invokes on Android"| node_native_ytdlp
node_history_service -->|"queries and saves"| node_history_dao
node_history_dao -->|"reads and writes"| node_database
node_history_ui -->|"retries and opens files"| node_history_service
node_android_host -->|"embeds Flutter"| node_entry
node_ci -->|"builds"| node_android_host
node_ci -->|"builds"| node_windows_host

click node_entry "https://github.com/autsunset/vidbee_flutter/blob/main/lib/main.dart"
click node_download_ui "https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/download/downloads_page.dart"
click node_add_url "https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/download/add_url_dialog.dart"
click node_history_ui "https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/history/history_page.dart"
click node_settings_ui "https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/settings/settings_page.dart"
click node_task_widgets "https://github.com/autsunset/vidbee_flutter/blob/main/lib/shared/widgets/task_widgets.dart"
click node_providers "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/providers/service_providers.dart"
click node_domain_models "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/models/download_task.dart"
click node_download_service "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/download_service.dart"
click node_ytdlp "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/ytdlp_service.dart"
click node_native_ytdlp "https://github.com/autsunset/vidbee_flutter/tree/main/android/app/src/main/res/raw/ytdlp"
click node_output_handling "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/utils/download_filename.dart"
click node_history_service "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/history_service.dart"
click node_history_dao "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/database/download_history_dao.dart"
click node_database "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/database/app_database.dart"
click node_cookies "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/cookie_service.dart"
click node_device_services "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/notification_service.dart"
click node_android_host "https://github.com/autsunset/vidbee_flutter/blob/main/android/app/src/main/AndroidManifest.xml"
click node_windows_host "https://github.com/autsunset/vidbee_flutter/blob/main/windows/runner/main.cpp"
click node_updates "https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/app_update_service.dart"
click node_ci "https://github.com/autsunset/vidbee_flutter/blob/main/.github/workflows/build.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_download_ui,node_add_url,node_history_ui,node_settings_ui,node_task_widgets,node_providers,node_domain_models toneBlue
class node_download_service,node_ytdlp,node_output_handling toneAmber
class node_history_service,node_history_dao,node_database,node_cookies,node_device_services toneMint
class node_native_ytdlp,node_android_host,node_windows_host,node_updates,node_ci toneRose
```

## Components

### Flutter client

- [App entry](https://github.com/autsunset/vidbee_flutter/blob/main/lib/main.dart): Dart bootstrap · `lib/main.dart`
- [Download workflow](https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/download/downloads_page.dart): feature UI · Adds URLs, selects formats, and manages active tasks. · `lib/features/download/downloads_page.dart`
- [URL parser dialog](https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/download/add_url_dialog.dart): feature UI · `lib/features/download/add_url_dialog.dart`
- [History page](https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/history/history_page.dart): feature UI · `lib/features/history/history_page.dart`
- [Settings & login](https://github.com/autsunset/vidbee_flutter/blob/main/lib/features/settings/settings_page.dart): feature UI · Settings, cookie controls, and embedded login flows. · `lib/features/settings/settings_page.dart`
- [Task presentation](https://github.com/autsunset/vidbee_flutter/blob/main/lib/shared/widgets/task_widgets.dart): shared widgets · `lib/shared/widgets/task_widgets.dart`
- [Riverpod boundary](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/providers/service_providers.dart): providers · Wires UI state to application services. · `lib/core/providers/service_providers.dart`
- [Tasks & media metadata](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/models/download_task.dart): domain models · Download lifecycle plus video and playlist records. · `lib/core/models/download_task.dart`

### Download pipeline

- [Download coordinator](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/download_service.dart): service · Creates tasks and manages transfer lifecycle. · `lib/core/services/download_service.dart`
- [yt-dlp adapter](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/ytdlp_service.dart): engine adapter · Inspects media and invokes the external extractor. · `lib/core/services/ytdlp_service.dart`
- [Output & media scan](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/utils/download_filename.dart): device utilities · Names files and exposes completed media to the device. · `lib/core/utils/download_filename.dart`

### Persistence & device

- [History recovery](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/history_service.dart): service · Restores, deduplicates, retries, and acts on saved tasks. · `lib/core/services/history_service.dart`
- [History DAO](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/database/download_history_dao.dart): Drift DAO · `lib/core/database/download_history_dao.dart`
- [SQLite database](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/database/app_database.dart): Drift database · `lib/core/database/app_database.dart`
- [Cookie service](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/cookie_service.dart): authentication service · Imports and stores Netscape-format cookies. · `lib/core/services/cookie_service.dart`
- [Notifications & file actions](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/notification_service.dart): platform services · Permissions, file opening/sharing, and completion notifications. · `lib/core/services/notification_service.dart`

### Platform & release

- [Bundled yt-dlp](https://github.com/autsunset/vidbee_flutter/tree/main/android/app/src/main/res/raw/ytdlp): native executable · `android/app/src/main/res/raw/ytdlp`
- [Android host & policy](https://github.com/autsunset/vidbee_flutter/blob/main/android/app/src/main/AndroidManifest.xml): Android integration · Flutter host, manifest, and network/file-provider policy. · `android/app/src/main/AndroidManifest.xml`
- [Windows host](https://github.com/autsunset/vidbee_flutter/blob/main/windows/runner/main.cpp): desktop runner · `windows/runner/main.cpp`
- [Update checks](https://github.com/autsunset/vidbee_flutter/blob/main/lib/core/services/app_update_service.dart): release service · `lib/core/services/app_update_service.dart`
- [Build CI](https://github.com/autsunset/vidbee_flutter/blob/main/.github/workflows/build.yml): GitHub Actions · `.github/workflows/build.yml`

## Connections

- App entry → Riverpod boundary: initializes
- App entry → Download workflow: renders
- Download workflow → URL parser dialog: opens
- Download workflow → Task presentation: uses
- History page → Task presentation: uses
- Download workflow → Riverpod boundary: consumes state
- History page → Riverpod boundary: consumes state
- Settings & login → Riverpod boundary: consumes state
- Riverpod boundary → Download coordinator: provides
- Riverpod boundary → History recovery: provides
- Riverpod boundary → Cookie service: provides
- Riverpod boundary → Update checks: provides
- Download coordinator → Tasks & media metadata: creates and updates
- Download coordinator → yt-dlp adapter: extracts and downloads
- Download coordinator → Output & media scan: writes output
- Download coordinator → History recovery: persists lifecycle
- Download coordinator → Notifications & file actions: reports completion
- yt-dlp adapter → Cookie service: uses authenticated requests
- yt-dlp adapter → Bundled yt-dlp: invokes on Android
- History recovery → History DAO: queries and saves
- History DAO → SQLite database: reads and writes
- History page → History recovery: retries and opens files
- Android host & policy → App entry: embeds Flutter
- Build CI → Android host & policy: builds
- Build CI → Windows host: builds
