# lutz2cru/sp-bot architecture

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

- Interactive diagram: https://gitdiagram.com/lutz2cru/sp-bot
- Repository: https://github.com/lutz2cru/sp-bot

## Overview

SP-Bot surveille les stations Total dans des zones configurées et alerte sur les changements confirmés de stock. Le parcours va de la commande de vérification au téléchargement et à la normalisation des relevés, puis à leur comparaison avec l’état antérieur, à la mise en file des événements et à leur remise via Ntfy. Le CLI propose aussi un tableau de bord, une boucle locale et un test de notification. Les liens non explicitement visibles dans les extraits ne sont conservés que lorsqu’ils sont documentés par le README.

Main entry points: [`main.py`](https://github.com/lutz2cru/sp-bot/blob/main/main.py) (CLI et tableau), [`src/fetcher.py`](https://github.com/lutz2cru/sp-bot/blob/main/src/fetcher.py) (Collecte stations), [`src/tracker.py`](https://github.com/lutz2cru/sp-bot/blob/main/src/tracker.py) (Suivi et événements), [`src/notifier.py`](https://github.com/lutz2cru/sp-bot/blob/main/src/notifier.py) (Envoi Ntfy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Pilotage et configuration"]
  node_cli["CLI et tableau<br/>[main.py]"]
  node_settings["Configuration<br/>[config.py]"]
end

subgraph group_collection["Collecte des stocks"]
  node_station_fetch["Collecte stations<br/>[fetcher.py]"]
  node_cross_fetch["Flux officiel de contrôle<br/>[fetcher.py]"]
end

subgraph group_monitoring["Suivi et vérification"]
  node_tracker["Suivi et événements<br/>[tracker.py]"]
  node_state[("État et outbox<br/>[state.json]")]
  node_clock["Temps et dates<br/>[timeutil.py]"]
end

subgraph group_delivery["Alertes et remise"]
  node_notify_manager["Gestion notifications<br/>[notifier.py]"]
  node_ntfy_sender["Envoi Ntfy<br/>[notifier.py]"]
end

node_operator(("Opérateur"))
node_scheduler(("GitHub Actions"))
node_station_api["API stations"]
node_geo_api["Géocodage officiel"]
node_ministry_feed["Flux carburants officiel"]
node_ntfy_service["Service Ntfy"]
node_subscriber(("Abonné mobile"))

node_operator -->|"lance commande"| node_cli
node_scheduler -->|"déclenche check"| node_cli
node_cli -->|"charge paramètres"| node_settings
node_settings -->|"géocode commune"| node_geo_api
node_cli -->|"récupère stations"| node_station_fetch
node_station_fetch -->|"interroge"| node_station_api
node_station_fetch -->|"applique filtres"| node_settings
node_station_fetch -->|"normalise relevés"| node_cross_fetch
node_cross_fetch -->|"lit le flux"| node_ministry_feed
node_cli -->|"traite relevés"| node_tracker
node_tracker -->|"recoupe changements"| node_cross_fetch
node_tracker -->|"lit et écrit"| node_state
node_tracker -->|"calcule délais"| node_clock
node_cli -->|"remet alertes"| node_notify_manager
node_notify_manager -->|"délègue envoi"| node_ntfy_sender
node_ntfy_sender -->|"publie message"| node_ntfy_service
node_ntfy_sender -->|"formate horaires"| node_clock
node_ntfy_service -->|"livre push"| node_subscriber

click node_cli "https://github.com/lutz2cru/sp-bot/blob/main/main.py"
click node_settings "https://github.com/lutz2cru/sp-bot/blob/main/src/config.py"
click node_station_fetch "https://github.com/lutz2cru/sp-bot/blob/main/src/fetcher.py"
click node_cross_fetch "https://github.com/lutz2cru/sp-bot/blob/main/src/fetcher.py"
click node_tracker "https://github.com/lutz2cru/sp-bot/blob/main/src/tracker.py"
click node_state "https://github.com/lutz2cru/sp-bot/blob/main/data/state.json"
click node_clock "https://github.com/lutz2cru/sp-bot/blob/main/src/timeutil.py"
click node_notify_manager "https://github.com/lutz2cru/sp-bot/blob/main/src/notifier.py"
click node_ntfy_sender "https://github.com/lutz2cru/sp-bot/blob/main/src/notifier.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_cli,node_settings toneBlue
class node_station_fetch,node_cross_fetch toneAmber
class node_tracker,node_state,node_clock,node_station_api toneMint
class node_notify_manager,node_ntfy_sender toneRose
class node_operator,node_scheduler,node_geo_api,node_ministry_feed,node_ntfy_service,node_subscriber toneIndigo
```

## Components

### Pilotage et configuration

- [CLI et tableau](https://github.com/lutz2cru/sp-bot/blob/main/main.py): `main.py`
- [Configuration](https://github.com/lutz2cru/sp-bot/blob/main/src/config.py): `src/config.py`

### Collecte des stocks

- [Collecte stations](https://github.com/lutz2cru/sp-bot/blob/main/src/fetcher.py): `src/fetcher.py`
- [Flux officiel de contrôle](https://github.com/lutz2cru/sp-bot/blob/main/src/fetcher.py): `src/fetcher.py`

### Suivi et vérification

- [Suivi et événements](https://github.com/lutz2cru/sp-bot/blob/main/src/tracker.py): `src/tracker.py`
- [État et outbox](https://github.com/lutz2cru/sp-bot/blob/main/data/state.json): `data/state.json`
- [Temps et dates](https://github.com/lutz2cru/sp-bot/blob/main/src/timeutil.py): `src/timeutil.py`

### Alertes et remise

- [Gestion notifications](https://github.com/lutz2cru/sp-bot/blob/main/src/notifier.py): `src/notifier.py`
- [Envoi Ntfy](https://github.com/lutz2cru/sp-bot/blob/main/src/notifier.py): `src/notifier.py`

### Other components

- **Opérateur**
- **GitHub Actions**
- **API stations**
- **Géocodage officiel**
- **Flux carburants officiel**
- **Service Ntfy**
- **Abonné mobile**

## Connections

- Opérateur → CLI et tableau: lance commande (evidence: `README.md`)
- GitHub Actions → CLI et tableau: déclenche check (evidence: `README.md`)
- CLI et tableau → Configuration: charge paramètres (evidence: `main.py`)
- Configuration → Géocodage officiel: géocode commune (evidence: `src/config.py`)
- CLI et tableau → Collecte stations: récupère stations (evidence: `main.py`)
- Collecte stations → API stations: interroge (evidence: `README.md`)
- Collecte stations → Configuration: applique filtres (evidence: `src/fetcher.py`)
- Collecte stations → Flux officiel de contrôle: normalise relevés (evidence: `src/fetcher.py`)
- Flux officiel de contrôle → Flux carburants officiel: lit le flux (evidence: `src/fetcher.py`)
- CLI et tableau → Suivi et événements: traite relevés (evidence: `README.md`)
- Suivi et événements → Flux officiel de contrôle: recoupe changements (evidence: `README.md`)
- Suivi et événements → État et outbox: lit et écrit (evidence: `src/tracker.py`)
- Suivi et événements → Temps et dates: calcule délais (evidence: `src/tracker.py`)
- CLI et tableau → Gestion notifications: remet alertes (evidence: `main.py`)
- Gestion notifications → Envoi Ntfy: délègue envoi (evidence: `src/notifier.py`)
- Envoi Ntfy → Service Ntfy: publie message (evidence: `src/notifier.py`)
- Envoi Ntfy → Temps et dates: formate horaires (evidence: `src/notifier.py`)
- Service Ntfy → Abonné mobile: livre push (evidence: `README.md`)
