# pointauc/pointauc_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/pointauc/pointauc_frontend
- Repository: https://github.com/pointauc/pointauc_frontend

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) written in React + TypeScript built with Vite.
- Purpose: a front‑end client for “Pointauc,” an Auction Service for Streamers that integrates with Twitch Channel Points, Donation Alerts, DonatePay, YouTube, and real‑time event streams. It provides interactive tools (auctions, wheels, lotteries) and customizable settings.

##### File structure
- Top‑level:
- public/ – static assets (fonts, robots.txt, sitemap.xml).
- src/ – application source:
– api/ – wrappers around HTTP endpoints for each integration (twitchApi, donatePayApi, etc.)
– services/ – core logic and long‑lived connections (WebSocketService, ChatService, SaveLoadService).
– reducers/ – Redux reducers for application state (AucSettings, Requests, User, socketIo).
– components/ – reusable UI components organized by feature.
– pages/ – route‑level page components (auction, settings, history, wheel, documentation).
– hooks/ – custom React hooks (useWheel, useStorageState, useChatBot).
– models/, enums/, constants/ – domain types and shared constants.
– assets/, styles/, i18n/ – theming, translations, global styles.
- config files: tsconfig.json, vite.config.ts, .eslintrc.cjs, .prettierrc.

##### Key insights from README
- Real‑time updates (bids, events).
- Multiple integrations (Twitch channel points, Donation Alerts, DonatePay).
- Interactive decision‑making tools (Wheel of Fortune, Dropout Wheel, Battle Royale).
- Customizable appearance and settings.

