# honishi/kick-signal architecture

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

- Interactive diagram: https://gitdiagram.com/honishi/kick-signal
- Repository: https://github.com/honishi/kick-signal

## Overview

##### Main Components
- Extension Entry Points: The project has several entry scripts:
– Background Script (src/entry/background.ts): Handles long‑running tasks, managing events, and coordinating data flow.
– Option Page (src/entry/option.tsx and src/view/html/option.html): Manages user settings/configuration.
– Content Script (src/entry/content.ts): Injected into webpages (if needed) to interact with page content.
– Offscreen Script (src/entry/offscreen.ts and src/view/html/offscreen.html): Handles tasks in an offscreen context.

- Domain Layer:
– Domain Models (src/domain/model): Define the core entities, e.g., kick‑channel, error definitions, and sound type.
– Infra Interfaces (src/domain/infra-interface): Define abstractions for interacting with external components (e.g., browser APIs, Kick API).

- Infrastructure Layer:
– Implementation of browser APIs and API integrations (src/infra): This layer contains the concrete implementations (e.g., Chrome messaging and integration with Kick API) that adhere to the infra‐interface contracts.
– Additionally, there is support for dependency injection (src/di), which registers and provides dependencies across the components.

- UI & Presentation Layer:
– Components (under src/entry/component) and views (src/view) for presenting data: React components (e.g., Channel.tsx, FollowingChannels.tsx) and static HTML/CSS files.

- Build & Configuration:
– Build scripts and configuration files (webpack configuration, tsconfig.json, package.json, etc.) indicate the building process and bundling for both development and production environments.

##### Relationships and Interactions
– The background script acts as a mediator between UI components (popup, option, offscreen) and the domain/infrastructure layers.
– When a user interface event occurs (e.g., in the popup or option page), it triggers a use case from the domain layer.
– The use case interacts with the domain models and, via the DI container (src/di), calls appropriate implementations (from src/infra) that use browser APIs or the Kick API.
– Data flows both ways: the UI sends commands to the background process, which communicates with offscreen scripts or content scripts as needed, and in turn, results or notifications are sent back to the UI.

##### Architectural Patterns and Design Principles
– Layered Architecture: Separation into presentation (UI), domain (business logic), and infrastructure (external communications).
– Dependency Injection: Clearly seen in the src/di folder for managing service registrations and resolving dependencies.
– Modular Design: Organized by clearly defined directories for domain models, use cases, and infrastructure, facilitating maintenance and scalability.
– Use of Standard Build Tools: Webpack for bundling, strict TypeScript configurations, and project standards set by ESLint and Prettier.

##### Additional Notes for Detail
– Don’t hesitate to break down further into sub‑components where necessary; for example, within the domain layer, show individual use cases like “Notify when streamer goes live” and “Manage user options.”
– Capture any integration points with the browser (e.g., through the Chrome Messaging system, seen in src/infra/chrome_message), which is critical in a Chrome extension.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Extension Entry Points
    subgraph "Extension Entry Points"
        E_BG["Background Script"]:::extension
        E_POP["Popup Script"]:::extension
        E_POP_HTML["Popup HTML"]:::extension
        E_OPT["Option Script"]:::extension
        E_OPT_HTML["Option HTML"]:::extension
        E_CONT["Content Script"]:::extension
        E_OFF["Offscreen Script"]:::extension
        E_OFF_HTML["Offscreen HTML"]:::extension
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D_MOD["Domain Models"]:::domain
        D_UC["Domain Use Cases"]:::domain
        D_IF["Infra Interfaces"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        I_DI["Dependency Injection"]:::infra
        I_IMPL["Infra Implementations"]:::infra
        E_API["Kick API"]:::infraExternal
        B_API["Browser APIs"]:::infraExternal
    end

    %% UI & Presentation
    subgraph "UI & Presentation"
        UI_COMP["UI Components"]:::ui
        UI_ASSET["Static Assets"]:::ui
    end

    %% Build & Configuration
    subgraph "Build & Configuration"
        BUILD["Build & Config"]:::build
    end

    %% Relationships
    %% UI interactions trigger extension entry points
    UI_COMP -->|"initiate"| E_POP
    UI_COMP -->|"initiate"| E_OPT
    UI_ASSET -->|"support"| UI_COMP

    %% Extension Entry interactions
    E_POP -->|"triggers"| E_BG
    E_OPT -->|"triggers"| E_BG
    E_CONT -->|"communicates"| E_BG
    E_OFF -->|"communicates"| E_BG
    E_OFF_HTML -->|"part of"| E_OFF

    %% Background script interaction with Domain
    E_BG -->|"executes"| D_UC

    %% Domain layer internal use
    D_UC -->|"utilizes"| D_MOD
    D_UC -->|"calls"| D_IF
    D_UC -->|"resolved by"| I_DI

    %% Dependency Injection wiring in Infra Layer
    I_DI -->|"provides"| I_IMPL

    %% Infra implementations call external services
    I_IMPL -->|"calls"| E_API
    I_IMPL -->|"calls"| B_API

    %% Build process bundles components
    BUILD -->|"bundles"| E_BG
    BUILD -->|"bundles"| UI_COMP
    BUILD -->|"bundles"| UI_ASSET

    %% Click Events
    click E_BG "https://github.com/honishi/kick-signal/blob/main/src/entry/background.ts"
    click E_POP "https://github.com/honishi/kick-signal/blob/main/src/entry/popup.tsx"
    click E_POP_HTML "https://github.com/honishi/kick-signal/blob/main/src/view/html/popup.html"
    click E_OPT "https://github.com/honishi/kick-signal/blob/main/src/entry/option.tsx"
    click E_OPT_HTML "https://github.com/honishi/kick-signal/blob/main/src/view/html/option.html"
    click E_CONT "https://github.com/honishi/kick-signal/blob/main/src/entry/content.ts"
    click E_OFF "https://github.com/honishi/kick-signal/blob/main/src/entry/offscreen.ts"
    click E_OFF_HTML "https://github.com/honishi/kick-signal/blob/main/src/view/html/offscreen.html"
    click D_MOD "https://github.com/honishi/kick-signal/tree/main/src/domain/model"
    click D_UC "https://github.com/honishi/kick-signal/tree/main/src/domain/usecase"
    click D_IF "https://github.com/honishi/kick-signal/tree/main/src/domain/infra-interface"
    click I_IMPL "https://github.com/honishi/kick-signal/tree/main/src/infra"
    click I_DI "https://github.com/honishi/kick-signal/tree/main/src/di"
    click UI_COMP "https://github.com/honishi/kick-signal/tree/main/src/entry/component"
    click UI_ASSET "https://github.com/honishi/kick-signal/tree/main/public"
    click BUILD "https://github.com/honishi/kick-signal/blob/main/webpack/webpack.common.js"

    %% Styles
    classDef extension fill:#A9D0F5,stroke:#1F618D,stroke-width:2px;
    classDef domain fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef infra fill:#A9DFBF,stroke:#229954,stroke-width:2px;
    classDef infraExternal fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef ui fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef build fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
