# stadt-bielefeld/bielefeldgeoclient architecture

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

- Interactive diagram: https://gitdiagram.com/stadt-bielefeld/bielefeldgeoclient
- Repository: https://github.com/stadt-bielefeld/bielefeldgeoclient

## Overview

##### Project type and purpose
- Full-stack, containerized web mapping application
- Purpose: Interactive mapping portal with user/role management, print-outs (via MapFish), digitizing, transport planning, and embed-in-portal integration

##### Main components
A.  Client Layer (Browser)
–  “Admin UI” (AngularJS-based)
–  “Map UI” (AngularJS-based map viewer with plugins: digitize, transport, geoEDITOR)
B.  Edge / Proxy
–  Nginx reverse proxy (serves static files + routes to backend)
C.  Application Layer
–  Python Flask/Gunicorn server (“munimap-app” container)
–  REST API endpoints (views/api.py, views/frontend.py, etc.)
–  Admin modules (views/admin.py + Angular controllers under munimap/frontend/js/admin)
–  Export/Print service (munimap/export + MapFish v3 integration)
–  Digitize + Transport plugins (munimap/munimap_transport + munimap/export)
–  Queue and worker (munimap/queue for background jobs: print, exports)
D.  Data Layer
–  PostgreSQL/PostGIS database (“munimap-postgis” container)
–  Mapbender schema & data (“munimap-postgis-mapbender” container or init scripts)
E.  External Services
–  WMS/WFS map services (configured via YAML under dev/data/map-configs)
–  Third-party transport API (invoked by munimap_transport/transport-api-service.js)
–  Form-Solutions portal (optional embed with token access)

##### Relationships and data flows
- Browser → Nginx → Gunicorn/Flask: all UI/API calls
- Browser → WMS/WFS: map tile/feature requests (configured endpoints)
- Flask → PostgreSQL: reads/writes user, maps, layers, project settings
- Flask → Queue → Worker → Filesystem/DB: asynchronous print job generation
- Flask → MapFish v3 (embedded) → PDF/JRXML templates → returns print output
- Flask → External transport API for journey planning
- Browser ↔ Flask: JSON config load/save, login/auth, administrative CRUD

##### Architectural patterns & design principles
- MVC separation inside Flask (views, forms, models under munimap/model)
- Modular frontend: AngularJS modules per feature (admin, digitize, transport)
- Configuration-driven: YAML under dev/data and dev/configs
- Containerization via Docker Compose (services for app, DB, nginx)
- Schema migrations with Alembic

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        AdminUI["Admin UI"]:::ui
        MapUI["Map UI"]:::ui
    end

    %% Edge / Proxy
    Nginx["Nginx Reverse Proxy"]:::backend

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Flask["Flask/Gunicorn App"]:::backend
        subgraph "REST API Endpoints"
            direction TB
            APIFrontend["frontend.py"]:::backend
            API["api.py"]:::backend
        end
        subgraph "Admin Modules"
            direction TB
            AdminBE["admin.py"]:::backend
            AdminFE["Admin Controllers/Services"]:::ui
        end
        subgraph "Export/Print Service"
            direction TB
            MapFishCore["mapfish.py/raw.py"]:::backend
            MapFishConfig["MapFish Configs/Templates"]:::backend
        end
        subgraph "Plugins"
            direction TB
            DigitizeBE["digitize.py"]:::backend
            DigitizeFE["Digitize Module"]:::ui
            GeoEditorFE["GeoEDITOR Module"]:::ui
            TransportBE["transport.py"]:::backend
            TransportCore["munimap_transport"]:::backend
            TransportFE["Transport Module"]:::ui
        end
        subgraph "Queue & Worker"
            direction TB
            Queue["Queue"]:::queue
            Worker["Worker"]:::queue
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        PostGIS["PostgreSQL/PostGIS"]:::db
        Mapbender["Mapbender Init"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        WMSWFS["WMS/WFS Services"]:::external
        TransportAPI["Transport API"]:::external
        Portal["Form-Solutions Portal"]:::external
    end

    %% Connections
    AdminUI -->|HTTP/REST| Nginx
    MapUI -->|HTTP/REST & WMS/WFS| Nginx
    Nginx -->|WSGI| Flask
    Flask -->|SQL| PostGIS
    Flask -->|SQL| Mapbender
    Flask -->|AMQP| Queue
    Queue -->|jobs| Worker
    Worker -->|FS/DB| PostGIS
    Flask -->|Embedded MapFish| MapFishCore
    MapFishCore -->|Config/Templates| MapFishConfig
    Flask -->|HTTP/REST| TransportAPI
    MapUI -->|WMS/WFS| WMSWFS
    Flask -->|JSON| AdminFE
    Flask -->|JSON| API
    Flask -->|JSON| APIFrontend

    %% Click Events
    click AdminUI "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/frontend/js/admin/"
    click MapUI "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/frontend/js/app.js"
    click MapUI "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/frontend/js/base-app.js"
    click MapUI "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/templates/munimap/app/"
    click Nginx "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/docker/munimap-nginx/default.conf"
    click Flask "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/application.py"
    click Flask "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/config.py"
    click Flask "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/gunicorn.conf"
    click Flask "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/Dockerfile"
    click API "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/views/api.py"
    click APIFrontend "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/views/frontend.py"
    click AdminBE "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/views/admin.py"
    click AdminFE "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/frontend/js/admin/"
    click MapFishCore "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/export/mapfish.py"
    click MapFishCore "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/export/raw.py"
    click MapFishConfig "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/dev/configs/mapfish/config.yaml"
    click MapFishConfig "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/dev/configs/mapfish/templates/"
    click DigitizeBE "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/views/digitize.py"
    click DigitizeFE "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/frontend/js/digitize/"
    click GeoEditorFE "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/frontend/js/geoeditor/"
    click TransportBE "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/views/transport.py"
    click TransportCore "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/munimap_transport/"
    click TransportFE "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/munimap/frontend/js/munimap_transport/"
    click Queue "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/queue/queue.py"
    click Worker "https://github.com/stadt-bielefeld/bielefeldgeoclient/blob/main/munimap/queue/worker.py"
    click PostGIS "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/docker/munimap-postgis/"
    click Mapbender "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/docker/munimap-postgis-mapbender/postgresql_init_data/"
    click WMSWFS "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/dev/data/map-configs/"
    click Portal "https://github.com/stadt-bielefeld/bielefeldgeoclient/tree/main/dev/data/app-configs/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef queue fill:#FFE4B5,stroke:#000,stroke-width:1px
```
