# arnav-ahirrao/esp32-click-switch architecture

> Architecture diagram of the GitHub repository arnav-ahirrao/esp32-click-switch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arnav-ahirrao/esp32-click-switch
- Repository: https://github.com/arnav-ahirrao/esp32-click-switch

## Overview

ESP32 Click Switch turns physical button clicks into Windows actions. The principal flow is button input, firmware event generation, USB serial reception, click-count dispatch, and keyboard or other Windows actions; holding the button keeps the window switcher open until release. The README also documents customizable app, lock, music, and slide actions. Firmware internals were not excerpted, so firmware behavior and its serial handoff are grounded in README statements rather than inspected implementation.

Main entry points: [`software/switch.py`](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py) (Event Dispatcher), [`firmware/click_switch/click_switch.ino`](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/firmware/click_switch/click_switch.ino) (Click Firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device Input"]
  node_firmware["Click Firmware<br/>[click_switch.ino]"]
end

subgraph group_host["Windows Host"]
  node_serial["USB Serial<br/>[switch.py]"]
  node_dispatcher["Event Dispatcher<br/>[switch.py]"]
end

subgraph group_actions["Action Execution"]
  node_window_actions["Window Controls<br/>[switch.py]"]
  node_custom_actions["Custom Actions<br/>[switch.py]"]
end

node_user(("Button User"))
node_windows["Windows"]

node_user -->|"presses button"| node_firmware
node_firmware -->|"sends events"| node_serial
node_serial -->|"yields messages"| node_dispatcher
node_dispatcher -->|"invokes actions"| node_window_actions
node_dispatcher -->|"dispatches clicks"| node_custom_actions
node_window_actions -->|"sends keystrokes"| node_windows
node_custom_actions -->|"runs actions"| node_windows

click node_firmware "https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/firmware/click_switch/click_switch.ino"
click node_serial "https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py"
click node_dispatcher "https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py"
click node_window_actions "https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py"
click node_custom_actions "https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware,node_user toneBlue
class node_serial,node_dispatcher toneAmber
class node_window_actions,node_custom_actions toneMint
class node_windows toneIndigo
```

## Components

### Device Input

- [Click Firmware](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/firmware/click_switch/click_switch.ino): `firmware/click_switch/click_switch.ino`

### Windows Host

- [USB Serial](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py): `software/switch.py`
- [Event Dispatcher](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py): `software/switch.py`

### Action Execution

- [Window Controls](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py): `software/switch.py`
- [Custom Actions](https://github.com/arnav-ahirrao/esp32-click-switch/blob/main/software/switch.py): `software/switch.py`

### Other components

- **Button User**
- **Windows**

## Connections

- Button User → Click Firmware: presses button (evidence: `README.md`)
- Click Firmware → USB Serial: sends events (evidence: `README.md`)
- USB Serial → Event Dispatcher: yields messages (evidence: `software/switch.py`)
- Event Dispatcher → Window Controls: invokes actions (evidence: `software/switch.py`)
- Event Dispatcher → Custom Actions: dispatches clicks (evidence: `software/switch.py`)
- Window Controls → Windows: sends keystrokes (evidence: `software/switch.py`)
- Custom Actions → Windows: runs actions (evidence: `software/switch.py`)
