# g3w-suite/g3w-client architecture

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

- Interactive diagram: https://gitdiagram.com/g3w-suite/g3w-client
- Repository: https://github.com/g3w-suite/g3w-client

## Overview

1. **What this repo is**
   - `g3w-client` is the browser-side cartographic viewer for the G3W suite.
   - It is not standalone: it expects a separate **g3w-admin** backend and is typically run in a **Docker Compose** dev stack with that backend plus shared config.

2. **Runtime and build boundary**
   - The codebase is a **Vue-based JavaScript application/library** with separate dev and prod entrypoints (`src/index.dev.js`, `src/index.prod.js`) and a custom build script (`build.js`).
   - `config.template.js` indicates runtime configuration is injected externally, not hardcoded into the app.

3. **Top-level application shell**
   - Core UI composition lives in `src/components/App.vue` and the form/panel/header/footer components.
   - This shell hosts the viewer chrome: catalog/tree navigation, modal dialogs, tabs, search, tables, messages, and tool panels.

4. **Application infrastructure**
   - The `src/g3w-*.js` files form the shared platform layer: app bootstrap, component/control/panel/layer abstractions, plugin registration, global state, event emission, iframe integration, and i18n.
   - This is the main internal boundary that all features plug into.

5. **Map and interaction subsystem**
   - `src/static/map-controls` contains the viewer’s built-in map controls: zoom, zoom history, overview, scale, mouse position, geolocation, geocoding, measurement, screenshot, query/query-by, add-layer, basemap switching, street view, and toggles.
   - `src/interactions` provides user interactions such as picking coordinates and features.
   - These modules are the map-facing surface of the app and typically mediate between user actions and layer/query state.

6. **Catalog, layer, and query workflows**
   - Components like `CatalogTree`, `QueryBuilder`, `QueryResults`, `Relations`, `Table`, `SearchPanel`, `Search`, and the layer modals manage project contents and data inspection.
   - The data flow here is: backend/project metadata → catalog/layer tree → user selection/query/search → results/table/relations UI.

7. **Form and field system**
   - The many `Field*` and `Input*` components implement a reusable form engine for layer attributes, editing, metadata, and specialized value types.
   - Mixins in `src/mixins` normalize behavior across field types, media inputs, geospatial inputs, selection widgets, resizing, and form input handling.
   - This is a distinct subsystem from the map shell: it focuses on structured data entry rather than viewer chrome.

8. **Plugin architecture**
   - `src/plugins` is an explicit extension boundary; plugins can be independently developed and mounted into the client.
   - The README shows plugins are selected via runtime config (`window.initConfig.group.plugins`) and can add custom UI, behavior, and hooks without changing the core app.
   - This is the main customization mechanism for deployments.

9. **Customization hooks and user extension points**
   - The app exposes event-driven hooks for things like header links and context menu entries.
   - README examples show `g3w.app` events are used to inject custom menu items, modal triggers, and UI links.
   - This means the app is designed as an extensible shell with late-bound features.

10. **Shared utilities and browser services**
   - `src/utils` contains the non-UI domain helpers: XHR, geometry conversions, scale/resolution math, feature splitting/dissolving, downloads, URL builders, deep cloning, debouncing/throttling, DOM ID generation, and browser storage via `idb`.
   - These utilities support the rest of the app but are not a subsystem on their own.

11. **Static assets and locale layer**
   - `src/static` bundles CSS, icons/cursors/fonts, translation files, and geocoding provider definitions.
   - Geocoding integrations are abstracted as provider modules, so the viewer can switch or extend search providers without changing the UI layer.
   - Internationalization is file-based and loaded from `src/static/locales`.

12. **Dev/test/release environment**
   - The repository is set up for local development alongside `g3w-suite-docker` and `g3w-admin`, with GitHub Actions for testing/backporting/release automation.
   - `test/map/*` contains map-centric test/demo scenarios, indicating the app is validated through viewer behavior rather than isolated unit logic alone.

