gpt5.5 - odladeni dokumentace dle kodu
Some checks failed
CI and deploy / migration-check (pull_request) Failing after 27s
CI and deploy / deploy (pull_request) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-02 19:17:04 +02:00
parent 3595b24f3b
commit 02f0ab66e4
9 changed files with 161 additions and 114 deletions

View File

@@ -12,12 +12,12 @@
┌─────────────▼───────────────────────────────┐
│ PostgREST │
│ Auto-REST API z PostgreSQL schématu ems │
│ Read: views, tabulky
│ Write: insert/update přes API
│ Read-only: views, vybrané tabulky
│ Write operace jdou přes FastAPI │
└─────────────┬───────────────────────────────┘
│ SQL
┌─────────────▼───────────────────────────────┐
│ PostgreSQL 16 + TimescaleDB │
│ PostgreSQL 18 + TimescaleDB │
│ Schéma: ems │
│ Funkce, views, hypertables │
└─────────────┬───────────────────────────────┘
@@ -26,13 +26,19 @@
│ FastAPI (Python) │
Scheduled tasks (APScheduler) │
telemetry_collector (každých 60s) │
price_importer (13:30, 14:00, 00:05) │
heartbeat (každých 60s) │
price_importer (13:25, 13/14:12, │
│ 13/14:45, 14:00, │
│ 00:05) │
forecast_service (každé 2h, minute 05)│
planning_engine (denně 15:00) │
rolling_replan (každých 15min) │
control_exporter (každých 15min) │
audit_filler (každých 15min) │
forecast_accuracy (:02,:17,:32,:47) │
plan_actual_slot_guard (:05,:20,:35,:50) │
verify_modbus (každé 2 min) │
signal_outbound (každých 15s) │
└──────┬──────────────────────────┬────────────┘
│ Modbus TCP │ HTTP
┌──────▼──────┐ ┌───────▼────────────┐
@@ -59,7 +65,7 @@ FastAPI endpointy pro dashboard a konfiguraci preferují **jedno volání** `sel
| Komponenta | Technologie | Port | Popis |
|---|---|---|---|
| `db` | PostgreSQL 16 + TimescaleDB | 5432 | Datová vrstva |
| `db` | PostgreSQL 18 + TimescaleDB | 5432 | Datová vrstva |
| `postgrest` | PostgREST 12 | 3000 | Auto-REST API |
| `backend` | Python 3.12 / FastAPI | 8000 | Logika, scheduled tasks |
| `frontend` | React + Vite + TypeScript | 5173 (dev) / 80 (prod) | UI |
@@ -88,7 +94,8 @@ ems-platform/
R__019_fn_fill_audit_interval.sql
R__073_fn_health_site_jobs_mode_bundle.sql
(historicky) R__fn_plan_day.sql primární plánování je PuLP v Pythonu
R__fn_create_planning_run.sql
R__037_fn_planning_run_commit.sql
R__063_fn_load_planning_slots_full.sql
views/
R__061_vw_site_effective_price.sql
R__058_vw_latest_telemetry.sql
@@ -114,7 +121,7 @@ ems-platform/
telemetry_collector.py
price_importer.py
forecast_service.py
planning_engine.py ← volá ems.fn_create_planning_run()
planning_engine.py ← PuLP solver, ukládá přes ems.fn_planning_run_commit()
control_exporter.py
audit_filler.py
modbus/
@@ -173,9 +180,10 @@ ems-platform/
Zařízení → Waveshare → Modbus TCP → telemetry_collector → PostgreSQL
```
### Denní plánování (15:00)
### Denní plánování (15:00) a rolling replan
```
PostgreSQL (ceny + forecast) → fn_create_planning_run() → planning_interval
PostgreSQL (ceny + forecast + telemetrie) → planning_engine (PuLP)
→ fn_planning_run_commit() → planning_interval
```
### Operátorské manuální akce (UI)
@@ -200,6 +208,10 @@ Browser → PostgREST (čtení views/tabulek, filtr site_id dle výběru v UI)
Browser → FastAPI (seznam lokalit /me/sites, triggery: replanning, import cen, …)
```
PostgREST je v aktuální produkční konfiguraci určený pro čtení (`ems_anon`
`SELECT` na vybrané views/tabulky). Zápisy a operátorské akce se provádí přes
FastAPI, které používá vlastní DB connection.
---
## Deployment: single-site (výchozí)