# xiaye13579/bbll architecture

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

- Interactive diagram: https://gitdiagram.com/xiaye13579/bbll
- Repository: https://github.com/xiaye13579/bbll

## Overview

##### Project type and purpose
- From the README, BBLL is a third-party Android TV client for Bilibili. It wraps Bilibili’s public API for video browsing, searching, playback, and user‐interaction features (tabs, favorites, history). It also integrates Firebase/AppCenter for analytics and crash reporting.

##### (implied) file structure
- Although only README.md was provided, a typical Android project will have:
- an “app” module under which there are:
– src/main/java/… (packages for UI, viewmodels, repositories, data sources)
– src/main/res/… (layouts, drawables, strings)
– AndroidManifest.xml
- build.gradle files (project and module)
- settings.gradle (module inclusion)
- gradle.properties, proguard rules, local.properties

##### README insights
- Features: video listing, playback (hardware decoding via ExoPlayer), refresh, tab navigation, remote control support, two APK flavors (release for API ≥21, api19 for Android 4.4).
- External services: Bilibili Official API, Firebase (analytics, device info), AppCenter (crash logs, distribution).

a. Main components
- Presentation Layer: Activities / Fragments / Android TV Leanback UI / ViewModels
- Domain Layer: business logic and use-cases (e.g., FetchVideoList, SearchVideos)
- Data Layer:
– Remote DataSource (Retrofit/Gson wrappers around Bilibili API)
– Local DataSource (optional cache or Room DB for history/favorites)
- Video Player: ExoPlayer module
- External Services:
– Bilibili API (cloud endpoint)
– Firebase Analytics & Crashlytics
– AppCenter Crash & Distribution
- Build & Distribution: Gradle build, flavors (api19, release)

b. Relationships and data flows
1. User interacts via Remote Control → UI Layer (Activity/Fragment)
2. UI calls corresponding ViewModel function
3. ViewModel invokes Domain UseCase
4. UseCase calls Repository
5. Repository chooses DataSource:
– RemoteDataSource → Retrofit → Bilibili API → returns JSON
– (Optional) LocalCache → Room
6. Data flows back up to ViewModel → UI observes LiveData/Flow → renders lists or details
7. Playback: UI launches ExoPlayer with video URL from Repository
8. Analytics / Crash reports: all layers hook into Firebase/AppCenter SDKs for events & crashes

c. Architectural patterns / design principles
- MVVM (View ↔ ViewModel ↔ Model)
- Clean architecture / layered separation (presentation, domain, data)
- Feature-based modules or packaged by layer
- Dependency injection (e.g., Dagger/Hilt or Koin) for decoupling
- Build flavors for API compatibility

d. Key technologies and libraries
- Android Jetpack: ViewModel, LiveData / Flow, Room (if used)
- Retrofit + Gson/Moshi for networking
- ExoPlayer for hardware-accelerated video playback
- Firebase Analytics & Crashlytics
- Microsoft AppCenter SDK
- Dagger/Hilt or Koin (DI)
- Gradle build scripts & flavors

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UI["Activities / Fragments / Leanback UI"]:::frontend
        VM["VideoListViewModel"]:::frontend
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        UC["UseCases<br/>(FetchVideoList, SearchVideos)"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Repo["Repository"]:::data
        RemoteDS["RemoteDataSource<br/>(Retrofit/Gson)"]:::data
        LocalDS["LocalDataSource<br/>(Room DB)"]:::data
        ExoPlayer["ExoPlayerManager"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        API["Bilibili API<br/>(Cloud Endpoint)"]:::external
        Firebase["Firebase Analytics & Crashlytics"]:::external
        AppCenter["AppCenter Crash & Distribution"]:::external
    end

    %% Build & Distribution
    subgraph "Build & Distribution"
        direction TB
        Gradle["Gradle Build"]:::infra
        Flavor1["Flavor: release (API ≥21)"]:::infra
        Flavor2["Flavor: api19 (Android 4.4)"]:::infra
    end

    %% Flow Relationships
    UI -->|"calls"| VM
    VM -->|"invokes"| UC
    UC -->|"uses"| Repo
    Repo -->|"fetchRemote"| RemoteDS
    Repo -->|"fetchLocal"| LocalDS
    RemoteDS -->|"HTTP JSON"| API
    UI -->|"playVideo"| ExoPlayer

    %% Analytics / Crash Reporting (dashed)
    VM -.->|"log events"| Firebase
    VM -.->|"log events"| AppCenter
    ExoPlayer -.->|"log events"| Firebase
    ExoPlayer -.->|"log events"| AppCenter
    RemoteDS -.->|"log errors"| Firebase
    RemoteDS -.->|"log errors"| AppCenter

    %% Build flows
    Gradle --> Flavor1
    Gradle --> Flavor2

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef domain fill:#E6F4EA,stroke:#1B7A3E,color:#1B7A3E
    classDef data fill:#FFF4E5,stroke:#D9822B,color:#D9822B
    classDef external fill:#F0F0F0,stroke:#888888,color:#555555,stroke-dasharray:0
    classDef infra fill:#F3E8FF,stroke:#7D3FBF,color:#7D3FBF
```
