# jakemiki/twitch-clip-queue architecture

> Architecture diagram of the GitHub repository jakemiki/twitch-clip-queue, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jakemiki/twitch-clip-queue
- Repository: https://github.com/jakemiki/twitch-clip-queue

## Overview

##### Main Components
- User Interface: Represent the UI layer where the primary React components reside. This includes:
- Core application container (App.tsx, layout, header, menu components).
- Feature pages like HomePage, AuthPage, HistoryPage, SettingsModal, and various clip and queue components.
- State & Middleware: Show a dedicated state management component (from files like store.ts and authSlice.ts) plus middleware integrations for analytics, clip queue, and Twitch chat.
- Feature Modules: Indicate separate modules such as:
- Authentication (twitchAuthApi, RequireAuth, etc.)
- Analytics (analytics.ts & analyticsMiddleware.tsx)
- Clips (various providers and queue for clips handling)
- Twitch Chat integration
- Migration utilities (legacyMigration.ts)
- Public / Static Assets: Outline the public folder with static HTML and asset files that bootstrap the SPA and serve as the first load.
- Build & Configuration: Optionally note that build scripts (e.g., package.json, tsconfig.json) and configuration files (like .env.sample) are present to manage environment and deployment configurations.

##### Relationships & Interactions
- App/Router layer (src/app/Router.tsx and other layout components) to various feature pages, symbolizing client-side routing.
- That UI components consume state managed by Redux (or similar store) and use middleware to intercept actions (such as in analyticsMiddleware and clipQueueMiddleware).
- That feature components interface with the API service layer to retrieve or send data to external clip providers (YouTube, Twitch, Afreeca, Kick, Streamable).
- Integration of Twitch chat where actions and commands (from twitchChat files) interact with the UI and state.

##### Architectural Patterns & Design Principles
- Modular and Feature-Driven: Features are organized into their own directories making the architecture highly modular.
- Separation of Concerns: Different domains like authentication, clips handling, chat, and analytics are clearly separated.
- Middleware Pattern: Use of middleware for analytics, clip queuing, and Twitch chat to intercept and process actions is evident.
- API Abstraction: The implementation abstracts external API integrations behind common interface methods.

##### Relevant Technologies, Frameworks, and Libraries
- React (front-end view rendering).
- Likely Redux/RTK for state management as inferred from slice files.
- Integration with external APIs for Twitch, YouTube, etc.
- Testing tooling (e.g., setupTests.ts) and development features provided by Create React App.
- TypeScript as the language of choice (files like .tsx, tsconfig.json).
- Use of common styling solutions (SCSS, as seen in index.scss).

- Clear labels for each component: e.g., “UI / React Components”, “Application State & Store”, “Middleware”, “API Services”, “External Providers (Twitch, YouTube, etc.)”, “Static Assets”.
- From the UI components to the State Store.
- From middleware intercepting actions to API service calls.
- From the API service to external endpoints.

