# tommyxchow/frosty architecture

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

- Interactive diagram: https://gitdiagram.com/tommyxchow/frosty
- Repository: https://github.com/tommyxchow/frosty

## Overview

##### Project Type and Purpose
- This is a cross-platform mobile and web application built with Flutter. Its purpose is to serve as an alternative Twitch client that supports third-party emotes (7TV, BetterTTV, and FrankerFaceZ) and offers rich, interactive chat features along with live stream browsing.
- The README emphasizes its features for enhanced chat readability, state management with MobX, and integration with several external APIs (Twitch, 7TV, BTTV, FFZ).

##### Main Components
- Platforms:
– Mobile Platforms: Android and iOS. (Separate directories with native configurations such as Gradle, Xcode projects, and Fastlane for deployments.)
– Web Platform: A web version built likely using Next.js (observed in the web folder with components, pages, and assets).
- Core Flutter Application: Located in the lib folder, which includes:
– UI Screens and Widgets: Organized by functional areas (home, channel, chat, video, onboarding, settings, etc.)
– Business Logic and State Management: MobX stores and corresponding generated files (.g.dart) are used across screens.
– API Clients: Under lib/apis for interfacing with external services (Twitch, BTTV, 7TV, FFZ).
– Domain Models: In lib/models, holding key entities like channel, user, stream, badges, etc.
- External Services and Integrations:
– Twitch Developer API (clientId/secret configuration via dart-define)
– Third-party emote services (7TV, BTTV, FFZ)
– Firebase (firebase_options.dart and firebase_app_id_file.json in iOS)
- CI/CD and Deployment Automation:
– GitHub workflows (.github/workflows) for CI, pull request checks, release management, etc.
– Fastlane configurations for both Android and iOS in respective directories.
- Asset Management:
– Platform-specific asset management (Android’s res folder, iOS Assets.xcassets)

##### Relationships and Interactions
- UI Layer:
– Different screens/components (home, channel, chat, video, settings) interact with MobX stores.
– Widgets and dialogs receive data from stores, while also triggering actions.
- Business Logic and State Management:
– The MobX stores (in stores directories under each screen set) manage state changes and drive rebuilding of UI components.
- API Layer and External Communications:
– The lib/apis module communicates with Twitch and emote service endpoints.
– Data fetched from these APIs is transformed into domain models (from lib/models) and then propagated to the UI via MobX stores.
- Platform-Specific Integrations:
– Android and iOS projects contain native configuration files (e.g., google-services.json, Info.plist) that handle platform-specific services such as Firebase.
- Continuous Integration/Delivery:
– GitHub Actions run tests and builds as configured in .github/workflows.

##### Architectural Patterns and Technologies
- Layered/Clean Architecture:
– UI components, state management (MobX), and API/data layers are clearly separated.
- Reactive State Management:
– MobX is employed across the application to enable auto-updating of the UI upon state changes.
- Cross-Platform Best Practices:
– Shared business logic across mobile and (potentially) web with Flutter.
- Development Tooling:
– Integration with CI/CD pipelines via GitHub Actions and deployment automation tools (Fastlane).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        A["Android Client"]:::mobile
        I["iOS Client"]:::mobile
        W["Web Client"]:::web
    end

    %% Flutter Core Application
    FC["Flutter Core Application"]:::core

    A -->|"runs_on"| FC
    I -->|"runs_on"| FC
    W -->|"runs_on"| FC

    %% Core Modules
    subgraph "Core Modules"
        UI["UI Screens & Widgets"]:::core
        MobX["MobX State Management"]:::core
        API["API Clients"]:::core
        DM["Domain Models"]:::core
    end

    FC --> UI
    FC --> MobX
    FC --> API
    FC --> DM

    UI -->|"triggers_actions"| MobX
    MobX -->|"fetches_from"| API
    API -->|"maps_to"| DM
    MobX -->|"maps_to"| DM

    %% External Services
    API -->|"calls"| Twitch["Twitch API"]:::external
    API -->|"calls"| Emotes["7TV/BTTV/FFZ Services"]:::external

    subgraph "External Services"
        Firebase["Firebase"]:::external
    end

    A -->|"uses"| Firebase
    I -->|"uses"| Firebase

    %% CI/CD & Release Automation
    subgraph "CI/CD & Release Automation"
        GH["GitHub Actions"]:::cicd
        FA["Android Fastlane"]:::cicd
        FI["iOS Fastlane"]:::cicd
    end

    GH -->|"builds"| FC
    FA -->|"deploys_to"| A
    FI -->|"deploys_to"| I

    %% Asset Management
    subgraph "Asset Management"
        Shared["Shared Assets"]:::asset
        A_Assets["Android Assets"]:::asset
        I_Assets["iOS Assets"]:::asset
    end

    Shared -->|"used_by"| FC
    A_Assets -->|"used_by"| A
    I_Assets -->|"used_by"| I

    %% Click Events
    click A "https://github.com/tommyxchow/frosty/tree/main/android/"
    click I "https://github.com/tommyxchow/frosty/tree/main/ios/"
    click W "https://github.com/tommyxchow/frosty/tree/main/web/"
    click FC "https://github.com/tommyxchow/frosty/tree/main/lib/"
    click UI "https://github.com/tommyxchow/frosty/tree/main/lib/screens/"
    click MobX "https://github.com/tommyxchow/frosty/tree/main/lib/screens/*/stores/"
    click API "https://github.com/tommyxchow/frosty/tree/main/lib/apis/"
    click DM "https://github.com/tommyxchow/frosty/tree/main/lib/models/"
    click GH "https://github.com/tommyxchow/frosty/tree/main/.github/workflows/"
    click FA "https://github.com/tommyxchow/frosty/tree/main/android/fastlane/"
    click FI "https://github.com/tommyxchow/frosty/tree/main/ios/fastlane/"
    click Shared "https://github.com/tommyxchow/frosty/tree/main/assets/"
    click A_Assets "https://github.com/tommyxchow/frosty/tree/main/android/app/src/main/res/"
    click I_Assets "https://github.com/tommyxchow/frosty/tree/main/ios/Runner/Assets.xcassets/"

    %% Styles
    classDef mobile fill:#bbdefb,stroke:#0D47A1,stroke-width:2px;
    classDef web fill:#c8e6c9,stroke:#1B5E20,stroke-width:2px;
    classDef core fill:#fff9c4,stroke:#F57F17,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#D84315,stroke-width:2px;
    classDef cicd fill:#d1c4e9,stroke:#6A1B9A,stroke-width:2px;
    classDef asset fill:#f8bbd0,stroke:#AD1457,stroke-width:2px;
```
