Skip to content

Architecture Overview

flowchart TD
    DB[("PostgreSQL
Online Database")] WS[("SQLite
Local Database")] BE["Backend
config · database · websocket
ml · model_handler · model_io
prediction_db · generic · logger"] CFG["Configs
constants · YAML model configs"] MOD["Models
LSTM · XGBoost
LinearRegression"] SVC["Services
data_loader · experiment_*
model_manager · simulation_worker
prediction_evaluator · *_tab_logic"] UI["UI
NiceGUI Dashboard
control · experiment · metrics
evaluation · settings tabs"] USR(["User / Browser"]) DB --> BE WS --> BE CFG --> BE CFG --> MOD BE --> SVC MOD --> SVC SVC --> UI UI --> USR

Connects to PostgreSQL and the WebSocket data source. Handles data ingestion, ML feature preparation, model loading/saving, prediction persistence, and application logging. Everything that talks to the outside world lives here.

YAML configuration files for each model type, plus constants.py for shared application-wide values. Loaded once at startup.

Three model implementations — LSTM, XGBoost, Linear Regression. Each follows the same interface so the services layer can use any model interchangeably.

Business logic for each dashboard tab. Each tab has a dedicated *_tab_logic module plus supporting services for loading, filtering, caching, plotting, and evaluating experiment data.

NiceGUI-based dashboard UI. Each tab has a top-level UI module plus reusable components in ui/components/. UI modules delegate all data operations to the services layer.

sequenceDiagram
    participant WS as WebSocket / DB
    participant BE as Backend
    participant SVC as Services
    participant MOD as Models
    participant UI as NiceGUI UI

    UI->>SVC: User selects experiment
    SVC->>BE: Fetch experiment data
    BE->>WS: Paginated query
    WS-->>BE: Rows
    BE-->>SVC: DataFrame
    SVC->>UI: Render plots

    UI->>SVC: Run prediction
    SVC->>MOD: predict (features)
    MOD-->>SVC: Prediction result
    SVC->>UI: Overlay forecast on chart