# hideyuki-hori/distribution-worker architecture

> Architecture diagram of the GitHub repository hideyuki-hori/distribution-worker, 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/hideyuki-hori/distribution-worker
- Repository: https://github.com/hideyuki-hori/distribution-worker

## Overview

##### Project Type and Purpose
- This project is a high-performance web application focused on optimizing rendering and handling intensive computations. It leverages Web Workers to offload heavy computations from the UI thread, employs reactive programming via RxJS, and visualizes camera and mouse interactions using technologies like SolidJS and Three.js.

##### File Structure
- The top-level files include configuration files (tsconfig, vite.config.ts, panda.config.ts), package files, and an index.html, indicating a modern front-end build setup.
- The bulk of the project resides in the src folder, which is organized into feature-specific directories such as:
- “background”, “camera”, “heat-map”, “interaction”, “mouse-moved-sampler”, “mouse-pressed-indicator”, and “notification” inside “src/features”. These denote distinct functional modules or components.
- The “public” folder contains static assets (like the screenshot), and there is a centralized “app.tsx” that likely ties everything together.
- The “src/lib” and “src/types” directories indicate shared libraries and type definitions used across components.
- Several files with a “$” identifier hint at specific or placeholder modules possibly used for reactive event hooks or base functionality.

##### Extract Key Architectural Elements from the README
- The README emphasizes using:
- Web Workers for offloading heavy calculations.
- RxJS for event handling and managing reactive data streams.
- SolidJS and Three.js for UI/visualization aspects.
- It also mentions visualizing camera inputs and mouse actions on HTML canvas, indicating a strong client-side interaction model potentially split into real-time data streams and rendering pipelines.

##### Main Components
a. Frontend / UI Layer:
- Components (SolidJS based UI written in “.tsx” files in “src/features” such as header, interaction, and notification).
- Visualization tools leveraging Three.js (likely in components like heat-map or camera).
- Event management using RxJS which connects these UI components with the underlying data streams.
b. Computation / Web Workers:
- Offloaded computation tasks (found in “src/features/heat-map/worker.ts” and possibly other “$” files within feature directories) which run in separate threads.
- Data flow from the UI triggering worker processes and returning results.
c. Reactive Data Flow / Event Handling:
- RxJS-based modules that capture and process user inputs (mouse events, camera access, etc.) and distribute these events to corresponding components.
d. Global Configurations and Utilities:
- Application configuration (found in panda.config.ts, postcss.config.cjs, tsconfig files) that set up the build and runtime environments.
- Utility libraries (in “src/lib/”) shared across modules.
e. External Assets and Resources:
- Static assets from “public” (images, possibly other media).

##### Establish Relationships and Data Flow
- Integration points where visualization libraries (SolidJS and Three.js) interact with both the computed data and the reactive event streams.
- Incorporate the configuration and utility layers as supporting services that ensure consistency across the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        APP["Application Shell"]:::ui
        HEADER["Header Component"]:::ui
        CAMERA["Camera Feature"]:::ui
        INTERACTION["Interaction Feature"]:::ui
        HEATMAP["Heat-map Feature"]:::ui
        MOUSEMOVED["Mouse Moved Sampler"]:::ui
        MOUSEPRESSED["Mouse Pressed Indicator"]:::ui
        NOTIFICATION["Notification System"]:::ui
    end

    %% Reactive Event Management and Shared Modules
    RXJS["Reactive Event Manager (RxJS)"]:::rxjs

    subgraph "Shared Modules"
        REACTIVEMODS["Reactive Modules"]:::shared
        UTILITYMODS["Utility Modules"]:::shared
    end

    %% Heavy Computation Layer
    WORKER["Heat-map Web Worker"]:::worker

    %% Global Configurations
    CONFIG["Global Config & Types"]:::config

    %% Data Flow Arrows
    APP -->|"dispatch"| HEADER
    APP -->|"dispatch"| CAMERA
    APP -->|"dispatch"| INTERACTION
    APP -->|"dispatch"| HEATMAP
    APP -->|"dispatch"| MOUSEMOVED
    APP -->|"dispatch"| MOUSEPRESSED
    APP -->|"dispatch"| NOTIFICATION

    HEADER -->|"event"| RXJS
    CAMERA -->|"event"| RXJS
    INTERACTION -->|"event"| RXJS
    HEATMAP -->|"event"| RXJS
    MOUSEMOVED -->|"event"| RXJS
    MOUSEPRESSED -->|"event"| RXJS
    NOTIFICATION -->|"event"| RXJS

    REACTIVEMODS -->|"support"| RXJS
    UTILITYMODS -->|"support"| RXJS

    RXJS -->|"compute"| WORKER
    WORKER -->|"result"| HEATMAP

    CONFIG -->|"configures"| APP
    CONFIG -->|"configures"| UTILITYMODS

    %% Click Events
    click APP "https://github.com/hideyuki-hori/distribution-worker/blob/main/src/app.tsx"
    click HEADER "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/header/"
    click CAMERA "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/camera/"
    click INTERACTION "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/interaction/"
    click HEATMAP "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/heat-map/"
    click MOUSEMOVED "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/mouse-moved-sampler/"
    click MOUSEPRESSED "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/mouse-pressed-indicator/"
    click NOTIFICATION "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/features/notification/"
    click WORKER "https://github.com/hideyuki-hori/distribution-worker/blob/main/src/features/heat-map/worker.ts"
    click REACTIVEMODS "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/$"
    click UTILITYMODS "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/lib/"
    click CONFIG "https://github.com/hideyuki-hori/distribution-worker/tree/main/src/types/"

    %% Styles
    classDef ui fill:#CCE5FF,stroke:#2B70F2,stroke-width:2px;
    classDef rxjs fill:#FFF3CD,stroke:#FFB400,stroke-width:2px;
    classDef worker fill:#D1E7DD,stroke:#0F5132,stroke-width:2px;
    classDef config fill:#F8D7DA,stroke:#C82333,stroke-width:2px;
    classDef shared fill:#E2E3E5,stroke:#6C757D,stroke-width:2px;
```
