How crackededed/xtra works
Based on your project’s file tree and README, you are working with Xtra for Twitch – an Android application that provides a Twitch player and browser. The application is clearly segmented using standard Android architectural patterns, likely favoring an MVVM (Model-View-ViewModel) style with data repositories, dependency injection, and separate API and database layers.
Main Components
a. User Interface (UI) Layer:
• Android Activities and Fragments (e.g., LoginActivity, MainActivity; numerous Fragments for chat, clips, streams, media viewing, settings, etc.).
• Custom UI components and views (e.g., CustomPlayerView, SliderLayout, and various custom adapters for lists and navigation).
b. Presentation/Logic Layer:
• ViewModels for each UI section (e.g., MainViewModel, ChatViewModel, PlayerViewModel) that manage state and business logic.
• UI adapters and controllers that mediate between views and models.
c. Data Repository Layer:
• Repository classes (e.g., ApiRepository, AuthRepository, GraphQLRepository) that abstract data fetching and manipulation.
• Data sources under the “datasource” package that likely separate network data from local database fetches.
d. Network/API Layer:
• API integrations with Twitch using GraphQL and REST endpoints (e.g., GraphQLApi, HelixApi, IdApi, UsherApi).
• GraphQL query files utilized for fetching Twitch data (media, user details, streams, chat info, etc.).
• External WebSocket and HTTP clients for real-time chat or live notifications (e.g., ChatReadWebSocket, EventSubWebSocket).
e. Local Persistence Layer:
• SQLite/Room-based database (evident from the “db” package, DAOs such as BookmarksDao, LocalFollowChannelDao, and the AppDatabase definition).
• Migration schemas in the “schemas” directory, showing different database version files.
f. Dependency Injection Configuration:
• DI modules (DatabaseModule, XtraModule) defining how dependencies are provided throughout the app.
g. Media Playback & Downloading:
• Player and download components including workers like VideoDownloadWorker and classes under the “player” package to manage low latency streaming and player settings.
• Integration with HLS playlist parsing (HlsPlaylistParser) and m3u8 utilities for streaming.
h. External Services & Libraries:
• External libraries like Glide (XtraGlideModule) and Coil for image caching.
• Integration with fastlane (for release metadata) which suggests CI/CD deployment flows (reflected in the .github/workflows/android.yml).
Relationships and Interactions
• UI components invoke ViewModels that, in turn, interact with the Repository layer.
• The Repository layer aggregates data from the Network/API/GraphQL sources and the Local Persistence (DAOs/Database).
• API layer components interact with external Twitch services using GraphQL queries and REST endpoints.
• Dependency injection spans across all layers ensuring that repositories, network clients, and data sources are correctly provided.
• Worker processes ( download workers, live notification worker) operate in the background to handle asynchronous tasks and notifications.
Architectural Patterns
• MVVM Pattern: Clearly visible with Activities/Fragments, ViewModels (managing UI-specific logic), and repositories handling data.
• Repository Pattern: Repositories abstract both remote and local data sources.
• Dependency Injection: DI modules streamline the provisioning and management of dependencies.
• Separation of Concerns: Distinct packages for API, db, models, ui, and utilities ensure that business logic, UI, and data are decoupled.
Relevant Technologies
• Android SDK and Android Architecture Components (LiveData, ViewModel).
• GraphQL via the defined *.graphql files for backend querying.
• Room/SQLite for database persistence.
• Gradle for builds (build.gradle.kts) and fastlane for deployment automation.
• External libraries (Glide, Coil, m3u8 processing utilities).
Elements
• UI components → ViewModels → Repositories.
• Repositories breaking into branches for "Remote API" (GraphQL/Helix) and "Local Database" (DAOs/Room).
• Dependency injection wiring between modules.
• Background processing components (DownloadWorker, NotificationWorker) interacting with both repositories and service endpoints.