# bbelk/handirokuremote architecture

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

- Interactive diagram: https://gitdiagram.com/bbelk/handirokuremote
- Repository: https://github.com/bbelk/handirokuremote

## Overview

##### Main Components

a) Input Layer:
- Camera Interface (represents the physical camera input)
- Video Capture System (OpenCV component)

b) Core Processing Layer:
- Hand Detection Module (MediaPipe integration)
- Gesture Recognition System
- Command Interpreter

c) Output Layer:
- Roku Communication Module (ECP interface)
- GUI Interface (Tkinter)

d) Configuration & Storage:
- Settings Manager
- Device Discovery Service
- Logging System

**[User/Camera Input]**
- ↓
**[Video Processing Layer]**
- ↓
**[Gesture Processing Layer]**
- ↓
**[Command Layer]**
- ↓
**[Roku Device]**

##### Component Details

For each major component, include these specific implementations:

a) Video Processing Layer:
- OpenCV Video Capture
- Frame Processing
- Camera Selection Interface

b) Gesture Processing Layer:
- MediaPipe Hand Landmark Detection
- Gesture Pattern Recognition
- State Management (Idle/Active modes)

c) Command Layer:
- HTTP Request Handler
- Roku ECP Protocol Implementation
- Device Discovery Service

d) GUI Layer (parallel to main flow):
- Tkinter Interface
- Debug Overlay
- Settings Controls
- Video Feed Display

##### Technical Details to Highlight

- Camera input processing (gestureDetection.py)
- Roku communication (rokuRemote.py)
- GUI elements (tooltip.py)
- Configuration management (roku_config.json)
- Logging system (roku_remote.log)

##### Additional Elements

Annotations for:
- Supported gestures
- Command mapping
- Error handling paths
- Configuration flows

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'fontSize': '16px'}}}%%

flowchart TB
    classDef input fill:#a8d1f0,stroke:#000
    classDef processing fill:#90EE90,stroke:#000
    classDef network fill:#FFB347,stroke:#000
    classDef storage fill:#D3D3D3,stroke:#000
    classDef gui fill:#DDA0DD,stroke:#000

    subgraph Input
        Camera[Camera Interface]:::input
        VideoCapture[Video Capture System]:::input
    end

    subgraph ProcessingLayer[Processing Layer]
        VideoProc[Video Processing]:::processing
        HandDetect[Hand Detection Module]:::processing
        GestureRecog[Gesture Recognition]:::processing
        CommandInterp[Command Interpreter]:::processing
    end

    subgraph CommunicationLayer[Communication Layer]
        RokuComm[Roku Communication]:::network
        DeviceDisc[Device Discovery]:::network
    end

    subgraph GUI[GUI Layer]
        TkInterface[Tkinter Interface]:::gui
        DebugOverlay[Debug Overlay]:::gui
        Settings[Settings Controls]:::gui
        VideoDisplay[Video Feed Display]:::gui
    end

    subgraph Storage[Configuration & Storage]
        SettingsManager[Settings Manager]:::storage
        LogSystem[Logging System]:::storage
    end

    Camera --> VideoCapture
    VideoCapture --> VideoProc
    VideoProc --> HandDetect
    HandDetect --> GestureRecog
    GestureRecog --> CommandInterp
    CommandInterp --> RokuComm
    RokuComm --> DeviceDisc
    
    VideoProc --> VideoDisplay
    SettingsManager --> Settings
    HandDetect --> DebugOverlay
    
    %% Click events for component mapping
    click VideoProc "https://github.com/BBelk/HandiRokuRemote/blob/main/gestureDetection.py"
    click HandDetect "https://github.com/BBelk/HandiRokuRemote/blob/main/gestureDetection.py"
    click GestureRecog "https://github.com/BBelk/HandiRokuRemote/blob/main/gestureDetection.py"
    click RokuComm "https://github.com/BBelk/HandiRokuRemote/blob/main/rokuRemote.py"
    click TkInterface "https://github.com/BBelk/HandiRokuRemote/blob/main/tooltip.py"
    click DebugOverlay "https://github.com/BBelk/HandiRokuRemote/blob/main/tooltip.py"
    click VideoDisplay "https://github.com/BBelk/HandiRokuRemote/blob/main/tooltip.py"

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Processing Components]:::processing
        L3[Network Components]:::network
        L4[Storage Components]:::storage
        L5[GUI Components]:::gui
    end
```
