# frostnova721/animestream architecture

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

- Interactive diagram: https://gitdiagram.com/frostnova721/animestream
- Repository: https://github.com/frostnova721/animestream

## Overview

##### Project Type and Purpose
- This is a cross-platform Flutter application (“animestream”) for streaming and downloading anime, with built-in tracking via third-party anime databases (Anilist, MAL, Simkl).
- It targets Android, iOS, Web, Windows, macOS, and Linux using a single Dart/Flutter codebase + platform embedder code (Kotlin/Java for Android, Swift for iOS/macOS, C++/CMake for desktop, HTML/CSS/JS for Web).

##### File-Structure Analysis & Architectural Patterns
- Top-Level:
- android/, ios/, macos/, linux/, windows/, web/ – Flutter embedder and native platform code
- lib/ – Dart code, subdivided into:
– core/ – domain-level logic (download manager, extractors, providers, data & database handlers, news, app versioning)
– ui/ – presentation layer (widgets, pages, models, theme, assets)
– main.dart – application entrypoint
- pubspec.yaml / buildscripts – dependency & build configuration
- test/ – widget tests
- Architectural Pattern:
- Presentation layer uses Provider-style dependency injection (ui/models/providers).
- Domain layer in core/ separates business logic (downloadManager, providerManager, extractors) from data access.
- Data layer uses Hive (local NoSQL), secureStorage, and HTTP/GraphQL handlers for Anilist, MAL, Simkl.

##### Key Components
A. Flutter Engine & Embedder
B. Presentation Layer (UI)
- Pages (home, discover, info, watch, downloads, settings)
- Widgets (cards, controls, subtitle viewer, bottom sheets)
- Theme management
C. State Management / Provider Layer
- Provider instances (playerProvider, themeProvider, infoProvider, etc.)
- They act as controllers binding UI → domain
D. Domain / Core Logic
- Download Manager: handles stream extraction, file writes, progress events
- Extractors & Providers: anime source plugins (kwik, streamwish, AnimePahe, etc.)
- News module for fetching Anime news
- App runtime (version checking, updates)
E. Data Access Layer
- HTTP / GraphQL clients for Anilist, MAL, Simkl
- Secure storage for sensitive data (tokens)
F. External Services
- Anime streaming hosts (via plugins)
- Tracking APIs (Anilist GraphQL, MAL API, Simkl API)
- Subtitle parsers for SRT, ASS, VTT
G. File System
- Downloaded video files saved on device storage
- Persistent caches & config files

##### Relationships & Data Flows
- UI → Provider → Core Logic → Data Access → External Service → Core Logic → Provider → UI
- Download Flow: UI (download page) triggers Download Manager → Extractor plugin retrieves stream URL → DownloadManager writes to FS → signals progress back up
- Tracking Flow: UI triggers “mark as watched” → GraphQL client sends mutation to Anilist/MAL/Simkl → updates hive database for offline sync → Provider updates UI
- Settings Flow: UI toggles setting → Preferences module writes to Hive/SecureStorage → Provider notifies UI

