# kyhhe/timer architecture

> Architecture diagram of the GitHub repository kyhhe/timer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kyhhe/timer
- Repository: https://github.com/kyhhe/timer

## Overview

The ESP32 Timer Cube is a physical Pomodoro timer and desk clock: flipping the cube selects, pauses, or cancels a countdown, while its display shows time, weather, and timer status. Firmware startup connects Wi-Fi and synchronizes time; FreeRTOS tasks then poll orientation, coordinate timer state and display updates, and refresh weather independently. The README also documents custom PCB and enclosure hardware. Relationships below are limited to the supplied source excerpts and README; omitted main.cpp sections prevent confirming some task data transfers.

Main entry points: [`src/main.cpp`](https://github.com/kyhhe/timer/blob/main/src/main.cpp) (Task orchestration), [`src/ClockManager.cpp`](https://github.com/kyhhe/timer/blob/main/src/ClockManager.cpp) (Clock and timer), [`src/IMUSensor.cpp`](https://github.com/kyhhe/timer/blob/main/src/IMUSensor.cpp) (Orientation sensing), [`src/Display.cpp`](https://github.com/kyhhe/timer/blob/main/src/Display.cpp) (Screen rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Cube Interaction"]
  node_imu["Orientation sensing<br/>[IMUSensor.cpp]"]
  node_display["Screen rendering<br/>[Display.cpp]"]
end

subgraph group_firmware["Firmware Runtime"]
  node_firmware_main["Task orchestration<br/>[main.cpp]"]
  node_display_task["Display task<br/>[main.cpp]"]
  node_weather_task["Weather refresh task<br/>[main.cpp]"]
end

subgraph group_services["Time and Weather"]
  node_clock["Clock and timer<br/>[ClockManager.cpp]"]
  node_weather_data["Weather data and icons<br/>[WeatherData.h]"]
end

subgraph group_physical["Physical Device"]
  node_hardware_config["Pin configuration<br/>[HardwareConfig.h]"]
  node_pcb["Custom PCB"]
  node_enclosure["Printed enclosure"]
end

node_user(("Cube user"))
node_weather_api["OpenWeatherMap"]

node_user -->|"flips cube"| node_imu
node_firmware_main -->|"polls orientation"| node_imu
node_imu -->|"reports face"| node_firmware_main
node_firmware_main -->|"controls countdown"| node_clock
node_clock -->|"notifies completion"| node_firmware_main
node_firmware_main -->|"creates task"| node_display_task
node_display_task -->|"renders UI"| node_display
node_weather_task -->|"requests weather"| node_clock
node_clock -->|"fetches conditions"| node_weather_api
node_clock -->|"returns weather"| node_weather_data
node_display -->|"maps icons"| node_weather_data
node_firmware_main -->|"syncs time"| node_clock
node_user -->|"views status"| node_display
node_pcb -->|"mounts sensor"| node_imu
node_pcb -->|"mounts screen"| node_display
node_enclosure -->|"houses electronics"| node_pcb

click node_firmware_main "https://github.com/kyhhe/timer/blob/main/src/main.cpp"
click node_imu "https://github.com/kyhhe/timer/blob/main/src/IMUSensor.cpp"
click node_display_task "https://github.com/kyhhe/timer/blob/main/src/main.cpp"
click node_display "https://github.com/kyhhe/timer/blob/main/src/Display.cpp"
click node_clock "https://github.com/kyhhe/timer/blob/main/src/ClockManager.cpp"
click node_weather_task "https://github.com/kyhhe/timer/blob/main/src/main.cpp"
click node_weather_data "https://github.com/kyhhe/timer/blob/main/src/WeatherData.h"
click node_hardware_config "https://github.com/kyhhe/timer/blob/main/include/HardwareConfig.h"
click node_pcb "https://github.com/kyhhe/timer/tree/main/hardware/pcb"
click node_enclosure "https://github.com/kyhhe/timer/tree/main/hardware/enclosure"

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_imu,node_display,node_user toneBlue
class node_firmware_main,node_display_task,node_weather_task toneAmber
class node_clock,node_weather_data toneMint
class node_hardware_config,node_pcb,node_enclosure toneRose
class node_weather_api toneIndigo
```

## Components

### Cube Interaction

- [Orientation sensing](https://github.com/kyhhe/timer/blob/main/src/IMUSensor.cpp): `src/IMUSensor.cpp`
- [Screen rendering](https://github.com/kyhhe/timer/blob/main/src/Display.cpp): `src/Display.cpp`

### Firmware Runtime

- [Task orchestration](https://github.com/kyhhe/timer/blob/main/src/main.cpp): `src/main.cpp`
- [Display task](https://github.com/kyhhe/timer/blob/main/src/main.cpp): `src/main.cpp`
- [Weather refresh task](https://github.com/kyhhe/timer/blob/main/src/main.cpp): `src/main.cpp`

### Time and Weather

- [Clock and timer](https://github.com/kyhhe/timer/blob/main/src/ClockManager.cpp): `src/ClockManager.cpp`
- [Weather data and icons](https://github.com/kyhhe/timer/blob/main/src/WeatherData.h): `src/WeatherData.h`

### Physical Device

- [Pin configuration](https://github.com/kyhhe/timer/blob/main/include/HardwareConfig.h): `include/HardwareConfig.h`
- [Custom PCB](https://github.com/kyhhe/timer/tree/main/hardware/pcb): `hardware/pcb`
- [Printed enclosure](https://github.com/kyhhe/timer/tree/main/hardware/enclosure): `hardware/enclosure`

### Other components

- **Cube user**
- **OpenWeatherMap**

## Connections

- Cube user → Orientation sensing: flips cube (evidence: `README.md`)
- Task orchestration → Orientation sensing: polls orientation (evidence: `src/main.cpp`)
- Orientation sensing → Task orchestration: reports face (evidence: `src/main.cpp`)
- Task orchestration → Clock and timer: controls countdown (evidence: `src/main.cpp`)
- Clock and timer → Task orchestration: notifies completion (evidence: `src/ClockManager.cpp`)
- Task orchestration → Display task: creates task (evidence: `src/main.cpp`)
- Display task → Screen rendering: renders UI (evidence: `src/main.cpp`)
- Weather refresh task → Clock and timer: requests weather (evidence: `src/main.cpp`)
- Clock and timer → OpenWeatherMap: fetches conditions (evidence: `src/ClockManager.cpp`)
- Clock and timer → Weather data and icons: returns weather (evidence: `src/ClockManager.cpp`)
- Screen rendering → Weather data and icons: maps icons (evidence: `src/Display.cpp`)
- Task orchestration → Clock and timer: syncs time (evidence: `README.md`)
- Cube user → Screen rendering: views status (evidence: `README.md`)
- Custom PCB → Orientation sensing: mounts sensor (evidence: `README.md`)
- Custom PCB → Screen rendering: mounts screen (evidence: `README.md`)
- Printed enclosure → Custom PCB: houses electronics (evidence: `README.md`)
