# jbp35/layer-atlas-plugin architecture

> Architecture diagram of the GitHub repository jbp35/layer-atlas-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jbp35/layer-atlas-plugin
- Repository: https://github.com/jbp35/layer-atlas-plugin

## Overview

##### Project type and purpose
- From the file tree and README, this is a QGIS plugin (“Layer Atlas”) written in Python.
- Purpose: allow QGIS users to discover, preview, and drag-and-drop geospatial layers from remote sources, manage favorites, and handle file downloads—all within QGIS.

##### File structure
- Top-level:
- layeratlas/                ← plugin package
- README.md, CHANGELOG.md, .gitignore, etc.
- Inside layeratlas/:
- core/                      ← business-logic and services
– communication_bus.py
– download_file_task.py
– load_file.py
– manage_dependencies.py
– custom_web_engine_view.py
- gui/                       ← Qt GUI code
– layer_atlas_dockwidget.py (main UI dock)
– select_dataset_layers.py
- helper/                    ← shared utilities
– logging_helper.py
- resources/                 ← static assets & templates
- layer_atlas.py             ← plugin entrypoint (registers with QGIS)
- metadata.txt               ← QGIS plugin metadata

##### README for additional insights
- Plugin depends on QGIS ≥3.38 and PyQtWebEngine.
- Workflow:
1) QGIS loads plugin
2) GUI dock widget appears
3) User searches layers → plugin queries remote service
4) Preview via embedded web engine view
5) Download & add layer to map

- Break the system into the components listed above
- Major interactions, including dependency checks, web API calls, preview rendering, and download flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Components
    QGIS["QGIS Host Application"]:::external
    RemoteAPI("Remote Geospatial Data API"):::external
    PyPI("PyPI Repository"):::external
    FileSystem[(Local Cache / Downloaded Layers)]:::storage

    %% Plugin Boundary
    subgraph "Layer Atlas Plugin"
        direction TB

        %% Entrypoint
        Entrypoint["layer_atlas.py"]:::entrypoint
        Metadata["metadata.txt"]:::entrypoint

        %% Core Layer
        subgraph "Core Services"
            direction TB
            CommunicationBus["communication_bus.py"]:::core
            DependencyManager["manage_dependencies.py"]:::core
            DownloadTask["download_file_task.py"]:::core
            FileLoader["load_file.py"]:::core
            WebEngineView["custom_web_engine_view.py"]:::core
        end

        %% GUI Layer
        subgraph "GUI Components"
            direction TB
            DockWidget["layer_atlas_dockwidget.py"]:::gui
            LayerSelector["select_dataset_layers.py"]:::gui
        end

        %% Helper
        subgraph "Helper Utilities"
            direction TB
            LoggingHelper["logging_helper.py"]:::helper
        end

        %% Resources
        subgraph "Resources"
            direction TB
            Icons["icons/"]:::resources
            QRCDef["resources.qrc"]:::resources
            QRCModule["resources.py"]:::resources
            HTMLTemplate["templates/missing_pyqtwebengine.html"]:::resources
        end
    end

    %% Initialization Flows
    QGIS -->|"loads"| Entrypoint
    Entrypoint -->|"reads"| Metadata
    Entrypoint -->|"initializes"| DependencyManager
    Entrypoint -->|"initializes"| CommunicationBus
    Entrypoint -->|"initializes"| DockWidget
    DependencyManager -->|"install PyQtWebEngine"| PyPI

    %% Event & Data Flows
    DockWidget -->|"user search"| CommunicationBus
    CommunicationBus -->|"query metadata"| RemoteAPI
    RemoteAPI -->|"metadata response"| CommunicationBus
    CommunicationBus -->|"send metadata"| LayerSelector
    LayerSelector -->|"select layer"| DockWidget
    DockWidget -->|"render preview"| WebEngineView
    DockWidget -->|"download request"| DownloadTask
    DownloadTask -->|"save file"| FileSystem
    FileSystem -->|"add layer"| QGIS

    %% Logging
    CommunicationBus -.->|"log"| LoggingHelper
    DockWidget -.->|"log"| LoggingHelper
    DependencyManager -.->|"log"| LoggingHelper
    DownloadTask -.->|"log"| LoggingHelper

    %% Resource Usage
    DockWidget -->|"use icons"| Icons
    WebEngineView -->|"load HTML template"| HTMLTemplate
    Entrypoint -->|"load QRC"| QRCModule
    Entrypoint -->|"reference QRC"| QRCDef

    %% Click Events
    click Entrypoint "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/layer_atlas.py"
    click Metadata "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/metadata.txt"
    click CommunicationBus "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/core/communication_bus.py"
    click DependencyManager "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/core/manage_dependencies.py"
    click DownloadTask "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/core/download_file_task.py"
    click FileLoader "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/core/load_file.py"
    click WebEngineView "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/core/custom_web_engine_view.py"
    click DockWidget "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/gui/layer_atlas_dockwidget.py"
    click LayerSelector "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/gui/select_dataset_layers.py"
    click LoggingHelper "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/helper/logging_helper.py"
    click Icons "https://github.com/jbp35/layer-atlas-plugin/tree/main/layeratlas/resources/icons/"
    click QRCDef "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/resources/resources.qrc"
    click QRCModule "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/resources/resources.py"
    click HTMLTemplate "https://github.com/jbp35/layer-atlas-plugin/blob/main/layeratlas/resources/templates/missing_pyqtwebengine.html"

    %% Styles
    classDef core fill:#cce5ff,stroke:#4a90e2,color:#0b3d91;
    classDef gui fill:#d4edda,stroke:#28a745,color:#155724;
    classDef helper fill:#fff3cd,stroke:#ffc107,color:#856404;
    classDef resources fill:#ffe5b4,stroke:#ff8c00,color:#8b4513;
    classDef entrypoint fill:#b8daff,stroke:#1f618d,color:#1b4f72;
    classDef external fill:#f0f0f0,stroke:#999999,color:#333333;
    classDef storage fill:#e2e3e5,stroke:#6c757d,color:#495057;
    class Entrypoint,Metadata entrypoint;
    class CommunicationBus,DependencyManager,DownloadTask,FileLoader,WebEngineView core;
    class DockWidget,LayerSelector gui;
    class LoggingHelper helper;
    class Icons,QRCDef,QRCModule,HTMLTemplate resources;
    class QGIS,RemoteAPI,PyPI external;
    class FileSystem storage;
```
