# pyscada/pyscada architecture

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

- Interactive diagram: https://gitdiagram.com/pyscada/pyscada
- Repository: https://github.com/pyscada/pyscada

## Overview

PyScada is a Django-based SCADA system. Operators configure devices and variables, collect measurements through protocol/device workers, retain them in datasource-backed storage, and inspect them through the HTML5 HMI. Separate workers evaluate events, create mail notifications, and run scheduled data exports. The graph reflects the documented capabilities and sampled worker/model relationships; protocol integrations are optional external extensions, and unsampled implementation details are not inferred.

Main entry points: [`pyscada/models.py`](https://github.com/pyscada/pyscada/blob/main/pyscada/models.py) (Devices and variables), [`pyscada/utils/scheduler.py`](https://github.com/pyscada/pyscada/blob/main/pyscada/utils/scheduler.py) (Process scheduler), [`pyscada/hmi/views.py`](https://github.com/pyscada/pyscada/blob/main/pyscada/hmi/views.py) (HTML5 HMI), [`pyscada/export/worker.py`](https://github.com/pyscada/pyscada/blob/main/pyscada/export/worker.py) (Export worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Configuration and domain"]
  node_admin["Admin configuration<br/>[admin.py]"]
  node_domain["Devices and variables<br/>[models.py]"]
end

subgraph group_acquisition["Acquisition and storage"]
  node_device_workers["Device workers<br/>[worker.py]"]
  node_protocols{{"Protocol extensions"}}
  node_waveform["Generic waveform device<br/>[waveform.py]"]
  node_recorded_data[("Recorded data datasource<br/>[models.py]")]
  node_cache_data[("Cache datasource<br/>[models.py]")]
  node_single_value[("Single-value datasource<br/>[models.py]")]
end

subgraph group_operator["Operator HMI"]
  node_hmi_models["HMI configuration<br/>[models.py]"]
  node_hmi["HTML5 HMI<br/>[views.py]"]
end

subgraph group_services["Background services"]
  node_scheduler["Process scheduler<br/>[scheduler.py]"]
  node_events["Event evaluation<br/>[worker.py]"]
  node_export_tasks["Export tasks<br/>[models.py]"]
  node_export_worker["Export worker<br/>[worker.py]"]
  node_export_formats["Export formats<br/>[export.py]"]
  node_mail["Mail notifications<br/>[worker.py]"]
end

node_operator(("SCADA operator"))

node_operator -->|"configures"| node_admin
node_operator -->|"views status"| node_hmi
node_admin -->|"edits"| node_domain
node_domain -->|"selects datasource"| node_recorded_data
node_scheduler -->|"dispatches"| node_device_workers
node_device_workers -.->|"acquires through"| node_protocols
node_waveform -->|"uses device model"| node_domain
node_hmi -.->|"renders"| node_hmi_models
node_hmi_models -->|"references"| node_domain
node_scheduler -.->|"runs worker"| node_events
node_events -->|"checks events"| node_domain
node_scheduler -.->|"runs worker"| node_export_worker
node_export_worker -->|"reads tasks"| node_export_tasks
node_export_worker -->|"requests export"| node_export_formats
node_export_formats -->|"reads measurements"| node_recorded_data
node_scheduler -.->|"runs worker"| node_mail
node_mail -->|"sends queued mail"| node_domain
node_hmi -.->|"reads live values"| node_cache_data
node_hmi -.->|"reads current values"| node_single_value

click node_admin "https://github.com/pyscada/pyscada/blob/main/pyscada/admin.py"
click node_domain "https://github.com/pyscada/pyscada/blob/main/pyscada/models.py"
click node_scheduler "https://github.com/pyscada/pyscada/blob/main/pyscada/utils/scheduler.py"
click node_device_workers "https://github.com/pyscada/pyscada/blob/main/pyscada/generic/worker.py"
click node_waveform "https://github.com/pyscada/pyscada/blob/main/pyscada/generic/devices/waveform.py"
click node_recorded_data "https://github.com/pyscada/pyscada/blob/main/pyscada/django_datasource/models.py"
click node_cache_data "https://github.com/pyscada/pyscada/blob/main/pyscada/cache_datasource/models.py"
click node_single_value "https://github.com/pyscada/pyscada/blob/main/pyscada/single_value_datasource/models.py"
click node_hmi_models "https://github.com/pyscada/pyscada/blob/main/pyscada/hmi/models.py"
click node_hmi "https://github.com/pyscada/pyscada/blob/main/pyscada/hmi/views.py"
click node_events "https://github.com/pyscada/pyscada/blob/main/pyscada/event/worker.py"
click node_export_tasks "https://github.com/pyscada/pyscada/blob/main/pyscada/export/models.py"
click node_export_worker "https://github.com/pyscada/pyscada/blob/main/pyscada/export/worker.py"
click node_export_formats "https://github.com/pyscada/pyscada/blob/main/pyscada/export/export.py"
click node_mail "https://github.com/pyscada/pyscada/blob/main/pyscada/mail/worker.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_admin,node_domain toneBlue
class node_device_workers,node_protocols,node_waveform,node_recorded_data,node_cache_data,node_single_value toneAmber
class node_hmi_models,node_hmi toneMint
class node_scheduler,node_events,node_export_tasks,node_export_worker,node_export_formats,node_mail toneRose
class node_operator toneIndigo
```

## Components

### Configuration and domain

- [Admin configuration](https://github.com/pyscada/pyscada/blob/main/pyscada/admin.py): `pyscada/admin.py`
- [Devices and variables](https://github.com/pyscada/pyscada/blob/main/pyscada/models.py): `pyscada/models.py`

### Acquisition and storage

- [Device workers](https://github.com/pyscada/pyscada/blob/main/pyscada/generic/worker.py): `pyscada/generic/worker.py`
- **Protocol extensions**
- [Generic waveform device](https://github.com/pyscada/pyscada/blob/main/pyscada/generic/devices/waveform.py): `pyscada/generic/devices/waveform.py`
- [Recorded data datasource](https://github.com/pyscada/pyscada/blob/main/pyscada/django_datasource/models.py): `pyscada/django_datasource/models.py`
- [Cache datasource](https://github.com/pyscada/pyscada/blob/main/pyscada/cache_datasource/models.py): `pyscada/cache_datasource/models.py`
- [Single-value datasource](https://github.com/pyscada/pyscada/blob/main/pyscada/single_value_datasource/models.py): `pyscada/single_value_datasource/models.py`

### Operator HMI

- [HMI configuration](https://github.com/pyscada/pyscada/blob/main/pyscada/hmi/models.py): `pyscada/hmi/models.py`
- [HTML5 HMI](https://github.com/pyscada/pyscada/blob/main/pyscada/hmi/views.py): `pyscada/hmi/views.py`

### Background services

- [Process scheduler](https://github.com/pyscada/pyscada/blob/main/pyscada/utils/scheduler.py): `pyscada/utils/scheduler.py`
- [Event evaluation](https://github.com/pyscada/pyscada/blob/main/pyscada/event/worker.py): `pyscada/event/worker.py`
- [Export tasks](https://github.com/pyscada/pyscada/blob/main/pyscada/export/models.py): `pyscada/export/models.py`
- [Export worker](https://github.com/pyscada/pyscada/blob/main/pyscada/export/worker.py): `pyscada/export/worker.py`
- [Export formats](https://github.com/pyscada/pyscada/blob/main/pyscada/export/export.py): `pyscada/export/export.py`
- [Mail notifications](https://github.com/pyscada/pyscada/blob/main/pyscada/mail/worker.py): `pyscada/mail/worker.py`

### Other components

- **SCADA operator**

## Connections

- SCADA operator → Admin configuration: configures (evidence: `README.rst`)
- SCADA operator → HTML5 HMI: views status (evidence: `README.rst`)
- Admin configuration → Devices and variables: edits (evidence: `pyscada/admin.py`)
- Devices and variables → Recorded data datasource: selects datasource (evidence: `pyscada/models.py`)
- Process scheduler → Device workers: dispatches (evidence: `pyscada/utils/scheduler.py`)
- Device workers → Protocol extensions: acquires through (evidence: `README.rst`)
- Generic waveform device → Devices and variables: uses device model (evidence: `pyscada/generic/devices/waveform.py`)
- HTML5 HMI → HMI configuration: renders
- HMI configuration → Devices and variables: references (evidence: `pyscada/hmi/models.py`)
- Process scheduler → Event evaluation: runs worker (evidence: `pyscada/event/worker.py`)
- Event evaluation → Devices and variables: checks events (evidence: `pyscada/event/worker.py`)
- Process scheduler → Export worker: runs worker (evidence: `pyscada/export/worker.py`)
- Export worker → Export tasks: reads tasks (evidence: `pyscada/export/worker.py`)
- Export worker → Export formats: requests export (evidence: `pyscada/export/worker.py`)
- Export formats → Recorded data datasource: reads measurements (evidence: `pyscada/export/export.py`)
- Process scheduler → Mail notifications: runs worker (evidence: `pyscada/mail/worker.py`)
- Mail notifications → Devices and variables: sends queued mail (evidence: `pyscada/mail/worker.py`)
- HTML5 HMI → Cache datasource: reads live values
- HTML5 HMI → Single-value datasource: reads current values
