# heremaps/here-qgis-python architecture

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

- Interactive diagram: https://gitdiagram.com/heremaps/here-qgis-python
- Repository: https://github.com/heremaps/here-qgis-python

## Overview

#### Purpose and Runtime
This repository delivers a Python library plus a QGIS plugin that connects desktop QGIS to HERE platform services, especially Mapmaking and IML/VML datasets. It runs inside QGIS 3.34+ / QGIS 4 across Qt5/Qt6; it is not a standalone server or web application.

Key package boundaries are the reusable library in `src/here_qgis/` and the QGIS-hosted integration in `here_qgis_plugin/`.

#### Plugin Entry and Registration
QGIS loads the plugin package and initializes its UI, providers, and actions through:
- `here_qgis_plugin/__init__.py`
- `here_qgis_plugin/here_qgis_plugin.py`
- `here_qgis_plugin/here_qgis_provider.py`

`plugin_without_dependencies.py` supports bootstrap behavior where dependencies are not yet present. The provider exposes the plugin’s Processing algorithms to QGIS, while the main plugin coordinates menus, toolbars, dialogs, and project/layer interaction.

#### HERE Service Access and Authentication
The shared API layer isolates HERE HTTP/service interactions from QGIS UI and processing code:
- `src/here_qgis/api/api.py`
- `src/here_qgis/api/mapmaking.py`
- `src/here_qgis/platform/platform_auth.py`

Service domains include basemaps, geocoding, routing, map projects, Mapmaking, and VML. Authentication and credentials are managed separately in `src/here_qgis/platform/platform_credentials.py`; interactive QGIS login is implemented in `here_qgis_plugin/ui/here_iml/login/login.py`. API clients are constructed for plugin use through `here_qgis_plugin/api_factory.py`.

#### QGIS UI Workflows
The Qt/QGIS UI layer presents interactive Mapmaking, IML, editing, query, upload, reload, and settings workflows:
- `here_qgis_plugin/ui/here_iml/edit_map/edit_map.py`
- `here_qgis_plugin/ui/here_iml/mapmaking/mapmaking_project.py`
- `here_qgis_plugin/ui/here_iml/upload_map/upload_map.py`

UI controllers operate on QGIS layers and delegate remote/data operations to processing tools or shared APIs. Authentication includes QML/WebEngine assets under `here_qgis_plugin/ui/here_iml/login/`, a material Qt runtime boundary.

#### Processing Toolbox
QGIS Processing algorithms are the primary non-interactive automation boundary, covering service access, layer lifecycle, conversion, and publishing:
- `here_qgis_plugin/processing_toolbox/here_processing_base.py`
- `here_qgis_plugin/processing_toolbox/iml_load_layer.py`
- `here_qgis_plugin/processing_toolbox/iml_upload.py`

Other algorithm families provide basemap, geocoding, routing, Mapmaking upload, VML queries/batches, token refresh, and reload behavior. They can be invoked from QGIS toolbox/UI flows and should keep QGIS parameter/result handling separate from `src/here_qgis` service models.

#### Geospatial Data Transformation and Storage
Nested HERE/map data is made editable in QGIS through flatten/unflatten transformations:
- `src/here_qgis/flatten/flatten.py`
- `src/here_qgis/flatten/unflatten.py`
- `here_qgis_plugin/flatten/qgis_to_geojson.py`

The main data path is remote HERE payload or GeoJSON → flattened QGIS-friendly layers/attributes → user edits/styles → unflattened GeoJSON/map representation → upload to HERE. Local layer-related persistence is abstracted by `src/here_qgis/io/layer_storage.py`.

#### Mapmaking Semantics, Validation, and Styling
Mapmaking-specific formats and presets define domain conversion and editing semantics:
- `here_qgis_plugin/mom/osm_to_mom_10.py`
- `here_qgis_plugin/mapping_preset/Preset_MapMaking.json`
- `here_qgis_plugin/style_set/style_set_24_01_30/loadStyleSets.py`

The plugin ships QGIS QML style assets for standard, comparison, violation, and analysis views. These are presentation/validation resources applied to loaded QGIS layers, rather than a separate rendering service.

#### Telemetry and External Dependencies
The plugin emits product/usage events through an Amplitude integration:
- `src/here_qgis/amplitude_events/amplitude_client.py`
- `src/here_qgis/amplitude_events/api_usage_event.py`

External boundaries are QGIS/Qt, HERE platform APIs, optional Qt WebEngine for login, and Amplitude telemetry. Dependency installation and compatibility handling reside in `here_qgis_plugin/utils/dependencies.py`, supporting the intended one-click QGIS plugin installation path.

