# abhi-0703/whatchanged architecture

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

## Overview

What Changed? watches camera, stream, video, or image-folder frames; filters changes with a pixel-diff gate and settle/budget controls; asks a vision backend to describe meaningful changes and evaluate user rules; then records events for a live timeline, alerts, and Markdown export. The dashboard and headless CLI are separate entry points. The README documents these capabilities; sampled source excerpts show the main orchestration and backend behavior, while some UI, CLI, and detection details are supported only by documentation or the source index.

Main entry points: [`whatchanged/engine.py`](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/engine.py) (Watcher loop), [`app.py`](https://github.com/abhi-0703/whatchanged/blob/main/app.py) (Dashboard), [`whatchanged/backends/gemini_backend.py`](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/gemini_backend.py) (Gemini backend), [`whatchanged/backends/ollama_backend.py`](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/ollama_backend.py) (Ollama backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_dashboard["Dashboard<br/>[app.py]"]
  node_cli["Headless CLI<br/>[cli.py]"]
end

subgraph group_watch["Watching pipeline"]
  node_settings["Settings<br/>[config.py]"]
  node_sources["Frame sources<br/>[sources.py]"]
  node_watcher["Watcher loop<br/>[engine.py]"]
  node_pixelgate["Pixel change gate<br/>[detect.py]"]
end

subgraph group_inference["Inference and reports"]
  node_backendfactory["Backend registry<br/>[__init__.py]"]
  node_backendinterface["Backend interface<br/>[base.py]"]
  node_gemini["Gemini backend<br/>[gemini_backend.py]"]
  node_ollama["Ollama backend<br/>[ollama_backend.py]"]
  node_prompts["Rule prompts<br/>[prompts.py]"]
  node_imaging["Image preparation<br/>[imaging.py]"]
  node_report["Report parsing<br/>[report.py]"]
  node_cache[("Replay response cache<br/>[cache.py]")]
end

subgraph group_history["Events and history"]
  node_store[("Event store<br/>[store.py]")]
end

node_user(("Operator"))
node_modelservice{{"Model service"}}

node_user -->|"configures watch"| node_dashboard
node_user -->|"runs watch"| node_cli
node_dashboard -->|"starts and stops"| node_watcher
node_dashboard -->|"opens source"| node_sources
node_dashboard -->|"selects backend"| node_backendfactory
node_dashboard -->|"loads events"| node_store
node_cli -->|"runs loop"| node_watcher
node_cli -->|"opens source"| node_sources
node_cli -->|"selects backend"| node_backendfactory
node_watcher -->|"reads frames"| node_sources
node_watcher -->|"scores changes"| node_pixelgate
node_watcher -->|"uses thresholds"| node_settings
node_watcher -->|"checks and saves"| node_cache
node_watcher -->|"requests analysis"| node_backendinterface
node_watcher -->|"persists events"| node_store
node_backendfactory -->|"creates backend"| node_gemini
node_backendfactory -->|"creates backend"| node_ollama
node_gemini -->|"sends inference"| node_modelservice
node_ollama -->|"sends inference"| node_modelservice
node_gemini -->|"builds prompt"| node_prompts
node_gemini -->|"encodes frames"| node_imaging
node_gemini -->|"parses response"| node_report
node_ollama -->|"builds prompt"| node_prompts
node_ollama -->|"encodes frames"| node_imaging
node_ollama -->|"parses response"| node_report
node_dashboard -->|"configures options"| node_settings
node_dashboard -->|"exports timeline"| node_store

click node_dashboard "https://github.com/abhi-0703/whatchanged/blob/main/app.py"
click node_cli "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/cli.py"
click node_settings "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/config.py"
click node_sources "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/sources.py"
click node_watcher "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/engine.py"
click node_pixelgate "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/detect.py"
click node_backendfactory "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/__init__.py"
click node_backendinterface "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/base.py"
click node_gemini "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/gemini_backend.py"
click node_ollama "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/ollama_backend.py"
click node_prompts "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/prompts.py"
click node_imaging "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/imaging.py"
click node_report "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/report.py"
click node_cache "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/cache.py"
click node_store "https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/store.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_dashboard,node_cli toneBlue
class node_settings,node_sources,node_watcher,node_pixelgate toneAmber
class node_backendfactory,node_backendinterface,node_gemini,node_ollama,node_prompts,node_imaging,node_report,node_cache toneMint
class node_store toneRose
class node_user,node_modelservice toneIndigo
```

## Components

### User interfaces

- [Dashboard](https://github.com/abhi-0703/whatchanged/blob/main/app.py): `app.py`
- [Headless CLI](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/cli.py): `whatchanged/cli.py`

### Watching pipeline

- [Settings](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/config.py): `whatchanged/config.py`
- [Frame sources](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/sources.py): `whatchanged/sources.py`
- [Watcher loop](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/engine.py): `whatchanged/engine.py`
- [Pixel change gate](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/detect.py): `whatchanged/detect.py`

### Inference and reports

- [Backend registry](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/__init__.py): `whatchanged/backends/__init__.py`
- [Backend interface](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/base.py): `whatchanged/backends/base.py`
- [Gemini backend](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/gemini_backend.py): `whatchanged/backends/gemini_backend.py`
- [Ollama backend](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/backends/ollama_backend.py): `whatchanged/backends/ollama_backend.py`
- [Rule prompts](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/prompts.py): `whatchanged/prompts.py`
- [Image preparation](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/imaging.py): `whatchanged/imaging.py`
- [Report parsing](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/report.py): `whatchanged/report.py`
- [Replay response cache](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/cache.py): `whatchanged/cache.py`

### Events and history

- [Event store](https://github.com/abhi-0703/whatchanged/blob/main/whatchanged/store.py): `whatchanged/store.py`

### Other components

- **Operator**
- **Model service**

## Connections

- Operator → Dashboard: configures watch (evidence: `README.md`)
- Operator → Headless CLI: runs watch (evidence: `README.md`)
- Dashboard → Watcher loop: starts and stops (evidence: `app.py`)
- Dashboard → Frame sources: opens source (evidence: `app.py`)
- Dashboard → Backend registry: selects backend (evidence: `app.py`)
- Dashboard → Event store: loads events (evidence: `app.py`)
- Headless CLI → Watcher loop: runs loop (evidence: `whatchanged/cli.py`)
- Headless CLI → Frame sources: opens source (evidence: `whatchanged/cli.py`)
- Headless CLI → Backend registry: selects backend (evidence: `whatchanged/cli.py`)
- Watcher loop → Frame sources: reads frames (evidence: `whatchanged/engine.py`)
- Watcher loop → Pixel change gate: scores changes (evidence: `whatchanged/engine.py`)
- Watcher loop → Settings: uses thresholds (evidence: `whatchanged/engine.py`)
- Watcher loop → Replay response cache: checks and saves (evidence: `whatchanged/engine.py`)
- Watcher loop → Backend interface: requests analysis (evidence: `whatchanged/engine.py`)
- Watcher loop → Event store: persists events (evidence: `README.md`)
- Backend registry → Gemini backend: creates backend (evidence: `whatchanged/backends/__init__.py`)
- Backend registry → Ollama backend: creates backend (evidence: `whatchanged/backends/__init__.py`)
- Gemini backend → Model service: sends inference (evidence: `whatchanged/backends/gemini_backend.py`)
- Ollama backend → Model service: sends inference (evidence: `whatchanged/backends/ollama_backend.py`)
- Gemini backend → Rule prompts: builds prompt (evidence: `whatchanged/backends/gemini_backend.py`)
- Gemini backend → Image preparation: encodes frames (evidence: `whatchanged/backends/gemini_backend.py`)
- Gemini backend → Report parsing: parses response (evidence: `whatchanged/backends/gemini_backend.py`)
- Ollama backend → Rule prompts: builds prompt (evidence: `whatchanged/backends/ollama_backend.py`)
- Ollama backend → Image preparation: encodes frames (evidence: `whatchanged/backends/ollama_backend.py`)
- Ollama backend → Report parsing: parses response (evidence: `whatchanged/backends/ollama_backend.py`)
- Dashboard → Settings: configures options (evidence: `app.py`)
- Dashboard → Event store: exports timeline (evidence: `README.md`)
