# colterize/lega-watch architecture

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

- Interactive diagram: https://gitdiagram.com/colterize/lega-watch
- Repository: https://github.com/colterize/lega-watch

## Overview

Lega Watch is an Apple Watch air-quality monitor. The user opens a list of locations, selects one, and sees its current sensor status and a summary; the row and detail view independently request the selected sensor’s latest Firebase gas reading. FirebaseViewModel converts readings into a smoke value and health status. The repository also includes a report/chart model and watch notification and complication entry points. Source excerpts establish the main view and data calls; unsampled notification, complication, and chart behavior is not inferred beyond the shown code and index references.

Main entry points: [`Lega Watch WatchKit Extension/FirebaseViewModel.swift`](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/FirebaseViewModel.swift) (Firebase view model), [`Lega Watch WatchKit Extension/Lega_WatchApp.swift`](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Lega_WatchApp.swift) (Watch app), [`Lega Watch WatchKit Extension/Views/LocationView.swift`](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationView.swift) (Location list), [`Lega Watch WatchKit Extension/Views/LocationDetailView.swift`](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationDetailView.swift) (Location detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_watch_ui["Watch interface"]
  node_app["Watch app"]
  node_location_list["Location list<br/>[LocationView.swift]"]
  node_location_row["Location row<br/>[LocationRow.swift]"]
  node_location_detail["Location detail"]
  node_location_pulse["Live status"]
  node_location_summary["Location summary"]
  node_chart["Report chart<br/>[ChartView.swift]"]
end

subgraph group_sensor["Sensor readings"]
  node_firebase_model["Firebase view model"]
end

subgraph group_location_data["Location and reports"]
  node_lega_data["Location definitions<br/>[ModelData.swift]"]
  node_report["Hourly reports<br/>[Report.swift]"]
end

subgraph group_watch_system["Watch features"]
  node_notification_controller["Notification host"]
  node_notification_view["Notification view"]
  node_complication["Complication source"]
end

node_user(("Watch user"))
node_firebase[("Firebase Realtime Database")]
node_watchkit(("WatchKit runtime"))

node_user -->|"opens"| node_app
node_app -->|"shows"| node_location_list
node_app -->|"registers"| node_notification_controller
node_location_list -->|"renders"| node_location_row
node_location_list -->|"navigates"| node_location_detail
node_location_row -->|"requests reading"| node_firebase_model
node_location_detail -->|"shows"| node_location_pulse
node_location_detail -->|"shows"| node_location_summary
node_location_pulse -->|"requests reading"| node_firebase_model
node_firebase_model -->|"reads latest value"| node_firebase
node_firebase_model -->|"records reading"| node_report
node_chart -->|"plots reports"| node_report
node_notification_controller -->|"hosts"| node_notification_view
node_watchkit -.->|"presents"| node_notification_controller
node_watchkit -.->|"requests timeline"| node_complication

click node_app "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Lega_WatchApp.swift"
click node_location_list "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationView.swift"
click node_location_row "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationRow.swift"
click node_location_detail "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationDetailView.swift"
click node_location_pulse "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationPulsation.swift"
click node_location_summary "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationSummary.swift"
click node_firebase_model "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/FirebaseViewModel.swift"
click node_lega_data "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Model/ModelData.swift"
click node_report "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Model/Report.swift"
click node_chart "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/ChartView.swift"
click node_notification_controller "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/NotificationController.swift"
click node_notification_view "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/NotificationView.swift"
click node_complication "https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/ComplicationController.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_app,node_location_list,node_location_row,node_location_detail,node_location_pulse,node_location_summary,node_chart,node_user toneBlue
class node_firebase_model,node_firebase toneAmber
class node_lega_data,node_report toneMint
class node_notification_controller,node_notification_view,node_complication toneRose
class node_watchkit toneIndigo
```

## Components

### Watch interface

- [Watch app](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Lega_WatchApp.swift): `Lega Watch WatchKit Extension/Lega_WatchApp.swift`
- [Location list](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationView.swift): `Lega Watch WatchKit Extension/Views/LocationView.swift`
- [Location row](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationRow.swift): `Lega Watch WatchKit Extension/Views/LocationRow.swift`
- [Location detail](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationDetailView.swift): `Lega Watch WatchKit Extension/Views/LocationDetailView.swift`
- [Live status](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationPulsation.swift): `Lega Watch WatchKit Extension/Views/LocationPulsation.swift`
- [Location summary](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/LocationSummary.swift): `Lega Watch WatchKit Extension/Views/LocationSummary.swift`
- [Report chart](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Views/ChartView.swift): `Lega Watch WatchKit Extension/Views/ChartView.swift`

### Sensor readings

- [Firebase view model](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/FirebaseViewModel.swift): `Lega Watch WatchKit Extension/FirebaseViewModel.swift`

### Location and reports

- [Location definitions](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Model/ModelData.swift): `Lega Watch WatchKit Extension/Model/ModelData.swift`
- [Hourly reports](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/Model/Report.swift): `Lega Watch WatchKit Extension/Model/Report.swift`

### Watch features

- [Notification host](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/NotificationController.swift): `Lega Watch WatchKit Extension/NotificationController.swift`
- [Notification view](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/NotificationView.swift): `Lega Watch WatchKit Extension/NotificationView.swift`
- [Complication source](https://github.com/colterize/lega-watch/blob/main/Lega%20Watch%20WatchKit%20Extension/ComplicationController.swift): `Lega Watch WatchKit Extension/ComplicationController.swift`

### Other components

- **Watch user**
- **Firebase Realtime Database**
- **WatchKit runtime**

## Connections

- Watch user → Watch app: opens (evidence: `Lega Watch WatchKit Extension/Lega_WatchApp.swift`)
- Watch app → Location list: shows (evidence: `Lega Watch WatchKit Extension/Lega_WatchApp.swift`)
- Watch app → Notification host: registers (evidence: `Lega Watch WatchKit Extension/Lega_WatchApp.swift`)
- Location list → Location row: renders (evidence: `Lega Watch WatchKit Extension/Views/LocationView.swift`)
- Location list → Location detail: navigates (evidence: `Lega Watch WatchKit Extension/Views/LocationView.swift`)
- Location row → Firebase view model: requests reading (evidence: `Lega Watch WatchKit Extension/Views/LocationRow.swift`)
- Location detail → Live status: shows (evidence: `Lega Watch WatchKit Extension/Views/LocationDetailView.swift`)
- Location detail → Location summary: shows (evidence: `Lega Watch WatchKit Extension/Views/LocationDetailView.swift`)
- Live status → Firebase view model: requests reading (evidence: `Lega Watch WatchKit Extension/Views/LocationPulsation.swift`)
- Firebase view model → Firebase Realtime Database: reads latest value (evidence: `Lega Watch WatchKit Extension/FirebaseViewModel.swift`)
- Firebase view model → Hourly reports: records reading (evidence: `Lega Watch WatchKit Extension/FirebaseViewModel.swift`)
- Report chart → Hourly reports: plots reports (evidence: `Lega Watch WatchKit Extension/Views/ChartView.swift`)
- Notification host → Notification view: hosts (evidence: `Lega Watch WatchKit Extension/NotificationController.swift`)
- WatchKit runtime → Notification host: presents
- WatchKit runtime → Complication source: requests timeline