Main entry points: [`here_qgis_plugin/ui/here_iml/edit_map/edit_map.py`](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/ui/here_iml/edit_map/edit_map.py) (Mapmaking & IML UI), [`here_qgis_plugin/here_qgis_plugin.py`](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/here_qgis_plugin.py) (Plugin Controller), [`here_qgis_plugin/processing_toolbox/here_processing_base.py`](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/processing_toolbox/here_processing_base.py) (Processing Algorithms), [`src/here_qgis/api/api.py`](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/api/api.py) (HERE Service API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_qgis["QGIS Plugin"]
  node_plugin_entry["Plugin Entry<br/>plugin bootstrap<br/>[__init__.py]"]
  node_plugin_controller["Plugin Controller<br/>QGIS integration"]
  node_processing_provider["Processing Provider<br/>QGIS provider"]
  node_ui_workflows["Mapmaking &amp; IML UI<br/>Qt/QGIS controllers<br/>[edit_map.py]"]
  node_login_ui["Interactive Login<br/>Qt WebEngine UI<br/>[login.py]"]
  node_processing_algorithms["Processing Algorithms<br/>QGIS algorithms"]
  node_api_factory["Plugin API Factory<br/>client composition<br/>[api_factory.py]"]
  node_qgis_geojson["QGIS GeoJSON Adapter<br/>QGIS conversion<br/>[qgis_to_geojson.py]"]
  node_mapmaking_presets["Mapmaking Presets &amp; Styles<br/>domain resources<br/>[osm_to_mom_10.py]"]
end

subgraph group_library["Shared Library"]
  node_service_api["HERE Service API<br/>HTTP service clients<br/>[api.py]"]
  node_mapmaking_api["Mapmaking API<br/>service domain client<br/>[mapmaking.py]"]
  node_auth_credentials["Auth &amp; Credentials<br/>platform identity<br/>[platform_auth.py]"]
  node_flattening["Flatten / Unflatten<br/>geospatial transformation<br/>[flatten.py]"]
  node_layer_storage[("Layer Storage<br/>local persistence<br/>[layer_storage.py]")]
  node_telemetry["Amplitude Events<br/>telemetry client"]
end

subgraph group_external["External Boundaries"]
  node_qgis_runtime{{"QGIS / Qt Runtime<br/>host runtime"}}
  node_here_platform{{"HERE Platform APIs<br/>external services"}}
  node_amplitude{{"Amplitude<br/>telemetry service"}}
end

node_qgis_runtime -->|"loads"| node_plugin_entry
node_plugin_entry -->|"initializes"| node_plugin_controller
node_plugin_controller -->|"registers"| node_processing_provider
node_plugin_controller -->|"opens"| node_ui_workflows
node_ui_workflows -->|"authenticates through"| node_login_ui
node_ui_workflows -->|"invokes"| node_processing_algorithms
node_processing_provider -->|"publishes"| node_processing_algorithms
node_api_factory -->|"constructs"| node_service_api
node_api_factory -->|"configures"| node_auth_credentials
node_ui_workflows -->|"uses"| node_api_factory
node_processing_algorithms -->|"calls"| node_service_api
node_service_api -->|"includes"| node_mapmaking_api
node_service_api -->|"requests"| node_here_platform
node_mapmaking_api -->|"reads and uploads"| node_here_platform
node_login_ui -->|"obtains credentials"| node_auth_credentials
node_auth_credentials -->|"authorizes"| node_here_platform
node_processing_algorithms -->|"transforms payloads"| node_flattening
node_ui_workflows -->|"exports edits"| node_qgis_geojson
node_qgis_geojson -->|"supplies GeoJSON"| node_flattening
node_flattening -->|"persists layer data"| node_layer_storage
node_ui_workflows -->|"applies semantics and styles"| node_mapmaking_presets
node_plugin_controller -.->|"emits events"| node_telemetry
node_telemetry -->|"sends events"| node_amplitude

click node_plugin_entry "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/__init__.py"
click node_plugin_controller "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/here_qgis_plugin.py"
click node_processing_provider "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/here_qgis_provider.py"
click node_ui_workflows "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/ui/here_iml/edit_map/edit_map.py"
click node_login_ui "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/ui/here_iml/login/login.py"
click node_processing_algorithms "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/processing_toolbox/here_processing_base.py"
click node_api_factory "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/api_factory.py"
click node_qgis_geojson "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/flatten/qgis_to_geojson.py"
click node_mapmaking_presets "https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/mom/osm_to_mom_10.py"
click node_service_api "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/api/api.py"
click node_mapmaking_api "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/api/mapmaking.py"
click node_auth_credentials "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/platform/platform_auth.py"
click node_flattening "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/flatten/flatten.py"
click node_layer_storage "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/io/layer_storage.py"
click node_telemetry "https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/amplitude_events/amplitude_client.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_plugin_entry,node_plugin_controller,node_processing_provider,node_ui_workflows,node_login_ui,node_processing_algorithms,node_api_factory,node_qgis_geojson,node_mapmaking_presets toneBlue
class node_service_api,node_mapmaking_api,node_auth_credentials,node_flattening,node_layer_storage,node_telemetry toneAmber
class node_qgis_runtime,node_here_platform,node_amplitude toneMint
```

## Components

### QGIS Plugin

QGIS-hosted UI and Processing integration.

- [Plugin Entry](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/__init__.py): plugin bootstrap · Registers and initializes the QGIS plugin. · `here_qgis_plugin/__init__.py`
- [Plugin Controller](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/here_qgis_plugin.py): QGIS integration · Coordinates actions, menus, dialogs, and project interaction. · `here_qgis_plugin/here_qgis_plugin.py`
- [Processing Provider](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/here_qgis_provider.py): QGIS provider · Exposes HERE algorithms in the QGIS Processing toolbox. · `here_qgis_plugin/here_qgis_provider.py`
- [Mapmaking & IML UI](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/ui/here_iml/edit_map/edit_map.py): Qt/QGIS controllers · Interactive editing, project, upload, query, reload, and settings workflows. · `here_qgis_plugin/ui/here_iml/edit_map/edit_map.py`
- [Interactive Login](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/ui/here_iml/login/login.py): Qt WebEngine UI · Runs QML/WebEngine-backed authentication inside QGIS. · `here_qgis_plugin/ui/here_iml/login/login.py`
- [Processing Algorithms](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/processing_toolbox/here_processing_base.py): QGIS algorithms · Automation for loading, conversion, querying, publishing, and reload. · `here_qgis_plugin/processing_toolbox/here_processing_base.py`
- [Plugin API Factory](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/api_factory.py): client composition · Constructs shared API clients for plugin workflows. · `here_qgis_plugin/api_factory.py`
- [QGIS GeoJSON Adapter](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/flatten/qgis_to_geojson.py): QGIS conversion · Converts QGIS layer data to GeoJSON for publishing. · `here_qgis_plugin/flatten/qgis_to_geojson.py`
- [Mapmaking Presets & Styles](https://github.com/heremaps/here-qgis-python/blob/master/here_qgis_plugin/mom/osm_to_mom_10.py): domain resources · Defines Mapmaking conversion, validation, and layer presentation. · `here_qgis_plugin/mom/osm_to_mom_10.py`

### Shared Library

Reusable HERE access and geospatial data logic.

- [HERE Service API](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/api/api.py): HTTP service clients · Accesses basemap, geocoding, routing, Mapmaking, and VML services. · `src/here_qgis/api/api.py`
- [Mapmaking API](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/api/mapmaking.py): service domain client · Encapsulates Mapmaking-specific remote operations. · `src/here_qgis/api/mapmaking.py`
- [Auth & Credentials](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/platform/platform_auth.py): platform identity · Manages HERE authentication and stored credentials. · `src/here_qgis/platform/platform_auth.py`
- [Flatten / Unflatten](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/flatten/flatten.py): geospatial transformation · Maps nested HERE data to editable QGIS-friendly attributes and back. · `src/here_qgis/flatten/flatten.py`
- [Layer Storage](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/io/layer_storage.py): local persistence · Abstracts persistence for layer-related data. · `src/here_qgis/io/layer_storage.py`
- [Amplitude Events](https://github.com/heremaps/here-qgis-python/blob/master/src/here_qgis/amplitude_events/amplitude_client.py): telemetry client · Emits product and API-usage events. · `src/here_qgis/amplitude_events/amplitude_client.py`

### External Boundaries

- **QGIS / Qt Runtime**: host runtime · Hosts plugin UI, layers, projects, and Processing.
- **HERE Platform APIs**: external services · Remote HERE datasets and service endpoints.
- **Amplitude**: telemetry service

## Connections

- QGIS / Qt Runtime → Plugin Entry: loads
- Plugin Entry → Plugin Controller: initializes
- Plugin Controller → Processing Provider: registers
- Plugin Controller → Mapmaking & IML UI: opens
- Mapmaking & IML UI → Interactive Login: authenticates through
- Mapmaking & IML UI → Processing Algorithms: invokes
- Processing Provider → Processing Algorithms: publishes
- Plugin API Factory → HERE Service API: constructs
- Plugin API Factory → Auth & Credentials: configures
- Mapmaking & IML UI → Plugin API Factory: uses
- Processing Algorithms → HERE Service API: calls
- HERE Service API → Mapmaking API: includes
- HERE Service API → HERE Platform APIs: requests
- Mapmaking API → HERE Platform APIs: reads and uploads
- Interactive Login → Auth & Credentials: obtains credentials
- Auth & Credentials → HERE Platform APIs: authorizes
- Processing Algorithms → Flatten / Unflatten: transforms payloads
- Mapmaking & IML UI → QGIS GeoJSON Adapter: exports edits
- QGIS GeoJSON Adapter → Flatten / Unflatten: supplies GeoJSON
- Flatten / Unflatten → Layer Storage: persists layer data
- Mapmaking & IML UI → Mapmaking Presets & Styles: applies semantics and styles
- Plugin Controller → Amplitude Events: emits events
- Amplitude Events → Amplitude: sends events
