# qu4nd/ha-todo-sync architecture

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

- Interactive diagram: https://gitdiagram.com/qu4nd/ha-todo-sync
- Repository: https://github.com/qu4nd/ha-todo-sync

## Overview

To-do Sync is a local Home Assistant integration that mirrors open items between two selected to-do entities. Users configure a list pair and options; the integration starts a coordinator that reacts to list changes, periodic ticks, or a manual button, reads and normalizes both lists, applies synchronization rules, and persists a three-way snapshot. Status is exposed through a diagnostic sensor. The README documents duplicate cleanup and empty-list protection; their detailed internals are not fully shown in the excerpts, so they are represented as coordinator responsibilities.

Main entry points: [`custom_components/todo_sync/syncer.py`](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py) (Sync coordinator), [`custom_components/todo_sync/__init__.py`](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/__init__.py) (Entry lifecycle), [`custom_components/todo_sync/config_flow.py`](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/config_flow.py) (Pair options), [`custom_components/todo_sync/storage.py`](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/storage.py) (Snapshot storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_config["Pair options<br/>[config_flow.py]"]
end

subgraph group_runtime["Sync runtime"]
  node_entry["Entry lifecycle<br/>[__init__.py]"]
  node_coordinator["Sync coordinator<br/>[syncer.py]"]
  node_list_io["List read and write<br/>[syncer.py]"]
  node_reconcile["Reconcile and deduplicate<br/>[syncer.py]"]
  node_safety["Retry and empty guard<br/>[policy.py]"]
end

subgraph group_state["Models and state"]
  node_identity["Item identity<br/>[models.py]"]
  node_storage[("Snapshot storage<br/>[storage.py]")]
  node_status_model["Sync status<br/>[status.py]"]
end

subgraph group_ha["Home Assistant"]
  node_manual["Sync button<br/>[button.py]"]
  node_diagnostic["Status sensor<br/>[sensor.py]"]
end

node_user(("User"))
node_ha_runtime{{"Home Assistant"}}
node_todo_entities[("To-do entities")]

node_user -->|"selects pair"| node_config
node_config -->|"creates entry"| node_entry
node_ha_runtime -->|"loads entry"| node_entry
node_entry -->|"starts"| node_coordinator
node_entry -->|"forwards setup"| node_manual
node_entry -->|"forwards setup"| node_diagnostic
node_manual -->|"requests sync"| node_coordinator
node_coordinator -->|"reads and updates"| node_todo_entities
node_coordinator -->|"reconciles changes"| node_reconcile
node_coordinator -->|"checks policy"| node_safety
node_coordinator -->|"normalizes identity"| node_identity
node_coordinator -->|"loads and saves"| node_storage
node_coordinator -->|"updates status"| node_status_model
node_storage -->|"uses local store"| node_ha_runtime
node_diagnostic -->|"reads status"| node_coordinator
node_ha_runtime -->|"dispatches list events"| node_coordinator

click node_config "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/config_flow.py"
click node_entry "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/__init__.py"
click node_coordinator "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py"
click node_list_io "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py"
click node_reconcile "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py"
click node_safety "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/policy.py"
click node_identity "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/models.py"
click node_storage "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/storage.py"
click node_status_model "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/status.py"
click node_manual "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/button.py"
click node_diagnostic "https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/sensor.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_config,node_user toneBlue
class node_entry,node_coordinator,node_list_io,node_reconcile,node_safety,node_todo_entities toneAmber
class node_identity,node_storage,node_status_model toneMint
class node_manual,node_diagnostic toneRose
class node_ha_runtime toneIndigo
```

## Components

### Configuration

- [Pair options](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/config_flow.py): `custom_components/todo_sync/config_flow.py`

### Sync runtime

- [Entry lifecycle](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/__init__.py): `custom_components/todo_sync/__init__.py`
- [Sync coordinator](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py): `custom_components/todo_sync/syncer.py`
- [List read and write](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py): `custom_components/todo_sync/syncer.py`
- [Reconcile and deduplicate](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/syncer.py): `custom_components/todo_sync/syncer.py`
- [Retry and empty guard](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/policy.py): `custom_components/todo_sync/policy.py`

### Models and state

- [Item identity](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/models.py): `custom_components/todo_sync/models.py`
- [Snapshot storage](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/storage.py): `custom_components/todo_sync/storage.py`
- [Sync status](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/status.py): `custom_components/todo_sync/status.py`

### Home Assistant

- [Sync button](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/button.py): `custom_components/todo_sync/button.py`
- [Status sensor](https://github.com/qu4nd/ha-todo-sync/blob/main/custom_components/todo_sync/sensor.py): `custom_components/todo_sync/sensor.py`

### Other components

- **User**
- **Home Assistant**
- **To-do entities**

## Connections

- User → Pair options: selects pair (evidence: `README.md`)
- Pair options → Entry lifecycle: creates entry (evidence: `README.md`)
- Home Assistant → Entry lifecycle: loads entry (evidence: `custom_components/todo_sync/__init__.py`)
- Entry lifecycle → Sync coordinator: starts (evidence: `custom_components/todo_sync/__init__.py`)
- Entry lifecycle → Sync button: forwards setup (evidence: `custom_components/todo_sync/__init__.py`)
- Entry lifecycle → Status sensor: forwards setup (evidence: `custom_components/todo_sync/__init__.py`)
- Sync button → Sync coordinator: requests sync (evidence: `custom_components/todo_sync/button.py`)
- Sync coordinator → To-do entities: reads and updates (evidence: `README.md`)
- Sync coordinator → Reconcile and deduplicate: reconciles changes (evidence: `custom_components/todo_sync/syncer.py`)
- Sync coordinator → Retry and empty guard: checks policy (evidence: `custom_components/todo_sync/syncer.py`)
- Sync coordinator → Item identity: normalizes identity (evidence: `custom_components/todo_sync/syncer.py`)
- Sync coordinator → Snapshot storage: loads and saves (evidence: `custom_components/todo_sync/syncer.py`)
- Sync coordinator → Sync status: updates status (evidence: `custom_components/todo_sync/syncer.py`)
- Snapshot storage → Home Assistant: uses local store (evidence: `custom_components/todo_sync/storage.py`)
- Status sensor → Sync coordinator: reads status (evidence: `custom_components/todo_sync/sensor.py`)
- Home Assistant → Sync coordinator: dispatches list events (evidence: `custom_components/todo_sync/syncer.py`)