13. **Diagram takeaway**
   - A good architecture diagram should show:
     - **Backend/config input** from `g3w-admin` and Docker-managed runtime config
     - **Core Vue shell + g3w platform layer**
     - **Map controls/interactions** as a feature subsystem
     - **Catalog/query/forms/search** as major functional slices
     - **Plugin/extensions** as a separate injected boundary
     - **Shared utilities/static assets/locales** as supporting layers

Main entry points: [`src/components/App.vue`](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/App.vue) (App shell), [`src/g3w-app.js`](https://github.com/g3w-suite/g3w-client/blob/dev/src/g3w-app.js) (G3W platform), [`src/components/QueryBuilder.vue`](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/QueryBuilder.vue) (Query flow), [`src/static/map-controls/zoom.js`](https://github.com/g3w-suite/g3w-client/blob/dev/src/static/map-controls/zoom.js) (Map controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_config["Runtime config<br/>external config<br/>[config.template.js]"]
  node_entrydev["Dev entry<br/>bootstrap entry<br/>[index.dev.js]"]
  node_entryprod["Prod entry<br/>bootstrap entry<br/>[index.prod.js]"]
  node_build["Build script<br/>build tooling<br/>[build.js]"]
end

subgraph group_shell["Shell UI"]
  node_app["App shell<br/>Vue root<br/>[App.vue]"]
  node_panels["Panels<br/>ui chrome<br/>[FormHeader.vue]"]
  node_modals["Dialogs<br/>[ModalLogin.vue]"]
end

subgraph group_map["Map Layer"]
  node_mapctrl["Map controls<br/>map control layer<br/>[zoom.js]"]
  node_interact["Interactions<br/>map interaction<br/>[pick-feature.js]"]
end

subgraph group_data["Data Workflows"]
  node_catalog["Catalog tree<br/>project navigation<br/>[CatalogTree.vue]"]
  node_query["Query flow<br/>inspection workflow<br/>[QueryBuilder.vue]"]
  node_search["Search<br/>lookup workflow<br/>[SearchPanel.vue]"]
  node_forms["Form engine<br/>editing/forms<br/>[Form.vue]"]
end

subgraph group_ext["Extensions"]
  node_platform["G3W platform<br/>core runtime<br/>[g3w-app.js]"]
  node_plugins["Plugins<br/>extension boundary<br/>[README.md]"]
  node_hooks(("App hooks<br/>events<br/>[g3w-emitter.js]"))
  node_utils["Utilities<br/>shared helpers<br/>[base.js]"]
  node_i18n["Locales<br/>localization<br/>[index.js]"]
  node_static["Static assets<br/>[app.css]"]
end

node_build -->|"builds"| node_entrydev
node_build -->|"builds"| node_entryprod
node_config -->|"configures"| node_entrydev
node_config -->|"configures"| node_entryprod
node_entrydev -->|"boots"| node_app
node_entryprod -->|"boots"| node_app
node_app -->|"uses"| node_platform
node_platform -->|"exposes"| node_hooks
node_platform -->|"mounts"| node_plugins
node_platform -->|"loads"| node_i18n
node_platform -->|"depends on"| node_utils
node_platform -->|"serves"| node_static
node_app -->|"composes"| node_panels
node_app -->|"hosts"| node_catalog
node_app -->|"hosts"| node_query
node_app -->|"hosts"| node_search
node_app -->|"hosts"| node_forms
node_app -->|"opens"| node_modals
node_app -->|"surfaces"| node_mapctrl
node_mapctrl -->|"drives"| node_interact
node_mapctrl -->|"feeds"| node_query
node_catalog -->|"selects"| node_query
node_catalog -->|"navigates"| node_search
node_query -->|"uses"| node_forms
node_search -->|"uses"| node_utils
node_forms -->|"uses"| node_utils
node_plugins -->|"extends"| node_hooks
node_static -->|"contains"| node_i18n

click node_config "https://github.com/g3w-suite/g3w-client/blob/dev/config.template.js"
click node_entrydev "https://github.com/g3w-suite/g3w-client/blob/dev/src/index.dev.js"
click node_entryprod "https://github.com/g3w-suite/g3w-client/blob/dev/src/index.prod.js"
click node_build "https://github.com/g3w-suite/g3w-client/blob/dev/build.js"
click node_app "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/App.vue"
click node_panels "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/FormHeader.vue"
click node_catalog "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/CatalogTree.vue"
click node_query "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/QueryBuilder.vue"
click node_search "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/SearchPanel.vue"
click node_forms "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/Form.vue"
click node_modals "https://github.com/g3w-suite/g3w-client/blob/dev/src/components/ModalLogin.vue"
click node_mapctrl "https://github.com/g3w-suite/g3w-client/blob/dev/src/static/map-controls/zoom.js"
click node_interact "https://github.com/g3w-suite/g3w-client/blob/dev/src/interactions/pick-feature.js"
click node_platform "https://github.com/g3w-suite/g3w-client/blob/dev/src/g3w-app.js"
click node_plugins "https://github.com/g3w-suite/g3w-client/blob/dev/src/plugins/README.md"
click node_hooks "https://github.com/g3w-suite/g3w-client/blob/dev/src/g3w-emitter.js"
click node_utils "https://github.com/g3w-suite/g3w-client/blob/dev/src/utils/base.js"
click node_i18n "https://github.com/g3w-suite/g3w-client/blob/dev/src/static/locales/index.js"
click node_static "https://github.com/g3w-suite/g3w-client/blob/dev/src/static/app.css"

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_config,node_entrydev,node_entryprod,node_build toneBlue
class node_app,node_panels,node_modals toneAmber
class node_mapctrl,node_interact toneMint
class node_catalog,node_query,node_search,node_forms toneRose
class node_platform,node_plugins,node_hooks,node_utils,node_i18n,node_static toneIndigo
```

## Components

### Runtime

Build, bootstrap, and external runtime configuration.

- [Runtime config](https://github.com/g3w-suite/g3w-client/blob/dev/config.template.js): external config · Injected viewer settings and deployment-specific options, including plugin selection. · `config.template.js`
- [Dev entry](https://github.com/g3w-suite/g3w-client/blob/dev/src/index.dev.js): bootstrap entry · Development startup entrypoint. · `src/index.dev.js`
- [Prod entry](https://github.com/g3w-suite/g3w-client/blob/dev/src/index.prod.js): bootstrap entry · Production startup entrypoint. · `src/index.prod.js`
- [Build script](https://github.com/g3w-suite/g3w-client/blob/dev/build.js): build tooling · Custom build orchestration for the client. · `build.js`

### Shell UI

Top-level viewer chrome and application composition.

- [App shell](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/App.vue): Vue root · Top-level application composition and viewer chrome. · `src/components/App.vue`
- [Panels](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/FormHeader.vue): ui chrome · Header, footer, form body, global tabs, tool and message surfaces. · `src/components/FormHeader.vue`
- [Dialogs](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/ModalLogin.vue): ui dialogs · Modal surfaces for login, metadata, layer changes, and add-layer actions. · `src/components/ModalLogin.vue`

### Map Layer

Map controls and direct user interactions with the viewer.

- [Map controls](https://github.com/g3w-suite/g3w-client/blob/dev/src/static/map-controls/zoom.js): map control layer · Built-in viewer controls such as zoom, overview, geocoding, measure, query, baselayer, and screenshot. · `src/static/map-controls/zoom.js`
- [Interactions](https://github.com/g3w-suite/g3w-client/blob/dev/src/interactions/pick-feature.js): map interaction · Feature and coordinate picking interactions that feed map workflows. · `src/interactions/pick-feature.js`

### Data Workflows

Catalog, query, search, relations, and form entry flows.

- [Catalog tree](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/CatalogTree.vue): project navigation · Project and layer tree navigation for browsing content. · `src/components/CatalogTree.vue`
- [Query flow](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/QueryBuilder.vue): inspection workflow · Query builder, results, relations, and table-oriented inspection. · `src/components/QueryBuilder.vue`
- [Search](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/SearchPanel.vue): lookup workflow · Search panel and search widgets for finding projects, layers, and features. · `src/components/SearchPanel.vue`
- [Form engine](https://github.com/g3w-suite/g3w-client/blob/dev/src/components/Form.vue): editing/forms · Reusable field, input, and form components for structured data entry. · `src/components/Form.vue`

### Extensions

Plugin boundary, shared utilities, locales, and static assets.

- [G3W platform](https://github.com/g3w-suite/g3w-client/blob/dev/src/g3w-app.js): core runtime · Shared app, component, control, panel, layer, state, emitter, iframe, and plugin abstractions. · `src/g3w-app.js`
- [Plugins](https://github.com/g3w-suite/g3w-client/blob/dev/src/plugins/README.md): extension boundary · Mountable extension area for deployment-specific custom behavior and UI. · `src/plugins/README.md`
- [App hooks](https://github.com/g3w-suite/g3w-client/blob/dev/src/g3w-emitter.js): events · Event-driven extension points for header links, context menus, and modal triggers. · `src/g3w-emitter.js`
- [Utilities](https://github.com/g3w-suite/g3w-client/blob/dev/src/utils/base.js): shared helpers · XHR, geometry, search, filtering, download, storage, and other non-UI helpers. · `src/utils/base.js`
- [Locales](https://github.com/g3w-suite/g3w-client/blob/dev/src/static/locales/index.js): localization · Translation bundle loading and language resources. · `src/static/locales/index.js`
- [Static assets](https://github.com/g3w-suite/g3w-client/blob/dev/src/static/app.css): assets · Styles, icons, cursors, fonts, and geocoding providers. · `src/static/app.css`

## Connections

- Build script → Dev entry: builds · The build tooling packages the development entry.
- Build script → Prod entry: builds · The build tooling packages the production entry.
- Runtime config → Dev entry: configures · Runtime config is injected when the app starts in development.
- Runtime config → Prod entry: configures · Runtime config is injected when the app starts in production.
- Dev entry → App shell: boots · The dev entry initializes the Vue application shell.
- Prod entry → App shell: boots · The prod entry initializes the Vue application shell.
- App shell → G3W platform: uses · The shell is assembled on top of the shared G3W runtime abstractions.
- G3W platform → App hooks: exposes · The runtime layer exposes event and extension hooks.
- G3W platform → Plugins: mounts · Plugins register through the core platform boundary.
- G3W platform → Locales: loads · Localization is provided through the shared runtime layer.
- G3W platform → Utilities: depends on · Core runtime behavior relies on common helpers.
- G3W platform → Static assets: serves · Shared runtime assets are consumed across the app.
- App shell → Panels: composes · The root shell organizes the viewer chrome and panel surfaces.
- App shell → Catalog tree: hosts · The shell hosts catalog and layer navigation.
- App shell → Query flow: hosts · The shell hosts query and results workflows.
- App shell → Search: hosts · The shell hosts search surfaces.
- App shell → Form engine: hosts · The shell embeds the form and field engine.
- App shell → Dialogs: opens · The shell coordinates modal dialogs.
- App shell → Map controls: surfaces · Viewer chrome exposes map controls to the user.
- Map controls → Interactions: drives · Controls trigger direct map interactions.
- Map controls → Query flow: feeds · Map query controls connect to inspection workflows.
- Catalog tree → Query flow: selects · Catalog selection flows into query and results inspection.
- Catalog tree → Search: navigates · Catalog content is discoverable through search.
- Query flow → Form engine: uses · Query and editing workflows depend on reusable fields and inputs.
- Search → Utilities: uses · Search workflows rely on shared data-shaping helpers.
- Form engine → Utilities: uses · Field and input components use shared normalization and geometry helpers.
- Plugins → App hooks: extends · Plugins attach via the app event system and extension hooks.
- Static assets → Locales: contains · Language resources live alongside other static assets.
