# brandonwlii/zero2scraper architecture

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

- Interactive diagram: https://gitdiagram.com/brandonwlii/zero2scraper
- Repository: https://github.com/brandonwlii/zero2scraper

## Overview

story-watch polls configured Instagram accounts, enriches new story items, classifies and filters them, then delivers Discord notifications and records delivery state. A separate Discord bot collects human labels and ping preferences; evaluation tools compare classifier predictions with archived labels. The graph emphasizes these product workflows. Relationships for the watcher are supported by its documented flow and README; some internal details are inferred only where the indexed source references or excerpts support them.

Main entry points: [`story_watch/main.py`](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/main.py) (Polling loop), [`story_watch/evaluation/cli.py`](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/cli.py) (Evaluation CLI), [`story_watch/bot/discord_app.py`](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/discord_app.py) (Labeling bot), [`story_watch/instagram.py`](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/instagram.py) (Story fetcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_watch["Story watcher"]
  node_watcher["Polling loop<br/>[main.py]"]
  node_config["Service config<br/>[config.py]"]
  node_instagram["Story fetcher<br/>[instagram.py]"]
  node_store[("SQLite state<br/>[store.py]")]
  node_archive["Story archive<br/>[archive.py]"]
  node_jobtitles["Job page titles<br/>[jobs.py]"]
end

subgraph group_delivery["Classification and delivery"]
  node_classifier["Classifier<br/>[classify.py]"]
  node_tags["Tag model<br/>[tags.py]"]
  node_filters["Post-type filters<br/>[config.py]"]
  node_pingmatch["Ping matching<br/>[pings.py]"]
  node_notifier["Webhook sender<br/>[notify.py]"]
end

subgraph group_community["Discord bot"]
  node_bot_entry["Bot entry<br/>[main.py]"]
  node_discord_bot["Labeling bot<br/>[discord_app.py]"]
  node_labels["Label storage<br/>[labels.py]"]
  node_prefs_ui["Ping preferences<br/>[pings_app.py]"]
  node_prefs["Preference model<br/>[prefs.py]"]
end

subgraph group_evaluation["Label evaluation"]
  node_evaldata["Evaluation dataset<br/>[data.py]"]
  node_evalrunner["Tagger runner<br/>[runner.py]"]
  node_evalmetrics["Metrics<br/>[metrics.py]"]
  node_evalreport["Report builder<br/>[report.py]"]
  node_evalcli["Evaluation CLI<br/>[cli.py]"]
end

node_operator(("Operator"))
node_instagram_service{{"Instagram"}}
node_discord_service{{"Discord webhook"}}

node_operator -->|"configures and runs"| node_watcher
node_watcher -->|"loads settings"| node_config
node_watcher -->|"fetches stories"| node_instagram
node_instagram -->|"polls accounts"| node_instagram_service
node_watcher -->|"compares and records"| node_store
node_watcher -->|"archives stories"| node_archive
node_watcher -->|"classifies items"| node_classifier
node_classifier -->|"returns tags"| node_tags
node_watcher -->|"enriches job links"| node_jobtitles
node_watcher -->|"sends notifications"| node_notifier
node_watcher -->|"filters post types"| node_filters
node_watcher -->|"matches preferences"| node_pingmatch
node_notifier -->|"posts webhook"| node_discord_service
node_operator -.->|"runs bot"| node_bot_entry
node_bot_entry -->|"starts app"| node_discord_bot
node_discord_bot -->|"saves labels"| node_labels
node_discord_bot -->|"uses story data"| node_instagram
node_prefs_ui -->|"edits preferences"| node_prefs
node_prefs_ui -->|"reads saved preferences"| node_store
node_pingmatch -->|"matches saved rules"| node_prefs
node_evalcli -->|"loads labeled stories"| node_evaldata
node_evalcli -->|"runs taggers"| node_evalrunner
node_evalrunner -->|"uses dataset"| node_evaldata
node_evalcli -->|"computes metrics"| node_evalmetrics
node_evalcli -->|"builds report"| node_evalreport
node_evalreport -->|"renders results"| node_evalmetrics

click node_watcher "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/main.py"
click node_config "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/config.py"
click node_instagram "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/instagram.py"
click node_store "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/store.py"
click node_archive "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/archive.py"
click node_jobtitles "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/jobs.py"
click node_classifier "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/classify.py"
click node_tags "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/tags.py"
click node_filters "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/config.py"
click node_pingmatch "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/pings.py"
click node_notifier "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/notify.py"
click node_bot_entry "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/main.py"
click node_discord_bot "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/discord_app.py"
click node_labels "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/labels.py"
click node_prefs_ui "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/pings_app.py"
click node_prefs "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/prefs.py"
click node_evaldata "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/data.py"
click node_evalrunner "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/runner.py"
click node_evalmetrics "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/metrics.py"
click node_evalreport "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/report.py"
click node_evalcli "https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/cli.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_watcher,node_config,node_instagram,node_store,node_archive,node_jobtitles toneBlue
class node_classifier,node_tags,node_filters,node_pingmatch,node_notifier toneAmber
class node_bot_entry,node_discord_bot,node_labels,node_prefs_ui,node_prefs,node_discord_service toneMint
class node_evaldata,node_evalrunner,node_evalmetrics,node_evalreport,node_evalcli toneRose
class node_operator,node_instagram_service toneIndigo
```

## Components

### Story watcher

- [Polling loop](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/main.py): `story_watch/main.py`
- [Service config](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/config.py): `story_watch/config.py`
- [Story fetcher](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/instagram.py): `story_watch/instagram.py`
- [SQLite state](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/store.py): `story_watch/store.py`
- [Story archive](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/archive.py): `story_watch/archive.py`
- [Job page titles](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/jobs.py): `story_watch/jobs.py`

### Classification and delivery

- [Classifier](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/classify.py): `story_watch/classify.py`
- [Tag model](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/tags.py): `story_watch/tags.py`
- [Post-type filters](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/config.py): `story_watch/config.py`
- [Ping matching](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/pings.py): `story_watch/pings.py`
- [Webhook sender](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/notify.py): `story_watch/notify.py`

### Discord bot

- [Bot entry](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/main.py): `story_watch/bot/main.py`
- [Labeling bot](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/discord_app.py): `story_watch/bot/discord_app.py`
- [Label storage](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/labels.py): `story_watch/bot/labels.py`
- [Ping preferences](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/pings_app.py): `story_watch/bot/pings_app.py`
- [Preference model](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/bot/prefs.py): `story_watch/bot/prefs.py`

### Label evaluation

- [Evaluation dataset](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/data.py): `story_watch/evaluation/data.py`
- [Tagger runner](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/runner.py): `story_watch/evaluation/runner.py`
- [Metrics](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/metrics.py): `story_watch/evaluation/metrics.py`
- [Report builder](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/report.py): `story_watch/evaluation/report.py`
- [Evaluation CLI](https://github.com/brandonwlii/zero2scraper/blob/main/story_watch/evaluation/cli.py): `story_watch/evaluation/cli.py`

### Other components

- **Operator**
- **Instagram**
- **Discord webhook**

## Connections

- Operator → Polling loop: configures and runs
- Polling loop → Service config: loads settings (evidence: `story_watch/main.py`)
- Polling loop → Story fetcher: fetches stories (evidence: `story_watch/main.py`)
- Story fetcher → Instagram: polls accounts
- Polling loop → SQLite state: compares and records (evidence: `story_watch/main.py`)
- Polling loop → Story archive: archives stories (evidence: `story_watch/main.py`)
- Polling loop → Classifier: classifies items (evidence: `story_watch/main.py`)
- Classifier → Tag model: returns tags (evidence: `story_watch/classify.py`)
- Polling loop → Job page titles: enriches job links (evidence: `story_watch/main.py`)
- Polling loop → Webhook sender: sends notifications (evidence: `story_watch/main.py`)
- Polling loop → Post-type filters: filters post types (evidence: `story_watch/main.py`)
- Polling loop → Ping matching: matches preferences (evidence: `story_watch/main.py`)
- Webhook sender → Discord webhook: posts webhook (evidence: `story_watch/notify.py`)
- Operator → Bot entry: runs bot
- Bot entry → Labeling bot: starts app (evidence: `story_watch/bot/main.py`)
- Labeling bot → Label storage: saves labels (evidence: `story_watch/bot/discord_app.py`)
- Labeling bot → Story fetcher: uses story data (evidence: `story_watch/bot/discord_app.py`)
- Ping preferences → Preference model: edits preferences (evidence: `story_watch/bot/pings_app.py`)
- Ping preferences → SQLite state: reads saved preferences (evidence: `story_watch/bot/pings_app.py`)
- Ping matching → Preference model: matches saved rules (evidence: `story_watch/pings.py`)
- Evaluation CLI → Evaluation dataset: loads labeled stories (evidence: `story_watch/evaluation/cli.py`)
- Evaluation CLI → Tagger runner: runs taggers (evidence: `story_watch/evaluation/cli.py`)
- Tagger runner → Evaluation dataset: uses dataset (evidence: `story_watch/evaluation/runner.py`)
- Evaluation CLI → Metrics: computes metrics (evidence: `story_watch/evaluation/cli.py`)
- Evaluation CLI → Report builder: builds report (evidence: `story_watch/evaluation/cli.py`)
- Report builder → Metrics: renders results (evidence: `story_watch/evaluation/report.py`)
