# tanleee/smart_clock architecture

> Architecture diagram of the GitHub repository tanleee/smart_clock, 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/tanleee/smart_clock
- Repository: https://github.com/tanleee/smart_clock

## Overview

This is an ESP-IDF smart-clock application, despite the README describing a generic template. Its principal workflow starts in app_main: initialize persisted alarm data and the display, start Wi-Fi/time synchronization, then launch alarm, stopwatch, and Pomodoro tasks. The display task presents the dashboard and touch-driven screens; the app also supports alarm editing/ringing, manual time setting, and timer controls. Several feature modules are identified by the source index but were not excerpted, so their internal behavior and some links are left unverified.

Main entry points: [`main/src/main.c`](https://github.com/tanleee/smart_clock/blob/main/main/src/main.c) (App startup), [`main/src/display.cpp`](https://github.com/tanleee/smart_clock/blob/main/main/src/display.cpp) (Display task), [`main/src/alarm_task.c`](https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_task.c) (Alarm scheduler), [`main/src/alarm_data.c`](https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_data.c) (Alarm data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application startup"]
  node_main["App startup<br/>[main.c]"]
end

subgraph group_ui["Display and interaction"]
  node_display["Display task<br/>[display.cpp]"]
  node_touch["Touch handling<br/>[display.cpp]"]
  node_layout["Screen layout<br/>[ui_layout.h]"]
end

subgraph group_clock["Clock and connectivity"]
  node_wifi["Wi-Fi station<br/>[wifi_sta.c]"]
  node_timesync["Time synchronization<br/>[time_sync.c]"]
end

subgraph group_features["Clock features"]
  node_alarmdata["Alarm data<br/>[alarm_data.c]"]
  node_alarmtask["Alarm scheduler<br/>[alarm_task.c]"]
  node_buzzer["Alarm buzzer<br/>[buzzer.c]"]
  node_stopwatch["Stopwatch<br/>[stopwatch.c]"]
  node_pomodoro["Pomodoro timer<br/>[pomodoro.c]"]
end

subgraph group_assets["UI assets"]
  node_images["Screen backgrounds"]
end

node_user(("Clock user"))
node_device(("ESP32 device"))

node_user -->|"touches"| node_touch
node_touch -->|"sends commands"| node_display
node_display -->|"uses coordinates"| node_layout
node_display -->|"renders screens"| node_images
node_main -->|"initializes"| node_alarmdata
node_main -->|"initializes"| node_display
node_main -->|"initializes"| node_buzzer
node_main -->|"starts"| node_wifi
node_main -->|"starts"| node_timesync
node_main -->|"starts"| node_alarmtask
node_main -->|"starts"| node_stopwatch
node_main -->|"starts"| node_pomodoro
node_display -->|"reads and updates"| node_alarmdata
node_display -->|"starts and stops"| node_buzzer
node_display -->|"controls timer"| node_pomodoro
node_alarmtask -.->|"uses alarm data"| node_alarmdata
node_alarmtask -.->|"reports alarm state"| node_display
node_wifi -.->|"connects to network"| node_device
node_timesync -.->|"synchronizes clock"| node_device

click node_main "https://github.com/tanleee/smart_clock/blob/main/main/src/main.c"
click node_display "https://github.com/tanleee/smart_clock/blob/main/main/src/display.cpp"
click node_touch "https://github.com/tanleee/smart_clock/blob/main/main/src/display.cpp"
click node_layout "https://github.com/tanleee/smart_clock/blob/main/main/inc/ui_layout.h"
click node_images "https://github.com/tanleee/smart_clock/tree/main/main/inc/images"
click node_alarmdata "https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_data.c"
click node_alarmtask "https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_task.c"
click node_buzzer "https://github.com/tanleee/smart_clock/blob/main/main/src/buzzer.c"
click node_stopwatch "https://github.com/tanleee/smart_clock/blob/main/main/src/stopwatch.c"
click node_pomodoro "https://github.com/tanleee/smart_clock/blob/main/main/src/pomodoro.c"
click node_wifi "https://github.com/tanleee/smart_clock/blob/main/main/src/wifi_sta.c"
click node_timesync "https://github.com/tanleee/smart_clock/blob/main/main/src/time_sync.c"

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_main,node_user toneBlue
class node_display,node_touch,node_layout toneAmber
class node_wifi,node_timesync toneMint
class node_alarmdata,node_alarmtask,node_buzzer,node_stopwatch,node_pomodoro toneRose
class node_images,node_device toneIndigo
```

## Components

### Application startup

- [App startup](https://github.com/tanleee/smart_clock/blob/main/main/src/main.c): `main/src/main.c`

### Display and interaction

- [Display task](https://github.com/tanleee/smart_clock/blob/main/main/src/display.cpp): `main/src/display.cpp`
- [Touch handling](https://github.com/tanleee/smart_clock/blob/main/main/src/display.cpp): `main/src/display.cpp`
- [Screen layout](https://github.com/tanleee/smart_clock/blob/main/main/inc/ui_layout.h): `main/inc/ui_layout.h`

### Clock and connectivity

- [Wi-Fi station](https://github.com/tanleee/smart_clock/blob/main/main/src/wifi_sta.c): `main/src/wifi_sta.c`
- [Time synchronization](https://github.com/tanleee/smart_clock/blob/main/main/src/time_sync.c): `main/src/time_sync.c`

### Clock features

- [Alarm data](https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_data.c): `main/src/alarm_data.c`
- [Alarm scheduler](https://github.com/tanleee/smart_clock/blob/main/main/src/alarm_task.c): `main/src/alarm_task.c`
- [Alarm buzzer](https://github.com/tanleee/smart_clock/blob/main/main/src/buzzer.c): `main/src/buzzer.c`
- [Stopwatch](https://github.com/tanleee/smart_clock/blob/main/main/src/stopwatch.c): `main/src/stopwatch.c`
- [Pomodoro timer](https://github.com/tanleee/smart_clock/blob/main/main/src/pomodoro.c): `main/src/pomodoro.c`

### UI assets

- [Screen backgrounds](https://github.com/tanleee/smart_clock/tree/main/main/inc/images): `main/inc/images`

### Other components

- **Clock user**
- **ESP32 device**

## Connections

- Clock user → Touch handling: touches (evidence: `main/src/display.cpp`)
- Touch handling → Display task: sends commands (evidence: `main/src/display.cpp`)
- Display task → Screen layout: uses coordinates (evidence: `main/src/display.cpp`)
- Display task → Screen backgrounds: renders screens (evidence: `main/src/display.cpp`)
- App startup → Alarm data: initializes (evidence: `main/src/main.c`)
- App startup → Display task: initializes (evidence: `main/src/main.c`)
- App startup → Alarm buzzer: initializes (evidence: `main/src/main.c`)
- App startup → Wi-Fi station: starts (evidence: `main/src/main.c`)
- App startup → Time synchronization: starts (evidence: `main/src/main.c`)
- App startup → Alarm scheduler: starts (evidence: `main/src/main.c`)
- App startup → Stopwatch: starts (evidence: `main/src/main.c`)
- App startup → Pomodoro timer: starts (evidence: `main/src/main.c`)
- Display task → Alarm data: reads and updates (evidence: `main/src/display.cpp`)
- Display task → Alarm buzzer: starts and stops (evidence: `main/src/display.cpp`)
- Display task → Pomodoro timer: controls timer (evidence: `main/src/display.cpp`)
- Alarm scheduler → Alarm data: uses alarm data
- Alarm scheduler → Display task: reports alarm state
- Wi-Fi station → ESP32 device: connects to network
- Time synchronization → ESP32 device: synchronizes clock
