# saesh/goal-lights architecture

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

- Interactive diagram: https://gitdiagram.com/saesh/goal-lights
- Repository: https://github.com/saesh/goal-lights

## Overview

goal-lights monitors the Rocket League window, repeatedly captures the goal-display region, detects significant image changes, and fires configured REST events to control team-colored IoT lights. The sampled source shows the main control and image-processing flow; API endpoints and watcher settings are configured externally in settings.yaml, whose contents were not provided.

Main entry points: [`goal-lights.py`](https://github.com/saesh/goal-lights/blob/master/goal-lights.py) (Monitor loop), [`goalwatcher/__init__.py`](https://github.com/saesh/goal-lights/blob/master/goalwatcher/__init__.py) (Image comparison), [`util/__init__.py`](https://github.com/saesh/goal-lights/blob/master/util/__init__.py) (Screen capture), [`settings.yaml`](https://github.com/saesh/goal-lights/blob/master/settings.yaml) (Watcher settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Window capture"]
  node_entry["Monitor loop<br/>[goal-lights.py]"]
  node_config["Watcher settings<br/>[settings.yaml]"]
  node_screenshot["Screen capture<br/>[__init__.py]"]
end

subgraph group_detection["Goal detection"]
  node_watchers["Watcher instances<br/>[goal-lights.py]"]
  node_processor["Image comparison<br/>[__init__.py]"]
  node_color["Team color estimate<br/>[__init__.py]"]
end

subgraph group_events["Light events"]
  node_requests["Configured REST events<br/>[settings.yaml]"]
  node_api["Light control API"]
  node_lights["IoT lights"]
end

subgraph group_support["Shared utilities"]
  node_window["Window lookup<br/>[__init__.py]"]
  node_region["Goal display region<br/>[__init__.py]"]
  node_logging["Log output<br/>[__init__.py]"]
end

node_user(("Player"))
node_game["Rocket League"]

node_user -->|"plays"| node_game
node_entry -->|"loads"| node_config
node_entry -->|"finds window"| node_window
node_entry -->|"sizes capture"| node_region
node_entry -->|"captures"| node_screenshot
node_game -.->|"displays"| node_screenshot
node_entry -->|"creates"| node_watchers
node_entry -->|"passes image"| node_processor
node_watchers -->|"processes frames"| node_processor
node_processor -->|"estimates on goal"| node_color
node_processor -->|"reads events"| node_requests
node_processor -->|"sends REST request"| node_api
node_api -.->|"controls"| node_lights
node_processor -->|"logs response/errors"| node_logging

click node_entry "https://github.com/saesh/goal-lights/blob/master/goal-lights.py"
click node_config "https://github.com/saesh/goal-lights/blob/master/settings.yaml"
click node_window "https://github.com/saesh/goal-lights/blob/master/util/__init__.py"
click node_region "https://github.com/saesh/goal-lights/blob/master/util/__init__.py"
click node_screenshot "https://github.com/saesh/goal-lights/blob/master/util/__init__.py"
click node_watchers "https://github.com/saesh/goal-lights/blob/master/goal-lights.py"
click node_processor "https://github.com/saesh/goal-lights/blob/master/goalwatcher/__init__.py"
click node_color "https://github.com/saesh/goal-lights/blob/master/goalwatcher/__init__.py"
click node_requests "https://github.com/saesh/goal-lights/blob/master/settings.yaml"
click node_logging "https://github.com/saesh/goal-lights/blob/master/util/__init__.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_entry,node_config,node_screenshot toneBlue
class node_watchers,node_processor,node_color toneAmber
class node_requests,node_api,node_lights toneMint
class node_window,node_region,node_logging toneRose
class node_user,node_game toneIndigo
```

## Components

### Window capture

- [Monitor loop](https://github.com/saesh/goal-lights/blob/master/goal-lights.py): `goal-lights.py`
- [Watcher settings](https://github.com/saesh/goal-lights/blob/master/settings.yaml): `settings.yaml`
- [Screen capture](https://github.com/saesh/goal-lights/blob/master/util/__init__.py): `util/__init__.py`

### Goal detection

- [Watcher instances](https://github.com/saesh/goal-lights/blob/master/goal-lights.py): `goal-lights.py`
- [Image comparison](https://github.com/saesh/goal-lights/blob/master/goalwatcher/__init__.py): `goalwatcher/__init__.py`
- [Team color estimate](https://github.com/saesh/goal-lights/blob/master/goalwatcher/__init__.py): `goalwatcher/__init__.py`

### Light events

- [Configured REST events](https://github.com/saesh/goal-lights/blob/master/settings.yaml): `settings.yaml`
- **Light control API**
- **IoT lights**

### Shared utilities

- [Window lookup](https://github.com/saesh/goal-lights/blob/master/util/__init__.py): `util/__init__.py`
- [Goal display region](https://github.com/saesh/goal-lights/blob/master/util/__init__.py): `util/__init__.py`
- [Log output](https://github.com/saesh/goal-lights/blob/master/util/__init__.py): `util/__init__.py`

### Other components

- **Player**
- **Rocket League**

## Connections

- Player → Rocket League: plays (evidence: `README.md`)
- Monitor loop → Watcher settings: loads (evidence: `README.md`)
- Monitor loop → Window lookup: finds window (evidence: `goal-lights.py`)
- Monitor loop → Goal display region: sizes capture (evidence: `goal-lights.py`)
- Monitor loop → Screen capture: captures (evidence: `goal-lights.py`)
- Rocket League → Screen capture: displays
- Monitor loop → Watcher instances: creates (evidence: `goal-lights.py`)
- Monitor loop → Image comparison: passes image (evidence: `goal-lights.py`)
- Watcher instances → Image comparison: processes frames (evidence: `goal-lights.py`)
- Image comparison → Team color estimate: estimates on goal (evidence: `goalwatcher/__init__.py`)
- Image comparison → Configured REST events: reads events (evidence: `goalwatcher/__init__.py`)
- Image comparison → Light control API: sends REST request (evidence: `goalwatcher/__init__.py`)
- Light control API → IoT lights: controls (evidence: `README.md`)
- Image comparison → Log output: logs response/errors (evidence: `goalwatcher/__init__.py`)
