# ninanor/nina-catalogue architecture

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

- Interactive diagram: https://gitdiagram.com/ninanor/nina-catalogue
- Repository: https://github.com/ninanor/nina-catalogue

## Overview

The project is a full-stack web application built with Django and packaged with Docker, using a multi-container architecture. It combines “metadata_catalogue” as the main Django application (with separate apps for datasets, maps, users, etc.) and additional components like “bruno” which appears to manage catalogue services (CSW endpoints) and interoperability with different standards (ISO, QGIS, pycsw). There are also layers for infrastructure with directories dedicated to Nginx, Varnish, Docker Compose, and setup scripts, showing that the system is designed for both local development and production deployment with a strong emphasis on containerization.

##### Main Components
- Frontend / Client Layer:
– Although the project is primarily server-side rendered, include web browsers (clients) accessing the application.
- Reverse Proxy & Load Balancer:
– Represent Nginx, which is configured via its own directory and Dockerfiles.
- Caching Layer:
– Include Varnish (with its own Dockerfile and configuration) as the caching component.
- Django Application Server:
– Represent the main application contained in the “metadata_catalogue” directory. Break this component into its constituent Django “apps”:
▪ Core/Datasets/Maps/Users – these represent different business functionalities.
▪ Also note the “config” directory that contains the Django settings and routing logic.
- Catalogue Services:
– Represent the “bruno” component that seems dedicated to implementing catalogue functionalities using CSW standard (with multiple variants: ISO, QGIS, pycsw). Illustrate this as a microservice or sub-system that may interact with the main Django app via integration APIs or shared configurations.
- Auxiliary Processes and Tools:
– Include development and automation helpers indicated by files such as “helpers.sh”, pre-commit configuration, testing (pytest, coverage), and Docker Compose orchestration.
– Represent the “setup” container/process that is used for initial configuration (creation of secrets, etc.).
- External Data Sources / Database:
– While the file tree does not specify the database directory, it’s customary to represent a relational database (likely PostgreSQL or similar) used by Django. Include a database component and show its integration with the Django application.
- Documentation & Testing:

##### Relationships and Data Flows
– Client requests flowing through Nginx to the Varnish caching layer and finally to the Django backend.
– Communication between Django and the database.
– Interaction from the Django services to the “bruno” catalogue microservice (if they are designed to work as distributed components).
– Data flow from external services (or data harvesters) into the Catalogue (as seen in the “pycsw” and harvest scripts).
- How API calls (like CSW GetCapabilities, GetRecords, etc.) traverse between the catalogue service components and the main application.

##### Architectural Patterns & Design Principles
- Containerized Deployment:
– Emphasize the Docker-based orchestration (with Dockerfiles, docker-compose.yml in root and subdirectories, along with CI workflows in .github/workflows).
- Separation of Concerns:
– Clearly label components separating presentation (templates, static assets), business logic (Django apps in metadata_catalogue), catalogue service interfaces (bruno), and infrastructure services.
- Microservice-Oriented / Modular Design:
– Show the boundaries of the “bruno” service (a cataloguing engine with CSW endpoints) as a module that could be scaled independently or replaced.
- Configurability and Environment Specific Configuration:
– Indicate the “config/settings” folder that holds different settings (base, production, local, test) to show that environment-based configuration is a key design element.

##### Relevant Technologies, Frameworks, and Tools
- Django web framework, implying use of Django ORM, middleware, and template rendering.
- Docker and Docker Compose for containerized builds and deployments.
- Nginx and Varnish for reverse proxy and cache management.
- CI/CD tools as indicated by GitHub Actions (.github/workflows/* files).
- Testing and type checking (pytest, coverage, mypy).
- Additional scripts like “helpers.sh” to interact with the Docker/Django CLI.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client Layer
    subgraph "Client Layer"
        FE["Web Clients & Templates"]:::client
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        Nginx["Nginx Reverse Proxy"]:::infra
        Varnish["Varnish Cache"]:::infra
        DB["Database (PostgreSQL)"]:::infra
    end

    %% Application Layer
    subgraph "Application Layer"
        Django["Django Application Server"]:::app
        subgraph "Django Apps"
            Core["Core App"]:::app
            Datasets["Datasets App"]:::app
            Maps["Maps App"]:::app
            Users["Users App"]:::app
            Config["Configuration & Routing"]:::app
        end
    end

    %% Catalogue Services Layer
    subgraph "Catalogue Services"
        Bruno["Bruno Catalogue Service"]:::app
    end

    %% Auxiliary & Dev Tools
    subgraph "Auxiliary & Dev Tools"
        Setup["Setup Process"]:::aux
        Helpers["Helper Script: helpers.sh"]:::aux
        Entrypoint["Helper Script: entrypoint.sh"]:::aux
        CICD["CI/CD & Testing"]:::aux
        Docs["Documentation"]:::doc
        Compose["Docker Compose & Orchestration"]:::aux
    end

    %% Connections: Data flow
    FE -->|"request"| Nginx
    Nginx -->|"forwards"| Varnish
    Varnish -->|"routes to"| Django
    Django -->|"queries"| DB
    Django ---|"integrates with"| Bruno

    %% Connections: Internal Django apps aggregation
    Django --- Core
    Django --- Datasets
    Django --- Maps
    Django --- Users
    Django --- Config

    %% Click Events
    click FE "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/templates"
    click Nginx "https://github.com/ninanor/nina-catalogue/tree/master/nginx/"
    click Varnish "https://github.com/ninanor/nina-catalogue/tree/master/varnish/"
    click Django "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/"
    click Core "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/core/"
    click Datasets "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/datasets/"
    click Maps "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/maps/"
    click Users "https://github.com/ninanor/nina-catalogue/tree/master/metadata_catalogue/users/"
    click Config "https://github.com/ninanor/nina-catalogue/tree/master/config/"
    click Bruno "https://github.com/ninanor/nina-catalogue/tree/master/bruno/"
    click Setup "https://github.com/ninanor/nina-catalogue/tree/master/setup/"
    click Helpers "https://github.com/ninanor/nina-catalogue/blob/master/helpers.sh"
    click Entrypoint "https://github.com/ninanor/nina-catalogue/blob/master/entrypoint.sh"
    click CICD "https://github.com/ninanor/nina-catalogue/tree/master/.github/workflows/"
    click Docs "https://github.com/ninanor/nina-catalogue/tree/master/docs/"
    click Compose "https://github.com/ninanor/nina-catalogue/blob/master/docker-compose.yml"

    %% Styles
    classDef client fill:#DDEBF7,stroke:#1F497D,stroke-width:2px;
    classDef infra fill:#FCE4D6,stroke:#C65911,stroke-width:2px;
    classDef app fill:#E2EFDA,stroke:#5B9A68,stroke-width:2px;
    classDef aux fill:#FFF2CC,stroke:#BF9000,stroke-width:2px;
    classDef doc fill:#F8CBAD,stroke:#C0504D,stroke-width:2px;
```