● Start with a high-level block showing "Client/Browser" loading static assets from the "Public" folder.
● Next, show the "Application" block subdivided into the UI Layer (App, Routes, Layouts) and Business Logic Layer (State, Middleware, Feature Modules).
● Optionally, include error handling, logging, and configuration aspects that are present (e.g., logging.ts and environment configurations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::static
    StaticAssets["Static Assets"]:::static
    Browser -->|"loads"| StaticAssets

    BuildConfigs["Build & Configuration"]:::config

    subgraph "User Interface"
      direction TB
      AppContainer["App Container"]:::ui
      AppHeader["App Header"]:::ui
      AppLayout["App Layout"]:::ui
      AppMenu["App Menu"]:::ui
      Router["Router"]:::ui
      AppSkeleton["App Skeleton"]:::ui
      HomePage["Home Page"]:::ui
      AuthPage["Authentication Page"]:::ui
      HistoryPage["History Page"]:::ui
      SettingsModal["Settings Modal"]:::ui
      ClipsQueue["Clips & Queue"]:::ui
    end

    subgraph "Feature Modules"
      direction TB
      AuthModule["Authentication Module"]:::feature
      AnalyticsModule["Analytics Module"]:::feature
      ClipsModule["Clips Module"]:::feature
      TwitchChatModule["Twitch Chat Integration"]:::feature
      MigrationUtility["Migration Utility"]:::feature
    end

    subgraph "State & Middleware"
      direction TB
      GlobalStore["Global State Store"]:::state
      AuthSlice["Auth Slice"]:::state
      ClipQueueSlice["Clip Queue Slice"]:::state
      SettingsSlice["Settings Slice"]:::state
      AnalyticsMiddleware["Analytics Middleware"]:::state
      ClipQueueMiddleware["Clip Queue Middleware"]:::state
      TwitchChatMiddleware["Twitch Chat Middleware"]:::state
    end

    subgraph "API / Services"
      direction TB
      AfreecaAPI["Afreeca API"]:::api
      KickAPI["Kick API"]:::api
      StreamableAPI["Streamable API"]:::api
      TwitchAPI["Twitch API"]:::api
      YouTubeAPI["YouTube API"]:::api
    end

    ExternalProviders["External Providers (Twitch,YouTube,Afreeca,Kick,Streamable)"]:::external

    %% Connections
    StaticAssets -->|"bootstraps"| Router
    Router -->|"routes-to"| AppContainer
    AppContainer -->|"renders"| HomePage
    AppContainer -->|"renders"| AuthPage
    AppContainer -->|"renders"| HistoryPage
    AppContainer -->|"renders"| SettingsModal
    AppContainer -->|"renders"| ClipsQueue

    %% UI to Feature Modules
    Router -->|"activates"| AuthModule
    Router -->|"activates"| AnalyticsModule
    Router -->|"activates"| ClipsModule
    Router -->|"activates"| TwitchChatModule
    Router -->|"activates"| MigrationUtility

    %% Feature Modules to State & Middleware
    AuthModule -->|"dispatches"| GlobalStore
    AnalyticsModule -->|"dispatches"| AnalyticsMiddleware
    ClipsModule -->|"dispatches"| ClipQueueSlice
    TwitchChatModule -->|"dispatches"| TwitchChatMiddleware
    MigrationUtility -->|"initiates"| GlobalStore

    %% UI also interacts with State
    HomePage -->|"reads-updates"| GlobalStore
    AuthPage -->|"reads-updates"| GlobalStore

    %% State & Middleware to API Services
    GlobalStore -->|"triggers"| AfreecaAPI
    AnalyticsMiddleware -->|"calls"| KickAPI
    ClipQueueMiddleware -->|"calls"| StreamableAPI
    TwitchChatMiddleware -->|"calls"| TwitchAPI
    AuthSlice -->|"calls"| YouTubeAPI

    %% API Services to External Providers
    AfreecaAPI -->|"external-call"| ExternalProviders
    KickAPI -->|"external-call"| ExternalProviders
    StreamableAPI -->|"external-call"| ExternalProviders
    TwitchAPI -->|"external-call"| ExternalProviders
    YouTubeAPI -->|"external-call"| ExternalProviders

    %% Build & Configuration informational connection
    BuildConfigs --- StaticAssets

    %% Click Events
    click AppContainer "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/App.tsx"
    click AppHeader "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/AppHeader.tsx"
    click AppLayout "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/AppLayout.tsx"
    click AppMenu "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/AppMenu.tsx"
    click Router "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/Router.tsx"
    click AppSkeleton "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/AppSkeleton.tsx"
    click HomePage "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/home/HomePage.tsx"
    click AuthPage "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/auth/AuthPage.tsx"
    click HistoryPage "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/clips/history/HistoryPage.tsx"
    click SettingsModal "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/settings/SettingsModal.tsx"
    click ClipsQueue "https://github.com/jakemiki/twitch-clip-queue/tree/main/src/features/clips/queue"
    click GlobalStore "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/app/store.ts"
    click AuthSlice "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/auth/authSlice.ts"
    click ClipQueueSlice "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/clips/clipQueueSlice.ts"
    click SettingsSlice "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/settings/settingsSlice.ts"
    click AnalyticsMiddleware "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/analytics/analyticsMiddleware.tsx"
    click ClipQueueMiddleware "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/clips/clipQueueMiddleware.ts"
    click TwitchChatMiddleware "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/twitchChat/twitchChatMiddleware.ts"
    click AfreecaAPI "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/common/apis/afreecaApi.ts"
    click KickAPI "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/common/apis/kickApi.ts"
    click StreamableAPI "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/common/apis/streamableApi.ts"
    click TwitchAPI "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/common/apis/twitchApi.ts"
    click YouTubeAPI "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/common/apis/youtubeApi.ts"
    click AuthModule "https://github.com/jakemiki/twitch-clip-queue/tree/main/src/features/auth"
    click AnalyticsModule "https://github.com/jakemiki/twitch-clip-queue/tree/main/src/features/analytics"
    click ClipsModule "https://github.com/jakemiki/twitch-clip-queue/tree/main/src/features/clips"
    click TwitchChatModule "https://github.com/jakemiki/twitch-clip-queue/tree/main/src/features/twitchChat"
    click MigrationUtility "https://github.com/jakemiki/twitch-clip-queue/blob/main/src/features/migration/legacyMigration.ts"
    click StaticAssets "https://github.com/jakemiki/twitch-clip-queue/tree/main/public"
    click BuildConfigs "https://github.com/jakemiki/twitch-clip-queue/blob/main/package.json"

    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef feature fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef state fill:#A3E4D7,stroke:#117864,stroke-width:2px;
    classDef api fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef static fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
