# tuya-community/tuya-ray-materials architecture

> Architecture diagram of the GitHub repository tuya-community/tuya-ray-materials, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tuya-community/tuya-ray-materials
- Repository: https://github.com/tuya-community/tuya-ray-materials

## Overview

##### High-Level Architecture Components

The system should be divided into these main components:

a) Templates Layer
- Device-specific templates (e.g., SweepRobot, PanelLock, PublicPanelIpc)
- Each template containing its own UI components, business logic, and device protocols

b) Materials Layer
- Reusable UI components (HighPerfText, TySlider, RecycleView)
- Shared utilities and hooks

c) Core Framework Layer
- Ray framework integration
- Redux state management
- Device communication protocols
- Internationalization (i18n) support

##### Key Relationships to Highlight

- Template dependencies on Materials components
- Data flow between device protocols and UI components
- State management patterns using Redux
- Communication with Tuya IoT platform

##### Component Organization

For each template/material, show:
**Template/Material**
- Components
- UI Components
- Business Components
- Pages
- Route-based views
- Redux Store
- Actions
- Reducers
- Device Integration
- Protocols
- Schema
- Utils & Hooks

##### Implementation Details

Technical annotations for:
- TypeScript/JavaScript implementation
- React/Ray component structure
- Redux state flow
- Device protocol handling
- Style management (Less modules)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef material fill:#4CAF50,stroke:#2E7D32,color:white
    classDef template fill:#FF9800,stroke:#EF6C00,color:white
    classDef state fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef util fill:#9E9E9E,stroke:#616161,color:white

    %% Core Framework Layer
    subgraph CoreFramework["Core Framework Layer"]
        Ray["Ray Framework"]:::core
        Redux["Redux State Management"]:::state
        DeviceComm["Device Communication"]:::core
        I18N["i18n Support"]:::core
    end

    %% Materials Layer
    subgraph Materials["Materials Layer"]
        HighPerfText["HighPerfText"]:::material
        TySlider["TySlider"]:::material
        RecycleView["RecycleView"]:::material
        MaterialExamples["Material Examples"]:::material
    end

    %% Templates Layer
    subgraph Templates["Templates Layer"]
        direction TB
        subgraph DeviceTemplates["Device Templates"]
            SweepRobot["SweepRobot Template"]:::template
            PanelLock["Panel Lock Template"]:::template
            PublicPanelIpc["Public Panel IPC"]:::template
        end

        subgraph TemplateComponents["Template Structure"]
            Components["UI Components"]:::template
            Pages["Route-based Views"]:::template
            DeviceProtocols["Device Protocols"]:::template
            BusinessLogic["Business Logic"]:::template
        end
    end

    %% Shared Utilities
    subgraph Utils["Shared Utilities"]
        CommonUtils["Common Utils"]:::util
        Hooks["Custom Hooks"]:::util
        Types["TypeScript Types"]:::util
    end

    %% Relationships
    Ray --> DeviceTemplates
    Redux --> DeviceTemplates
    DeviceComm --> DeviceProtocols
    I18N --> Templates

    Materials --> TemplateComponents
    DeviceTemplates --> TemplateComponents
    Utils --> Templates
    Utils --> Materials

    %% Click Events
    click DeviceTemplates "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*"
    click Components "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/components"
    click Pages "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/pages"
    click DeviceProtocols "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/devices/protocols"
    click HighPerfText "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/materials/HighPerfText"
    click TySlider "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/materials/TySlider"
    click RecycleView "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/materials/RecycleView"
    click MaterialExamples "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/materials/*/example"
    click Redux "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/redux"
    click I18N "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/i18n"
    click DeviceComm "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/devices"
    click Ray "https://github.com/Tuya-Community/tuya-ray-materials/blob/main/template/*/ray.config.ts"
    click CommonUtils "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/utils"
    click Hooks "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/hooks"
    click Types "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/typings"
    click Components "https://github.com/Tuya-Community/tuya-ray-materials/tree/main/template/*/src/components"

    %% Legend
    subgraph Legend["Legend"]
        L1["Core Framework"]:::core
        L2["Material Component"]:::material
        L3["Template Component"]:::template
        L4["State Management"]:::state
        L5["Utility"]:::util
    end
```
