# bharat-uniyal/watchdog architecture

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

- Interactive diagram: https://gitdiagram.com/bharat-uniyal/watchdog
- Repository: https://github.com/bharat-uniyal/watchdog

## Overview

Watchdog turns user-defined web watches into scheduled or on-demand TinyFish checks, stores normalized results and diffs in SQLite, and presents a unified feed with an optional Claude digest. The graph follows the documented and excerpted flow; the frontend is a single HTML file and its implementation was not sampled, so its API calls are not asserted.

Main entry points: [`backend/app.py`](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py) (Parallel check runner), [`frontend/index.html`](https://github.com/bharat-uniyal/watchdog/blob/main/frontend/index.html) (Dashboard), [`backend/tinyfish.py`](https://github.com/bharat-uniyal/watchdog/blob/main/backend/tinyfish.py) (TinyFish client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_watch_setup["Watch setup"]
  node_watch_api["Watch management API<br/>[app.py]"]
  node_templates["Watch templates and goals<br/>[app.py]"]
  node_scheduler["Frequency scheduler<br/>[app.py]"]
end

subgraph group_collection["Result collection"]
  node_check_runner["Parallel check runner<br/>[app.py]"]
  node_goal_builder["Goal builder<br/>[app.py]"]
  node_agent_client["TinyFish client<br/>[tinyfish.py]"]
  node_normalizer["Result normalizer<br/>[app.py]"]
end

subgraph group_state_feed["State and feed"]
  node_sqlite[("Watch and result store<br/>[app.py]")]
  node_diff_engine["Item diff engine<br/>[app.py]"]
  node_feed_api["Unified feed API<br/>[app.py]"]
end

subgraph group_digest["Change digest"]
  node_digest_api["Digest API<br/>[app.py]"]
end

node_user(("User"))
node_dashboard["Dashboard<br/>[index.html]"]
node_tinyfish{{"TinyFish Agent API"}}
node_claude{{"Claude Messages API"}}

node_user -->|"uses"| node_dashboard
node_dashboard -.->|"manages watches"| node_watch_api
node_watch_api -->|"validates"| node_templates
node_scheduler -->|"checks due watches"| node_check_runner
node_watch_api -->|"starts checks"| node_check_runner
node_check_runner -->|"builds goals"| node_goal_builder
node_check_runner -->|"runs agent"| node_agent_client
node_agent_client -->|"requests extraction"| node_tinyfish
node_check_runner -->|"normalizes result"| node_normalizer
node_watch_api -->|"stores watches"| node_sqlite
node_check_runner -->|"reads and writes results"| node_sqlite
node_check_runner -->|"computes changes"| node_diff_engine
node_diff_engine -->|"loads prior items"| node_sqlite
node_feed_api -->|"reads latest results"| node_sqlite
node_dashboard -.->|"shows feed"| node_feed_api
node_dashboard -.->|"requests digest"| node_digest_api
node_digest_api -->|"collects changes"| node_feed_api
node_digest_api -->|"summarizes changes"| node_claude
node_digest_api -.->|"returns digest"| node_dashboard

click node_dashboard "https://github.com/bharat-uniyal/watchdog/blob/main/frontend/index.html"
click node_watch_api "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_templates "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_scheduler "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_check_runner "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_goal_builder "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_agent_client "https://github.com/bharat-uniyal/watchdog/blob/main/backend/tinyfish.py"
click node_normalizer "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_sqlite "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_diff_engine "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_feed_api "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py"
click node_digest_api "https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.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_watch_api,node_templates,node_scheduler,node_user toneBlue
class node_check_runner,node_goal_builder,node_agent_client,node_normalizer toneAmber
class node_sqlite,node_diff_engine,node_feed_api,node_tinyfish,node_claude toneMint
class node_digest_api toneRose
class node_dashboard toneTeal
```

## Components

### Watch setup

- [Watch management API](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [Watch templates and goals](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [Frequency scheduler](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`

### Result collection

- [Parallel check runner](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [Goal builder](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [TinyFish client](https://github.com/bharat-uniyal/watchdog/blob/main/backend/tinyfish.py): `backend/tinyfish.py`
- [Result normalizer](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`

### State and feed

- [Watch and result store](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [Item diff engine](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`
- [Unified feed API](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`

### Change digest

- [Digest API](https://github.com/bharat-uniyal/watchdog/blob/main/backend/app.py): `backend/app.py`

### Other components

- **User**
- [Dashboard](https://github.com/bharat-uniyal/watchdog/blob/main/frontend/index.html): `frontend/index.html`
- **TinyFish Agent API**
- **Claude Messages API**

## Connections

- User → Dashboard: uses (evidence: `README.md`)
- Dashboard → Watch management API: manages watches (evidence: `README.md`)
- Watch management API → Watch templates and goals: validates (evidence: `backend/app.py`)
- Frequency scheduler → Parallel check runner: checks due watches (evidence: `backend/app.py`)
- Watch management API → Parallel check runner: starts checks (evidence: `backend/app.py`)
- Parallel check runner → Goal builder: builds goals (evidence: `backend/app.py`)
- Parallel check runner → TinyFish client: runs agent (evidence: `backend/app.py`)
- TinyFish client → TinyFish Agent API: requests extraction (evidence: `backend/tinyfish.py`)
- Parallel check runner → Result normalizer: normalizes result (evidence: `backend/app.py`)
- Watch management API → Watch and result store: stores watches (evidence: `backend/app.py`)
- Parallel check runner → Watch and result store: reads and writes results (evidence: `backend/app.py`)
- Parallel check runner → Item diff engine: computes changes (evidence: `backend/app.py`)
- Item diff engine → Watch and result store: loads prior items (evidence: `backend/app.py`)
- Unified feed API → Watch and result store: reads latest results (evidence: `backend/app.py`)
- Dashboard → Unified feed API: shows feed (evidence: `README.md`)
- Dashboard → Digest API: requests digest (evidence: `README.md`)
- Digest API → Unified feed API: collects changes (evidence: `backend/app.py`)
- Digest API → Claude Messages API: summarizes changes (evidence: `backend/app.py`)
- Digest API → Dashboard: returns digest (evidence: `README.md`)
