# azista-image-processing/clickhouse_data_downloader architecture

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

- Interactive diagram: https://gitdiagram.com/azista-image-processing/clickhouse_data_downloader
- Repository: https://github.com/azista-image-processing/clickhouse_data_downloader

## Overview

This QGIS plugin lets users connect to ClickHouse, choose a table and spatial columns, build a query, download results as CSV, and add them to the map. The excerpts show connection and schema discovery, filter SQL generation, background export, and layer addition. Some dialog wiring and the handoff from the query editor to the download task occur in unsampled lines, so those links are marked unverified.

Main entry points: [`plugin.py`](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py) (Downloader dialog), [`__init__.py`](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/__init__.py) (Plugin factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin entry"]
  node_factory["Plugin factory<br/>[__init__.py]"]
  node_plugin_ui["Plugin action<br/>[plugin.py]"]
end

subgraph group_query["Query and connection"]
  node_dialog["Downloader dialog<br/>[plugin.py]"]
  node_filters["Filter builder<br/>[plugin.py]"]
  node_schema["Schema discovery<br/>[plugin.py]"]
end

subgraph group_output["Export and mapping"]
  node_export["Background CSV export<br/>[plugin.py]"]
  node_csv["CSV file"]
  node_layer["QGIS map layer<br/>[plugin.py]"]
end

node_user(("QGIS user"))
node_clickhouse[("ClickHouse")]
node_qgis["QGIS application"]

node_user -->|"opens plugin"| node_plugin_ui
node_factory -->|"loads"| node_plugin_ui
node_plugin_ui -.->|"opens dialog"| node_dialog
node_dialog -->|"connects to"| node_clickhouse
node_dialog -->|"requests schema"| node_schema
node_schema -->|"queries metadata"| node_clickhouse
node_dialog -.->|"uses filters"| node_filters
node_filters -.->|"provides SQL"| node_dialog
node_dialog -->|"starts download"| node_export
node_export -->|"streams query results"| node_clickhouse
node_export -->|"writes rows"| node_csv
node_dialog -->|"adds result"| node_layer
node_layer -->|"creates map layer"| node_qgis

click node_factory "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/__init__.py"
click node_plugin_ui "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py"
click node_dialog "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py"
click node_filters "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py"
click node_schema "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py"
click node_export "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py"
click node_layer "https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.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_factory,node_plugin_ui,node_user toneBlue
class node_dialog,node_filters,node_schema,node_clickhouse toneAmber
class node_export,node_csv,node_layer toneMint
class node_qgis toneIndigo
```

## Components

### Plugin entry

- [Plugin factory](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/__init__.py): `__init__.py`
- [Plugin action](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`

### Query and connection

- [Downloader dialog](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`
- [Filter builder](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`
- [Schema discovery](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`

### Export and mapping

- [Background CSV export](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`
- **CSV file**
- [QGIS map layer](https://github.com/azista-image-processing/clickhouse_data_downloader/blob/master/plugin.py): `plugin.py`

### Other components

- **QGIS user**
- **ClickHouse**
- **QGIS application**

## Connections

- QGIS user → Plugin action: opens plugin (evidence: `plugin.py`)
- Plugin factory → Plugin action: loads (evidence: `__init__.py`)
- Plugin action → Downloader dialog: opens dialog (evidence: `plugin.py`)
- Downloader dialog → ClickHouse: connects to (evidence: `plugin.py`)
- Downloader dialog → Schema discovery: requests schema (evidence: `plugin.py`)
- Schema discovery → ClickHouse: queries metadata (evidence: `plugin.py`)
- Downloader dialog → Filter builder: uses filters (evidence: `plugin.py`)
- Filter builder → Downloader dialog: provides SQL (evidence: `plugin.py`)
- Downloader dialog → Background CSV export: starts download (evidence: `plugin.py`)
- Background CSV export → ClickHouse: streams query results (evidence: `plugin.py`)
- Background CSV export → CSV file: writes rows (evidence: `plugin.py`)
- Downloader dialog → QGIS map layer: adds result (evidence: `plugin.py`)
- QGIS map layer → QGIS application: creates map layer (evidence: `plugin.py`)
