# alamin271/oep-watcher architecture

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

- Interactive diagram: https://gitdiagram.com/alamin271/oep-watcher
- Repository: https://github.com/alamin271/oep-watcher

## Overview

oep-watcher is a small Python monitor that logs into the OEP training site, periodically searches for batches at a configured location, detects batches not seen before, and alerts a Telegram chat. The main loop owns session setup and polling; batch handling owns deduplication, persistence, and notification. The README gives no additional capability detail, so this map reflects the sampled runtime source.

Main entry points: [`oep_batch_watcher.py`](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py) (Polling loop), [`seen_batches.json`](https://github.com/alamin271/oep-watcher/blob/main/seen_batches.json) (Seen batches)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitor["Monitoring"]
  node_main_loop["Polling loop"]
  node_session_setup["Login and filters"]
  node_batch_search["Batch search"]
  node_batch_handler["New-batch detection"]
end

subgraph group_state["State"]
  node_state_io["Seen-batch state"]
  node_state_file[("Seen batches<br/>[seen_batches.json]")]
end

subgraph group_alerts["Alerts"]
  node_notifier["Telegram notifier"]
end

node_operator(("Operator"))
node_oep_site["OEP training site"]
node_telegram["Telegram API"]

node_operator -->|"configures and starts"| node_main_loop
node_main_loop -->|"loads state"| node_state_io
node_main_loop -->|"sets up session"| node_session_setup
node_session_setup -->|"logs in and filters"| node_oep_site
node_main_loop -->|"polls batches"| node_batch_search
node_batch_search -->|"searches and reads"| node_oep_site
node_main_loop -->|"handles results"| node_batch_handler
node_batch_handler -->|"reads and updates"| node_state_io
node_state_io -->|"reads or writes"| node_state_file
node_batch_handler -->|"sends alerts"| node_notifier
node_notifier -->|"posts messages"| node_telegram

click node_main_loop "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py"
click node_session_setup "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py"
click node_batch_search "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py"
click node_batch_handler "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py"
click node_state_io "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py"
click node_state_file "https://github.com/alamin271/oep-watcher/blob/main/seen_batches.json"
click node_notifier "https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.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_main_loop,node_session_setup,node_batch_search,node_batch_handler toneBlue
class node_state_io,node_state_file toneAmber
class node_notifier,node_telegram toneMint
class node_operator,node_oep_site toneIndigo
```

## Components

### Monitoring

- [Polling loop](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`
- [Login and filters](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`
- [Batch search](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`
- [New-batch detection](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`

### State

- [Seen-batch state](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`
- [Seen batches](https://github.com/alamin271/oep-watcher/blob/main/seen_batches.json): `seen_batches.json`

### Alerts

- [Telegram notifier](https://github.com/alamin271/oep-watcher/blob/main/oep_batch_watcher.py): `oep_batch_watcher.py`

### Other components

- **Operator**
- **OEP training site**
- **Telegram API**

## Connections

- Operator → Polling loop: configures and starts (evidence: `oep_batch_watcher.py`)
- Polling loop → Seen-batch state: loads state (evidence: `oep_batch_watcher.py`)
- Polling loop → Login and filters: sets up session (evidence: `oep_batch_watcher.py`)
- Login and filters → OEP training site: logs in and filters (evidence: `oep_batch_watcher.py`)
- Polling loop → Batch search: polls batches (evidence: `oep_batch_watcher.py`)
- Batch search → OEP training site: searches and reads (evidence: `oep_batch_watcher.py`)
- Polling loop → New-batch detection: handles results (evidence: `oep_batch_watcher.py`)
- New-batch detection → Seen-batch state: reads and updates (evidence: `oep_batch_watcher.py`)
- Seen-batch state → Seen batches: reads or writes (evidence: `oep_batch_watcher.py`)
- New-batch detection → Telegram notifier: sends alerts (evidence: `oep_batch_watcher.py`)
- Telegram notifier → Telegram API: posts messages (evidence: `oep_batch_watcher.py`)
