# finnishtransportagency/liikennemerkit architecture

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

- Interactive diagram: https://gitdiagram.com/finnishtransportagency/liikennemerkit
- Repository: https://github.com/finnishtransportagency/liikennemerkit

## Overview

##### Project type and purpose
- This is an open-source QGIS resource library, not a full web app or microservice.
- It provides three SVG image collections (old signs, new signs, style scripts) plus a Python “sign stylizer” script to automate symbolization in QGIS.

##### File structure
- Top-level files and folders:
- README.md – explains usage
- metadata.ini – QGIS Resource Sharing metadata
- collections/
– new_signs/ (SVG assets, license, previews)
– old_signs/ (SVG assets, license, previews)
– style_script/ (sign_stylizer.py under processing/)
- No backend or database. The processing script runs inside QGIS’s Processing Toolbox.

##### README for additional insights
- The library is installed via QGIS’s Resource Sharing plugin.
- Users load point-layer data (e.g. Digiroad or Tierekisteri) and run the Python script to map feature codes to the correct SVG.

##### Main components
a. QGIS Application
b. Resource Sharing Plugin (inside QGIS)
c. Collections Repository
- new_signs SVG folder
- old_signs SVG folder
- style_script/processing/sign_stylizer.py
- metadata.ini
d. External point-layer data sources
- Digiroad / Tierekisteri CSV or PostGIS layer
e. User interaction (GIS analyst running the tool)

##### Relationships and interactions
- User → QGIS Application: invokes Resource Sharing plugin
- Resource Sharing plugin → Collections Repository: installs or updates collections
- User loads point-layer data into QGIS
- User runs “Finnish traffic sign stylizer” script
- sign_stylizer.py reads feature attribute codes and metadata.ini
- sign_stylizer.py selects appropriate SVG from new_signs or old_signs
- Script applies SVG symbols to the point layer symbology

##### Architectural patterns and design principles
- Plug-in/extension architecture: QGIS core + Resource Sharing plugin + processing script
- Separation of concerns:
- Static asset storage (SVG files)
- Metadata and installation info (metadata.ini)
- Processing logic (Python script)
- Extensibility: new collections can be added by following same folder structure and updating metadata.ini

##### Relevant technologies
- QGIS 3.x
- QGIS Resource Sharing plugin
- Python (sign_stylizer.py, QGIS Processing framework)

##### Diagramming recommendations
- QGIS Application
- Resource Sharing Plugin
- Collections Repository
- Processing Script
- External Data Sources
- User
- Installation flow (plugin → repository)
- Data flow (external sources → QGIS → script → map canvas)
- Annotations for key files (metadata.ini, sign_stylizer.py) next to their components

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["GIS Analyst\n(User)"]:::user
    QGIS["QGIS Application"]:::core
    Plugin["Resource Sharing Plugin"]:::plugin
    ExtData["External Data Sources\n(Digiroad/Tierekisteri)"]:::external
    Doc["Usage Documentation\n(README.md)"]:::doc
    Map["Styled Map Output\n(Map Canvas)"]:::output

    subgraph "Collections Repository"
        CR["collections/"]:::folder
        NS["new_signs\n(SVG Assets)"]:::asset
        OS["old_signs\n(SVG Assets)"]:::asset
        SSfolder["style_script/"]:::folder
        SS["sign_stylizer.py"]:::script
        MI["metadata.ini"]:::config
    end

    User -->|installs plugin| QGIS
    QGIS -->|loads plugin| Plugin
    Plugin -->|installs/updates| CR
    CR --> NS
    CR --> OS
    CR --> SSfolder
    CR --> MI
    SSfolder --> SS
    User -->|loads data| QGIS
    ExtData -->|point-layer data| QGIS
    User -->|runs script| Plugin
    Plugin -->|executes| SS
    SS -->|reads| MI
    SS -->|selects SVG| NS
    SS -->|selects SVG| OS
    SS -->|applies symbology| Map
    QGIS -->|renders| Map

    click CR "https://github.com/finnishtransportagency/liikennemerkit/tree/master/collections/"
    click NS "https://github.com/finnishtransportagency/liikennemerkit/tree/master/collections/new_signs/"
    click OS "https://github.com/finnishtransportagency/liikennemerkit/tree/master/collections/old_signs/"
    click SSfolder "https://github.com/finnishtransportagency/liikennemerkit/tree/master/collections/style_script/"
    click SS "https://github.com/finnishtransportagency/liikennemerkit/blob/master/collections/style_script/processing/sign_stylizer.py"
    click MI "https://github.com/finnishtransportagency/liikennemerkit/blob/master/metadata.ini"
    click Doc "https://github.com/finnishtransportagency/liikennemerkit/blob/master/README.md"

    classDef user fill:#dddddd,stroke:#999,stroke-width:1px
    classDef core fill:#c0c0ff,stroke:#6666aa,stroke-width:1px
    classDef plugin fill:#e0ccff,stroke:#aa66cc,stroke-width:1px
    classDef external fill:#ffc080,stroke:#cc6600,stroke-width:1px
    classDef folder fill:#cce5ff,stroke:#3399ff,stroke-width:1px
    classDef asset fill:#99ccff,stroke:#0066cc,stroke-width:1px
    classDef script fill:#ccffcc,stroke:#33cc33,stroke-width:1px
    classDef config fill:#e6ffe6,stroke:#66cc66,stroke-width:1px
    classDef doc fill:#f2f2f2,stroke:#999999,stroke-width:1px
    classDef output fill:#ffffb3,stroke:#cccc00,stroke-width:1px
```