##### How to represent this
a. Main components
- Browser (client)
- React Application
– UI Layer: pages, components, theme & router wrappers
– State Layer: Redux store + reducers
– API Layer: src/api/* modules
– Service Layer: WebSocketService, ChatService, SaveLoadService
– Utility Layer: hooks, models, constants
- External Services
– Pointauc Back‑end API (auction, requests, settings)
– Twitch Channel Points API
– Donation Alerts API
– DonatePay API
– YouTube API (player & data)
– AUKUS event service
– Pubsub/Centrifuge real‑time event stream

b. Relationships and interactions
- UI Layer dispatches Redux actions → updates store → re‑renders components.
- Components invoke API Layer modules to call REST back‑end or third‑party services.
- WebSocketService/centrifugeFlow connects to real‑time stream → dispatches updates to Redux.
- Hooks wrap components around API calls and service subscriptions.
- i18n & ThemeWrapper provide context to all UI components.

c. Architectural patterns and design principles
- Component‑based UI (React)
- Unidirectional data flow (Redux)
- Separation of concerns: UI / state / API / services
- Context providers for theme and localization
- Custom hooks to encapsulate logic (e.g., useWheel, useChatBot)
- Typed contracts (TypeScript models & enums)

d. Key technologies & frameworks
- React + JSX + SCSS
- Redux (reducers folder)
- Vite build tool
- TypeScript
- WebSocket / Centrifuge for real‑time
- REST calls via Axios or fetch in src/api
- i18next or custom i18n module
- External APIs (Twitch, Donation Alerts, DonatePay, YouTube)

##### Final advice
- Be detailed: capture each logical layer and its relation.
- Components by role, not file path.
- Don’t overthink—list all layers and show how data flows end to end, from user interaction through API calls and back via WebSocket events.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::external
    main["main.tsx"]:::init
    App["App.tsx"]:::init
    Browser --> main
    main --> App
    App --> ReactApp

    subgraph ReactApp
        subgraph "UI Layer"
            Pages["Pages"]:::frontend
            Components["Components"]:::frontend
            ThemeWrapper["ThemeWrapper"]:::frontend
            GlobalStyles["Global Styles"]:::frontend
        end
        subgraph "State Layer"
            RootReducer["Root Reducer"]:::state
            AucSettings["AucSettings Reducer"]:::state
            RequestsReducer["Requests Reducer"]:::state
            UserReducer["User Reducer"]:::state
            SocketReducer["Socket.IO Reducer"]:::state
            OtherReducers["Additional Reducers"]:::state
        end
        subgraph "API Layer"
            TwitchApi["Twitch API"]:::api
            DAApi["Donation Alerts API"]:::api
            DonatePayApi["DonatePay API"]:::api
            YouTubeApi["YouTube API"]:::api
            RequestsApi["Requests API"]:::api
            UserApi["User API"]:::api
            TokenApi["Token API"]:::api
            AUKUSApi["AUKUS API"]:::api
            OtherApi["Other APIs"]:::api
        end
        subgraph "Service Layer"
            WSService["WebSocketService"]:::service
            ChatService["ChatService"]:::service
            SaveLoadService["SaveLoadService"]:::service
            PredictionService["PredictionService"]:::service
            SpinPaceService["SpinPaceService"]:::service
            PercentsRefMap["PercentsRefMap"]:::service
        end
        subgraph "Utility Layer"
            Hooks["Hooks"]:::util
            Models["Models"]:::util
            Enums["Enums"]:::util
            Constants["Constants"]:::util
            Utils["Utils"]:::util
        end
    end

    %% UI to State
    Components -->|"dispatch actions"| RootReducer
    RootReducer -->|"state updates"| Components

    %% UI to API
    Components -->|"REST calls"| TwitchApi
    Components -->|"REST calls"| DAApi
    Components -->|"REST calls"| DonatePayApi
    Components -->|"REST calls"| YouTubeApi
    Components -->|"REST calls"| RequestsApi
    Components -->|"REST calls"| UserApi
    Components -->|"REST calls"| TokenApi
    Components -->|"REST calls"| AUKUSApi

    %% Services to State and External
    WSService -->|"dispatch actions"| RootReducer
    WSService -->|"subscribe"| Centrifuge
    ChatService -->|"chat events"| TwitchExt

    %% Hooks usage
    Hooks --> Components
    Hooks --> WSService

    %% Theme & Styles context
    ThemeWrapper --> Components
    GlobalStyles --> Components

    %% External Systems
    subgraph External
        TwitchExt["Twitch Channel Points API"]:::external
        DonationExt["Donation Alerts API"]:::external
        DonatePayExt["DonatePay API"]:::external
        YouTubeExt["YouTube API"]:::external
        PointaucBack["Pointauc Backend"]:::external
        Centrifuge["PubSub/Centrifuge Stream"]:::external
    end

    %% API to External
    TwitchApi --> TwitchExt
    DAApi --> DonationExt
    DonatePayApi --> DonatePayExt
    YouTubeApi --> YouTubeExt
    RequestsApi --> PointaucBack
    UserApi --> PointaucBack
    TokenApi --> PointaucBack
    AUKUSApi --> PointaucBack

    %% Click Events
    click main "https://github.com/pointauc/pointauc_frontend/blob/master/src/main.tsx"
    click App "https://github.com/pointauc/pointauc_frontend/blob/master/src/App.tsx"
    click Pages "https://github.com/pointauc/pointauc_frontend/tree/master/src/pages"
    click Components "https://github.com/pointauc/pointauc_frontend/tree/master/src/components"
    click ThemeWrapper "https://github.com/pointauc/pointauc_frontend/blob/master/src/ThemeWrapper.tsx"
    click GlobalStyles "https://github.com/pointauc/pointauc_frontend/blob/master/src/styles/index.scss"
    click RootReducer "https://github.com/pointauc/pointauc_frontend/blob/master/src/reducers/index.ts"
    click AucSettings "https://github.com/pointauc/pointauc_frontend/blob/master/src/reducers/AucSettings/AucSettings.ts"
    click RequestsReducer "https://github.com/pointauc/pointauc_frontend/blob/master/src/reducers/Requests/Requests.ts"
    click UserReducer "https://github.com/pointauc/pointauc_frontend/blob/master/src/reducers/User/User.ts"
    click SocketReducer "https://github.com/pointauc/pointauc_frontend/blob/master/src/reducers/socketIo/socketIo.ts"
    click TwitchApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/twitchApi.ts"
    click DAApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/daApi.ts"
    click DonatePayApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/donatePayApi.ts"
    click YouTubeApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/youtubeApi.ts"
    click RequestsApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/requestsApi.ts"
    click UserApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/userApi.ts"
    click TokenApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/tokenApi.ts"
    click AUKUSApi "https://github.com/pointauc/pointauc_frontend/blob/master/src/api/events/aukusApi.ts"
    click WSService "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/WebSocketService.ts"
    click ChatService "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/ChatService.ts"
    click SaveLoadService "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/SaveLoadService.ts"
    click PredictionService "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/PredictionService.ts"
    click SpinPaceService "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/SpinPaceService.ts"
    click PercentsRefMap "https://github.com/pointauc/pointauc_frontend/blob/master/src/services/PercentsRefMap.ts"
    click Hooks "https://github.com/pointauc/pointauc_frontend/tree/master/src/hooks"
    click Models "https://github.com/pointauc/pointauc_frontend/tree/master/src/models"
    click Enums "https://github.com/pointauc/pointauc_frontend/tree/master/src/enums"
    click Constants "https://github.com/pointauc/pointauc_frontend/tree/master/src/constants"
    click Utils "https://github.com/pointauc/pointauc_frontend/tree/master/src/utils"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#333,stroke-width:1px
    classDef state fill:#D0F0C0,stroke:#333,stroke-width:1px
    classDef api fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef service fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef util fill:#E8E8E8,stroke:#333,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px
    classDef init fill:#E6E6FA,stroke:#333,stroke-width:1px
```
