# thecodedose/kdashboard architecture

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

## Overview

Kindle Planner Dashboard is a self-hosted planner and home dashboard: people update lists through Telegram or the Kindle, while the Kindle displays planner, health, calendar, delivery, vacuum, and music information. Its cloud layer exposes dashboard and integration endpoints backed by per-owner InsForge data; an optional iOS companion uploads Apple Health summaries. The graph preserves documented capabilities, but several backend and native integration internals were not excerpted, so only documented or excerpt-supported relationships are connected.

Main entry points: [`kindle/native/src/kindle_dashboard.cpp`](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/kindle_dashboard.cpp) (Dashboard renderer), [`migrations`](https://github.com/thecodedose/kdashboard/tree/main/migrations) (Planner database), [`functions/telegram-webhook.ts`](https://github.com/thecodedose/kdashboard/blob/main/functions/telegram-webhook.ts) (Telegram actions), [`ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift`](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift) (Upload client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kindle["Kindle dashboard"]
  node_kindle_app["Dashboard renderer"]
  node_vacuum_client["Narwal client<br/>[narwal_client.hpp]"]
end

subgraph group_backend["InsForge backend"]
  node_db[("Planner database")]
  node_dashboard_data["Dashboard data"]
  node_dashboard_events["Live events"]
  node_dashboard_toggle["Item toggles"]
  node_dashboard_info["Dashboard info"]
  node_dashboard_version["Version checks"]
  node_dashboard_widgets["Widgets"]
  node_dashboard_music["Music endpoint"]
  node_dashboard_orders["Delivery summaries"]
  node_telegram_webhook["Telegram actions"]
  node_health_sync["Apple Health upload<br/>[health-sync.ts]"]
  node_google_health_sync["Google Health sync"]
end

subgraph group_ios["Health companion"]
  node_ios_ui["Companion interface<br/>[ContentView.swift]"]
  node_ios_viewmodel["Sync coordinator"]
  node_healthkit["HealthKit reader"]
  node_sync_client["Upload client"]
  node_app_config["Sync configuration<br/>[AppConfig.swift]"]
  node_app_delegate["Background sync<br/>[AppDelegate.swift]"]
  node_health_models["Health data models"]
  node_companion_app["iOS app entry"]
end

subgraph group_integrations["External integrations"]
  node_telegram(("Telegram user"))
  node_telegram_service["Telegram Bot API"]
  node_openai["OpenAI"]
  node_apple_health["Apple Health"]
  node_google_services["Google Health and Calendar"]
  node_spotify_service["Spotify"]
  node_narwal_vacuum["Narwal vacuum"]
end

subgraph group_native_audio["Native audio"]
  node_spotify_control["Spotify controls<br/>[spotify_control.c]"]
  node_spotify_mixer["Audio mixer<br/>[spotify_mixer.c]"]
  node_spotify_pcm["PCM audio<br/>[spotify_pcm.c]"]
end

node_kindle_user(("Kindle user"))

node_kindle_user -->|"uses"| node_kindle_app
node_kindle_app -.->|"fetches dashboard"| node_dashboard_data
node_kindle_app -.->|"sends toggles"| node_dashboard_toggle
node_kindle_app -.->|"receives events"| node_dashboard_events
node_kindle_app -.->|"requests info"| node_dashboard_info
node_kindle_app -.->|"checks version"| node_dashboard_version
node_kindle_app -.->|"loads widgets"| node_dashboard_widgets
node_kindle_app -.->|"controls music"| node_dashboard_music
node_kindle_app -.->|"loads summaries"| node_dashboard_orders
node_kindle_app -->|"uses"| node_vacuum_client
node_vacuum_client -.->|"controls locally"| node_narwal_vacuum
node_kindle_app -.->|"dispatches controls"| node_spotify_control
node_spotify_control -.->|"mixes audio"| node_spotify_mixer
node_spotify_mixer -.->|"outputs PCM"| node_spotify_pcm
node_spotify_control -.->|"controls playback"| node_spotify_service
node_dashboard_data -->|"reads planner data"| node_db
node_dashboard_toggle -->|"updates items"| node_db
node_dashboard_events -.->|"streams updates"| node_db
node_dashboard_info -.->|"reads info"| node_db
node_dashboard_version -.->|"reads state"| node_db
node_dashboard_widgets -.->|"reads widget data"| node_db
node_dashboard_music -.->|"reads music state"| node_db
node_dashboard_orders -.->|"reads summaries"| node_db
node_telegram -->|"sends updates"| node_telegram_service
node_telegram_service -->|"posts webhook"| node_telegram_webhook
node_telegram_webhook -->|"writes planner data"| node_db
node_telegram_webhook -.->|"parses optionally"| node_openai
node_telegram_webhook -->|"sends confirmation"| node_telegram_service
node_companion_app -->|"presents"| node_ios_ui
node_ios_ui -->|"invokes"| node_ios_viewmodel
node_app_delegate -->|"starts observers"| node_healthkit
node_ios_viewmodel -->|"fetches summaries"| node_healthkit
node_ios_viewmodel -->|"uploads summaries"| node_sync_client
node_sync_client -->|"loads endpoint config"| node_app_config
node_healthkit -->|"reads aggregates"| node_apple_health
node_sync_client -->|"posts summaries"| node_health_sync
node_health_sync -->|"stores summaries"| node_db
node_health_models -.->|"encodes payload data"| node_sync_client
node_google_services -.->|"syncs health data"| node_google_health_sync
node_google_services -.->|"provides calendar data"| node_dashboard_data

click node_kindle_app "https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/kindle_dashboard.cpp"
click node_vacuum_client "https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/narwal_client.hpp"
click node_spotify_control "https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_control.c"
click node_spotify_mixer "https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_mixer.c"
click node_spotify_pcm "https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_pcm.c"
click node_db "https://github.com/thecodedose/kdashboard/tree/main/migrations"
click node_dashboard_data "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-data.ts"
click node_dashboard_events "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-events.ts"
click node_dashboard_toggle "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-toggle.ts"
click node_dashboard_info "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-info.ts"
click node_dashboard_version "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-version.ts"
click node_dashboard_widgets "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-widgets.ts"
click node_dashboard_music "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-music.ts"
click node_dashboard_orders "https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-orders.ts"
click node_telegram_webhook "https://github.com/thecodedose/kdashboard/blob/main/functions/telegram-webhook.ts"
click node_health_sync "https://github.com/thecodedose/kdashboard/blob/main/functions/health-sync.ts"
click node_google_health_sync "https://github.com/thecodedose/kdashboard/blob/main/functions/google-health-sync.ts"
click node_ios_ui "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/ContentView.swift"
click node_ios_viewmodel "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/SyncViewModel.swift"
click node_healthkit "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthKitSyncService.swift"
click node_sync_client "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift"
click node_app_config "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/AppConfig.swift"
click node_app_delegate "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/AppDelegate.swift"
click node_health_models "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncModels.swift"
click node_companion_app "https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncCompanionApp.swift"

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_kindle_app,node_vacuum_client,node_kindle_user toneBlue
class node_db,node_dashboard_data,node_dashboard_events,node_dashboard_toggle,node_dashboard_info,node_dashboard_version,node_dashboard_widgets,node_dashboard_music,node_dashboard_orders,node_telegram_webhook,node_health_sync,node_google_health_sync toneAmber
class node_ios_ui,node_ios_viewmodel,node_healthkit,node_sync_client,node_app_config,node_app_delegate,node_health_models,node_companion_app toneMint
class node_telegram,node_telegram_service,node_openai,node_apple_health,node_google_services,node_spotify_service,node_narwal_vacuum toneRose
class node_spotify_control,node_spotify_mixer,node_spotify_pcm toneIndigo
```

## Components

### Kindle dashboard

- [Dashboard renderer](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/kindle_dashboard.cpp): `kindle/native/src/kindle_dashboard.cpp`
- [Narwal client](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/narwal_client.hpp): `kindle/native/src/narwal_client.hpp`

### InsForge backend

- [Planner database](https://github.com/thecodedose/kdashboard/tree/main/migrations): `migrations`
- [Dashboard data](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-data.ts): `functions/kindle-dashboard-data.ts`
- [Live events](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-events.ts): `functions/kindle-dashboard-events.ts`
- [Item toggles](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-toggle.ts): `functions/kindle-dashboard-toggle.ts`
- [Dashboard info](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-info.ts): `functions/kindle-dashboard-info.ts`
- [Version checks](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-version.ts): `functions/kindle-dashboard-version.ts`
- [Widgets](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-widgets.ts): `functions/kindle-dashboard-widgets.ts`
- [Music endpoint](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-music.ts): `functions/kindle-dashboard-music.ts`
- [Delivery summaries](https://github.com/thecodedose/kdashboard/blob/main/functions/kindle-dashboard-orders.ts): `functions/kindle-dashboard-orders.ts`
- [Telegram actions](https://github.com/thecodedose/kdashboard/blob/main/functions/telegram-webhook.ts): `functions/telegram-webhook.ts`
- [Apple Health upload](https://github.com/thecodedose/kdashboard/blob/main/functions/health-sync.ts): `functions/health-sync.ts`
- [Google Health sync](https://github.com/thecodedose/kdashboard/blob/main/functions/google-health-sync.ts): `functions/google-health-sync.ts`

### Health companion

- [Companion interface](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/ContentView.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/ContentView.swift`
- [Sync coordinator](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/SyncViewModel.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/SyncViewModel.swift`
- [HealthKit reader](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthKitSyncService.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/HealthKitSyncService.swift`
- [Upload client](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift`
- [Sync configuration](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/AppConfig.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/AppConfig.swift`
- [Background sync](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/AppDelegate.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/AppDelegate.swift`
- [Health data models](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncModels.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncModels.swift`
- [iOS app entry](https://github.com/thecodedose/kdashboard/blob/main/ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncCompanionApp.swift): `ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncCompanionApp.swift`

### External integrations

- **Telegram user**
- **Telegram Bot API**
- **OpenAI**
- **Apple Health**
- **Google Health and Calendar**
- **Spotify**
- **Narwal vacuum**

### Native audio

- [Spotify controls](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_control.c): `kindle/native/src/spotify_control.c`
- [Audio mixer](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_mixer.c): `kindle/native/src/spotify_mixer.c`
- [PCM audio](https://github.com/thecodedose/kdashboard/blob/main/kindle/native/src/spotify_pcm.c): `kindle/native/src/spotify_pcm.c`

### Other components

- **Kindle user**

## Connections

- Kindle user → Dashboard renderer: uses (evidence: `README.md`)
- Dashboard renderer → Dashboard data: fetches dashboard
- Dashboard renderer → Item toggles: sends toggles
- Dashboard renderer → Live events: receives events
- Dashboard renderer → Dashboard info: requests info
- Dashboard renderer → Version checks: checks version
- Dashboard renderer → Widgets: loads widgets
- Dashboard renderer → Music endpoint: controls music
- Dashboard renderer → Delivery summaries: loads summaries
- Dashboard renderer → Narwal client: uses (evidence: `kindle/native/src/kindle_dashboard.cpp`)
- Narwal client → Narwal vacuum: controls locally
- Dashboard renderer → Spotify controls: dispatches controls
- Spotify controls → Audio mixer: mixes audio
- Audio mixer → PCM audio: outputs PCM
- Spotify controls → Spotify: controls playback
- Dashboard data → Planner database: reads planner data (evidence: `README.md`)
- Item toggles → Planner database: updates items (evidence: `README.md`)
- Live events → Planner database: streams updates
- Dashboard info → Planner database: reads info
- Version checks → Planner database: reads state
- Widgets → Planner database: reads widget data
- Music endpoint → Planner database: reads music state
- Delivery summaries → Planner database: reads summaries
- Telegram user → Telegram Bot API: sends updates (evidence: `README.md`)
- Telegram Bot API → Telegram actions: posts webhook (evidence: `README.md`)
- Telegram actions → Planner database: writes planner data (evidence: `functions/telegram-webhook.ts`)
- Telegram actions → OpenAI: parses optionally (evidence: `functions/telegram-webhook.ts`)
- Telegram actions → Telegram Bot API: sends confirmation (evidence: `README.md`)
- iOS app entry → Companion interface: presents (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncCompanionApp.swift`)
- Companion interface → Sync coordinator: invokes (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/ContentView.swift`)
- Background sync → HealthKit reader: starts observers (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/AppDelegate.swift`)
- Sync coordinator → HealthKit reader: fetches summaries (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/SyncViewModel.swift`)
- Sync coordinator → Upload client: uploads summaries (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/SyncViewModel.swift`)
- Upload client → Sync configuration: loads endpoint config (evidence: `ios/HealthSyncCompanion/HealthSyncCompanion/HealthSyncClient.swift`)
- HealthKit reader → Apple Health: reads aggregates (evidence: `README.md`)
- Upload client → Apple Health upload: posts summaries (evidence: `README.md`)
- Apple Health upload → Planner database: stores summaries (evidence: `README.md`)
- Health data models → Upload client: encodes payload data
- Google Health and Calendar → Google Health sync: syncs health data
- Google Health and Calendar → Dashboard data: provides calendar data
