# yuniruyuni/streamtaginventory architecture

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

- Interactive diagram: https://gitdiagram.com/yuniruyuni/streamtaginventory
- Repository: https://github.com/yuniruyuni/streamtaginventory

## Overview

##### Project Type & Purpose
- This is a *frontend-only* Single‐Page Application (SPA) for Twitch streamers to manage and apply streaming templates (title/category/tag sets) via the Twitch API.
- It uses React + TypeScript, Bun as the build/runtime, Tailwind CSS for styling, and is ultimately served as static assets (Docker + Nginx).

##### Core Components
a. User’s Browser (SPA)
- React components (CategorySelector, InputTags, MainScreen, TemplateCard, etc.)
- Contexts & Hooks (TwitchAuth context/provider, useTemplateOperations, useStorage)
- Local storage persistence layer (useStorage.ts → browser’s localStorage)
- i18n layer for locale switching
b. Static Asset Server
- Docker container running Nginx (Dockerfile + conf.d/default.conf)
- Serves index.html, JS bundle, CSS, assets
c. Build & Dev Toolchain (optional inset)
- Bun (bun.lock, bunfig.toml) for build/dev server (bin/local.ts)
- Lint/format (biome), TypeScript compilation (tsconfig.json)
d. External Service
- Twitch API endpoints
- OAuth2 authentication & token issuance
- Category (game) search endpoint
- Channel settings PATCH (title/category/tag)
- Stream markers POST

##### Relationships & Data Flows
- Browser SPA ←(HTTP/HTTPS)→ Static Server (Nginx)
- SPA → TwitchAuth (OAuth redirect / token management)
- SPA → Twitch API
- GET /helix/games (category search)
- PATCH /helix/channels (apply template)
- POST /helix/stream_markers
- SPA ↔ localStorage (template CRUD via templateIO.ts & useStorage.ts)

##### Architectural Patterns & Design Principles
- Component‐Based UI (presentational vs. container hooks)
- Context API for cross‐cutting concerns (auth, notifications, i18n)
- Custom hooks for data‐fetching & side‐effects (useTemplateSearch, useTemplateOperations)
- Local persistence abstraction (templateIO.ts, useStorage)
- Static hosting with containerized reverse proxy (Docker + Nginx)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser / SPA"
        SPA["React SPA"]:::frontend
        subgraph "UI Layer"
            CategorySelector["CategorySelector"]:::ui
            click CategorySelector "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/CategorySelector"
            InputTags["InputTags"]:::ui
            click InputTags "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/InputTags"
            MainScreen["MainScreen"]:::ui
            click MainScreen "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/MainScreen"
            TemplateCard["TemplateCard"]:::ui
            click TemplateCard "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/TemplateCard"
            ErrorNotification["ErrorNotification"]:::ui
            click ErrorNotification "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/ErrorNotification"
            LanguageSwitcher["LanguageSwitcher"]:::ui
            click LanguageSwitcher "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/LanguageSwitcher"
            Notification["Notification"]:::ui
            click Notification "https://github.com/yuniruyuni/streamtaginventory/tree/main/src/Notification"
        end
        subgraph "State Layer"
            TwitchAuthContext["TwitchAuth Context"]:::state
            click TwitchAuthContext "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/TwitchAuth/context.tsx"
            TwitchAuthProvider["TwitchAuth Provider"]:::state
            click TwitchAuthProvider "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/TwitchAuth/provider.tsx"
            NotificationContext["Notification Context"]:::state
            click NotificationContext "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/Notification/context.tsx"
        end
        subgraph "Hooks & Data"
            useTemplateOperations["useTemplateOperations"]:::data
            click useTemplateOperations "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/hooks/useTemplateOperations.ts"
            useTemplateSearch["useTemplateSearch"]:::data
            click useTemplateSearch "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/hooks/useTemplateSearch.ts"
            useStorageHook["useStorage"]:::data
            click useStorageHook "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/useStorage.ts"
            useCategorySearch["useCategorySearch"]:::data
            click useCategorySearch "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/CategorySelector/useCategorySearch.ts"
            useCategoryNavigation["useCategoryNavigation"]:::data
            click useCategoryNavigation "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/CategorySelector/useCategoryNavigation.ts"
            templateIO["templateIO (LocalStorage)"]:::storage
            click templateIO "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/utils/templateIO.ts"
        end
        subgraph "i18n Layer"
            i18nConfig["i18n config"]:::state
            click i18nConfig "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/i18n/config.ts"
            i18nIndex["i18n index"]:::state
            click i18nIndex "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/i18n/index.ts"
            enLocale["en.json"]:::state
            click enLocale "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/i18n/locales/en.json"
            jaLocale["ja.json"]:::state
            click jaLocale "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/i18n/locales/ja.json"
        end
        localStorage["LocalStorage"]:::storage
    end

    TwitchAPI["Twitch API"]:::external
    Nginx["Nginx Static Server"]:::infra

    subgraph "Build & Dev Toolchain"
        BunConfig["bunfig.toml"]:::toolchain
        click BunConfig "https://github.com/yuniruyuni/streamtaginventory/blob/main/bunfig.toml"
        BunLock["bun.lock"]:::toolchain
        click BunLock "https://github.com/yuniruyuni/streamtaginventory/blob/main/bun.lock"
        LocalScript["bin/local.ts"]:::toolchain
        click LocalScript "https://github.com/yuniruyuni/streamtaginventory/blob/main/bin/local.ts"
        Biome["biome.jsonc"]:::toolchain
        click Biome "https://github.com/yuniruyuni/streamtaginventory/blob/main/biome.jsonc"
        TSConfig["tsconfig.json"]:::toolchain
        click TSConfig "https://github.com/yuniruyuni/streamtaginventory/blob/main/tsconfig.json"
    end

    EntryHTML["index.html"]:::infra
    click EntryHTML "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/index.html"
    EntryTSX["index.tsx"]:::infra
    click EntryTSX "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/index.tsx"
    IndexCSS["index.css"]:::infra
    click IndexCSS "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/index.css"
    Constants["constant.ts"]:::infra
    click Constants "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/constant.ts"
    Fetcher["fetcher.ts"]:::infra
    click Fetcher "https://github.com/yuniruyuni/streamtaginventory/blob/main/src/fetcher.ts"
    DockFile["Dockerfile"]:::infra
    click DockFile "https://github.com/yuniruyuni/streamtaginventory/tree/main/Dockerfile"
    NginxConf["default.conf"]:::infra
    click NginxConf "https://github.com/yuniruyuni/streamtaginventory/blob/main/conf.d/default.conf"

    Nginx -->|"Serves SPA (HTTPS)"| SPA
    SPA -->|"OAuth2 / HTTPS"| TwitchAPI
    SPA -->|"CRUD Templates"| templateIO
    templateIO -->|"reads/writes"| localStorage
    localStorage -->|"persists data"| templateIO
    TwitchAPI -->|"API Responses"| SPA

    classDef ui fill:#CEF6F5,stroke:#006B6B,stroke-width:1px
    classDef state fill:#FCF6BD,stroke:#8B6508,stroke-width:1px
    classDef data fill:#E2F0CB,stroke:#4F772D,stroke-width:1px
    classDef storage fill:#FDEDEC,stroke:#B03A2E,stroke-width:1px
    classDef external fill:#E8E8E8,stroke:#6E6E6E,stroke-width:1px
    classDef infra fill:#D5D8DC,stroke:#2E4053,stroke-width:1px
    classDef toolchain fill:#F5EEF8,stroke:#6C3483,stroke-width:1px
```