##### Architectural Patterns & Principles
- Layered architecture: Presentation / State / Domain / Data / Infrastructure
- Plugin pattern for providers & extractors – easy to register new anime sources
- Repository/Data Access abstraction for external APIs
- Provider / Dependency Injection for decoupling UI from business logic

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Platform Embedder"
        AndroidEng["Android Embedder (MainActivity.kt)"]:::platform
        AndroidMulti["Android Embedder (FlutterMultiDexApplication.java)"]:::platform
        iOS["iOS Embedder (AppDelegate.swift)"]:::platform
        macOS["macOS Embedder (AppDelegate.swift)"]:::platform
        LinuxMain["Linux Embedder (main.cc)"]:::platform
        LinuxReg["Linux Embedder (generated_plugin_registrant.cc)"]:::platform
        WinMain["Windows Embedder (main.cpp)"]:::platform
        WinReg["Windows Embedder (generated_plugin_registrant.cc)"]:::platform
        WebEng["Web Embedder (index.html)"]:::platform
    end

    FlutterEngine["Flutter Engine"]:::platform

    AndroidEng --> FlutterEngine
    AndroidMulti --> FlutterEngine
    iOS --> FlutterEngine
    macOS --> FlutterEngine
    LinuxMain --> FlutterEngine
    LinuxReg --> FlutterEngine
    WinMain --> FlutterEngine
    WinReg --> FlutterEngine
    WebEng --> FlutterEngine

    subgraph "Flutter App"
        subgraph "Presentation Layer"
            UIPages["UI Pages"]:::presentation
            UIWidgets["UI Widgets"]:::presentation
            UITheme["Theme Management"]:::presentation
        end
        subgraph "State Management"
            Providers["Providers"]:::state
        end
        subgraph "Domain Layer"
            DownloadMgr["Download Manager"]:::domain
            Extractors["Extractors"]:::domain
            ProviderPlugins["Provider Plugins"]:::domain
            NewsMod["News Module"]:::domain
            AppRuntime["App Runtime & Versioning"]:::domain
            SubtitlePars["Subtitle Parsers"]:::domain
        end
        subgraph "Data Access Layer"
            HiveStorage["Hive & Preferences & SecureStorage"]:::data
            AniClient["Anilist Client"]:::data
            MALClient["MAL Client"]:::data
            SimklClient["Simkl Client"]:::data
            DBHandler["DB Handler & Sync"]:::data
        end
        FileSystem["File System"]:::data
    end

    subgraph "External Services"
        AnimeHosts["Anime Hosts"]:::external
        TrackingAPIs["Tracking APIs (Anilist/MAL/Simkl)"]:::external
    end

    FlutterEngine --> UIPages
    FlutterEngine --> UIWidgets
    FlutterEngine --> UITheme

    UIPages --> Providers
    UIWidgets --> Providers
    UITheme --> Providers

    Providers --> DownloadMgr
    Providers --> ProviderPlugins
    Providers --> NewsMod
    Providers --> AppRuntime
    Providers --> SubtitlePars

    DownloadMgr --> Extractors
    DownloadMgr --> FileSystem
    DownloadMgr --> DBHandler

    Extractors --> AnimeHosts
    ProviderPlugins --> AnimeHosts

    NewsMod --> TrackingAPIs
    TrackingAPIs --> AniClient
    TrackingAPIs --> MALClient
    TrackingAPIs --> SimklClient

    AppRuntime --> DBHandler
    DBHandler --> HiveStorage
    AniClient --> DBHandler
    MALClient --> DBHandler
    SimklClient --> DBHandler
    HiveStorage --> Providers

    SubtitlePars --> DownloadMgr

    click AndroidEng "https://github.com/frostnova721/animestream/blob/master/android/app/src/main/kotlin/app/animestream/MainActivity.kt"
    click AndroidMulti "https://github.com/frostnova721/animestream/blob/master/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java"
    click iOS "https://github.com/frostnova721/animestream/blob/master/ios/Runner/AppDelegate.swift"
    click macOS "https://github.com/frostnova721/animestream/blob/master/macos/Runner/AppDelegate.swift"
    click LinuxMain "https://github.com/frostnova721/animestream/blob/master/linux/main.cc"
    click LinuxReg "https://github.com/frostnova721/animestream/blob/master/linux/flutter/generated_plugin_registrant.cc"
    click WinMain "https://github.com/frostnova721/animestream/blob/master/windows/runner/main.cpp"
    click WinReg "https://github.com/frostnova721/animestream/blob/master/windows/flutter/generated_plugin_registrant.cc"
    click WebEng "https://github.com/frostnova721/animestream/blob/master/web/index.html"

    click UIPages "https://github.com/frostnova721/animestream/tree/master/lib/ui/pages/"
    click UIWidgets "https://github.com/frostnova721/animestream/tree/master/lib/ui/models/widgets/"
    click UITheme "https://github.com/frostnova721/animestream/tree/master/lib/ui/theme/"

    click Providers "https://github.com/frostnova721/animestream/tree/master/lib/ui/models/providers/"

    click DownloadMgr "https://github.com/frostnova721/animestream/blob/master/lib/core/anime/downloader/downloadManager.dart"
    click Extractors "https://github.com/frostnova721/animestream/tree/master/lib/core/anime/extractors/"
    click ProviderPlugins "https://github.com/frostnova721/animestream/tree/master/lib/core/anime/providers/"
    click NewsMod "https://github.com/frostnova721/animestream/blob/master/lib/core/news/animenews.dart"
    click AppRuntime "https://github.com/frostnova721/animestream/blob/master/lib/core/app/runtimeDatas.dart"
    click AppRuntime "https://github.com/frostnova721/animestream/blob/master/lib/core/app/update.dart"
    click AppRuntime "https://github.com/frostnova721/animestream/blob/master/lib/core/app/version.dart"
    click SubtitlePars "https://github.com/frostnova721/animestream/tree/master/lib/core/commons/subtitleParsers/"

    click HiveStorage "https://github.com/frostnova721/animestream/blob/master/lib/core/data/hive.dart"
    click HiveStorage "https://github.com/frostnova721/animestream/blob/master/lib/core/data/preferences.dart"
    click HiveStorage "https://github.com/frostnova721/animestream/blob/master/lib/core/data/secureStorage.dart"

    click AniClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/anilist/queries.dart"
    click AniClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/anilist/mutations.dart"
    click AniClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/anilist/login.dart"

    click MALClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/mal/mal.dart"
    click MALClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/mal/mutations.dart"
    click MALClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/mal/login.dart"

    click SimklClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/simkl/simkl.dart"
    click SimklClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/simkl/mutations.dart"
    click SimklClient "https://github.com/frostnova721/animestream/blob/master/lib/core/database/simkl/login.dart"

    click DBHandler "https://github.com/frostnova721/animestream/blob/master/lib/core/database/handler/handler.dart"
    click DBHandler "https://github.com/frostnova721/animestream/blob/master/lib/core/database/handler/syncHandler.dart"

    classDef presentation fill:#a8e6cf,stroke:#2e7d32,color:#000
    classDef state fill:#81d4fa,stroke:#0277bd,color:#000
    classDef domain fill:#ffcc80,stroke:#ef6c00,color:#000
    classDef data fill:#ce93d8,stroke:#6a1b9a,color:#000
    classDef external fill:#ff8a80,stroke:#c62828,color:#000
    classDef platform fill:#cfd8dc,stroke:#455a64,color:#000
```
