# sle2p/anich architecture

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

- Interactive diagram: https://gitdiagram.com/sle2p/anich
- Repository: https://github.com/sle2p/anich

## Overview

##### Project type and purpose
- From the README and directory layout, AniCh is a cross-platform Flutter client app for browsing, playing, and managing online anime (“番剧”) with ultra-resolution (“超分辨率”) video and multi-source danmaku support. It targets Android, iOS, Web, Windows, macOS, and Linux.

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” directories: platform embeddings for Flutter.
- “lib/main.dart”: application entry point.
- “lib/src/pages” & “lib/src/widgets”: UI layer, organized by feature.
- “lib/src/apis” & “lib/protobuf”: data layer, API clients generated from .proto definitions.
- “lib/src/middlewares”, “lib/src/utils”, “lib/src/config.dart”: cross-cutting infrastructure (authentication, logging, global config).
- “lib/src/pages/*/controller.dart”: state-management/controllers per feature (MVC or MVVM style).
- “lib/src/pages/*/models” & “lib/src/pages/*/views”: domain models and view widgets.
- “lib/src/pages/*/storage”: persistent local storage for settings, play history, user data.

##### README for additional insights
- Key features: super-resolution video, offline cache, multiple danmaku sources, search, bookmarking, comments.
- No backend code here—app relies on remote HTTP/gRPC API defined via protobuf.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter Application
    subgraph "Flutter App"
        subgraph "UI Layer"
            Main["lib/main.dart"]:::bootstrap
            Pages["Pages"]:::ui
            Widgets["Widgets"]:::ui
        end
        subgraph "Business Logic"
            Router["Router (lib/src/router.dart)"]:::logic
            Controllers["Feature Controllers"]:::logic
        end
        subgraph "Data Layer"
            APIs["API Clients"]:::data
            Protobuf["Protobuf Models"]:::data
            Middlewares["Middlewares & Config"]:::infrastructure
        end
        subgraph "Local Persistence"
            LocalStorage["Local Storage"]:::storage
        end
        subgraph "Video Player Subsystem"
            PlayerController["Player Controller"]:::logic
            PlayerWidget["Player Widget"]:::ui
        end
    end

    %% Platform Embedding
    subgraph "Platform Embedding"
        Android["Android Embedding"]:::native
        iOS["iOS Embedding"]:::native
        Windows["Windows Embedding"]:::native
        macOS["macOS Embedding"]:::native
        Linux["Linux Embedding"]:::native
        WebPlatform["Web Embedding"]:::native
    end

    %% External Backend
    subgraph "External Backend Services"
        CatalogAPI["Anime Catalog API"]:::external
        DanmakuAPI["Danmaku API"]:::external
        AuthAPI["Account & Auth API"]:::external
        ThreadAPI["Comments & Thread API"]:::external
    end

    %% Data Flows
    Main -->|"initialization"| Pages
    Main -->|"initialization"| Widgets
    Pages -->|"user events"| Controllers
    Widgets -->|"controls & views"| Controllers
    Controllers -->|"invoke API"| APIs
    APIs -->|"gRPC/HTTP"| CatalogAPI
    APIs -->|"gRPC/HTTP"| DanmakuAPI
    APIs -->|"gRPC/HTTP"| AuthAPI
    APIs -->|"gRPC/HTTP"| ThreadAPI
    Controllers -->|"read/write"| LocalStorage
    PlayerWidget <-->|"render & commands"| PlayerController
    PlayerController -->|"native codecs"| Android
    PlayerController -->|"native codecs"| iOS
    PlayerController -->|"native codecs"| Windows
    PlayerController -->|"native codecs"| macOS
    PlayerController -->|"native codecs"| Linux
    PlayerController -->|"native codecs"| WebPlatform

    %% Component Dependencies
    Protobuf --> APIs
    Middlewares --> APIs
    Router --> Pages
    Router --> Controllers

    %% Click Events
    click Main "https://github.com/sle2p/anich/blob/main/lib/main.dart"
    click Pages "https://github.com/sle2p/anich/tree/main/lib/src/pages"
    click Widgets "https://github.com/sle2p/anich/tree/main/lib/src/widgets"
    click Router "https://github.com/sle2p/anich/blob/main/lib/src/router.dart"
    click APIs "https://github.com/sle2p/anich/blob/main/lib/src/apis/account.dart"
    click APIs "https://github.com/sle2p/anich/blob/main/lib/src/apis/bangumi.dart"
    click APIs "https://github.com/sle2p/anich/blob/main/lib/src/apis/search.dart"
    click APIs "https://github.com/sle2p/anich/blob/main/lib/src/apis/thread.dart"
    click Protobuf "https://github.com/sle2p/anich/tree/main/lib/protobuf"
    click Middlewares "https://github.com/sle2p/anich/blob/main/lib/src/middlewares/auth.dart"
    click Middlewares "https://github.com/sle2p/anich/blob/main/lib/src/config.dart"
    click LocalStorage "https://github.com/sle2p/anich/blob/main/lib/src/pages/settings/storage/account_storage.dart"
    click LocalStorage "https://github.com/sle2p/anich/blob/main/lib/src/pages/settings/storage/play_history_storage.dart"
    click LocalStorage "https://github.com/sle2p/anich/blob/main/lib/src/pages/settings/storage/theme_storage.dart"
    click LocalStorage "https://github.com/sle2p/anich/blob/main/lib/src/pages/bangumi_collection/models/bangumi_collection_model.dart"
    click PlayerController "https://github.com/sle2p/anich/blob/main/lib/src/widgets/player/controller.dart"
    click PlayerWidget "https://github.com/sle2p/anich/blob/main/lib/src/widgets/player/controls.dart"
    click Android "https://github.com/sle2p/anich/blob/main/android/app/src/main/kotlin/cx/xs/open/MainActivity.kt"
    click iOS "https://github.com/sle2p/anich/blob/main/ios/Runner/AppDelegate.swift"
    click Windows "https://github.com/sle2p/anich/blob/main/windows/runner/flutter_window.cpp"
    click Windows "https://github.com/sle2p/anich/blob/main/windows/runner/main.cpp"
    click macOS "https://github.com/sle2p/anich/blob/main/macos/Runner/AppDelegate.swift"
    click Linux "https://github.com/sle2p/anich/blob/main/linux/main.cc"
    click WebPlatform "https://github.com/sle2p/anich/blob/main/web/index.html"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#4A90E2,color:#000;
    classDef logic fill:#DFF2BF,stroke:#4F8A10,color:#000;
    classDef data fill:#FFE4B5,stroke:#E69138,color:#000;
    classDef infrastructure fill:#F0F0F0,stroke:#999,color:#000;
    classDef storage fill:#FFF2CC,stroke:#D6B656,color:#000;
    classDef bootstrap fill:#E1D5E7,stroke:#9673A6,color:#000;
    classDef native fill:#E8E8E8,stroke:#A9A9A9,color:#000;
    classDef external fill:#F4CCCC,stroke:#CC0000,color:#000;
```
