# qgis/qgis-hub-website architecture

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

- Interactive diagram: https://gitdiagram.com/qgis/qgis-hub-website
- Repository: https://github.com/qgis/qgis-hub-website

## Overview

##### Main Components
- Client Side (Browser/User): Represents the end-user interface. It interacts with the server using HTTP/HTTPS.
- Reverse Proxy / Web Server: The dockerize/sites-enabled directory shows several configurations for development, staging, and production. These point to an Nginx container acting as the reverse proxy – routing traffic from external clients to the internal application server.
- Application Server (Django Application):
– uWSGI: The “dockerize/docker/uwsgi.conf” file indicates that uWSGI is used to serve the Django application.
– Django Application: The “qgis-app” folder contains the actual Django project, broken down into multiple Django apps (api, base, geopackages, etc.) following the MVC (model–view–controller, or more accurately MTV in Django) pattern.
- Database: Although the file tree doesn’t explicitly name the database, by convention Django projects use PostgreSQL or another RDBMS. The docker-compose file is likely to include a database container.
- Static File & Asset Storage: The “qgis-app/static” directory and various “templates” directories indicate that static assets (CSS/JS/images) and HTML templates are maintained within the project.
- Docker Containers & Orchestration: The “dockerize” folder, docker-compose YAML, and associated scripts illustrate that the entire deployment is containerized.

##### Relationships and Interactions
- Client requests are first received by the reverse proxy (Nginx) which routes them to the uWSGI server running inside the Django container.
- The Django application processes these requests by invoking the correct Django “app” logic (models, views, forms, etc.).
- Database communications occur within the Django application when reading or writing data.
- Static content (templates, CSS, JavaScript, media) is served either by Django in development or by a dedicated static server that can be coordinated via Docker.
- Docker-compose orchestrates the containers, ensuring that the web application, database, and any other services run together.

##### Important Architectural Patterns and Technologies
- MVC/MTV Pattern: The project uses Django’s architecture, separating the Models (database layer), Templates (view layer), and Views (controller logic).
- Containerization: The deployment via docker-compose and Dockerfiles enables isolation – the web server (uWSGI + Django) and reverse proxy (Nginx) are containerized.
- Multi-environment configuration: The file tree includes separate configurations for development, production, and staging (e.g., dev.conf, prod.conf, staging-ssl.conf).
- Continuous Integration/Testing: Files under .github/workflows and testing directories in each Django app highlight an integrated CI and test suite.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client (Browser)"]:::client
    B["Reverse Proxy (Nginx)"]:::infra

    A -->|"HTTP_Request"| B
    B -->|"Routes_Request"| UW

    subgraph "Django App Container"
        UW["uWSGI Server"]:::infra
        UW -->|"Invokes_Apps"| API
        
        subgraph "Django Apps"
            API["api"]:::app
            BASE["base"]:::app
            GP["geopackages"]:::app
            LD["layerdefinitions"]:::app
            MG["map_gallery"]:::app
            MOD["models"]:::app
            PS["processing_scripts"]:::app
            STY["styles"]:::app
            US["users"]:::app
            WF["wavefronts"]:::app
        end
        
        subgraph "Client Assets"
            TMP["Templates"]:::assets
            STATIC["Static Files"]:::assets
        end
    end

    API -->|"DB_Query"| E
    E["Database Container"]:::infra

    F["Docker Orchestration"]:::infra
    F -.-> B
    F -.-> UW
    F -.-> E

    %% Click Events
    click TMP "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/templates"
    click STATIC "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/static"
    click B "https://github.com/qgis/qgis-hub-website/tree/master/dockerize/sites-enabled"
    click UW "https://github.com/qgis/qgis-hub-website/blob/master/dockerize/docker/uwsgi.conf"
    click API "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/api"
    click BASE "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/base"
    click GP "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/geopackages"
    click LD "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/layerdefinitions"
    click MG "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/map_gallery"
    click MOD "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/models"
    click PS "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/processing_scripts"
    click STY "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/styles"
    click US "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/users"
    click WF "https://github.com/qgis/qgis-hub-website/tree/master/qgis-app/wavefronts"
    click E "https://github.com/qgis/qgis-hub-website/blob/master/dockerize/docker-compose.yml"
    click F "https://github.com/qgis/qgis-hub-website/tree/master/dockerize"

    %% Styles
    classDef client fill:#bbf,stroke:#333,stroke-width:2px;
    classDef infra fill:#f88,stroke:#333,stroke-width:2px;
    classDef app fill:#afa,stroke:#333,stroke-width:2px;
    classDef assets fill:#ccf,stroke:#333,stroke-width:2px;
```
