# digital-land/config architecture

> Architecture diagram of the GitHub repository digital-land/config, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/digital-land/config
- Repository: https://github.com/digital-land/config

## Overview

1. This repository is a configuration source of truth, not an application runtime. It stores CSV-based definitions for datasets and their processing pipelines, copied from original collection repositories and normalized to match the current specification.

2. The two core configuration surfaces are `collection/` and `pipeline/`. Each subdirectory represents one dataset/domain such as `historic-england`, `brownfield-land`, or `planning-application`, and contains the files that define how that dataset is described and processed.

3. `collection/<name>/` holds the dataset-level configuration for the published collection: `source.csv`, `endpoint.csv`, and `old-resource.csv`. These appear to describe where data comes from, what endpoint it is exposed through, and any legacy resource mapping retained for compatibility.

4. `pipeline/<name>/` holds the transformation pipeline for each dataset. The repeated CSV files such as `column.csv`, `combine.csv`, `concat.csv`, `convert.csv`, `default.csv`, `default-value.csv`, `expect.csv`, `filter.csv`, `lookup.csv`, `patch.csv`, `skip.csv`, and `transform.csv` represent rule sets for shaping incoming data into the expected schema.

5. The pipeline structure suggests a staged data-normalization flow: source data is filtered, transformed, combined, defaulted, and validated against expectations before being used by downstream systems. The `entity-organisation.csv` and `old-entity.csv` files indicate entity resolution and legacy mapping are part of the standard processing model.

6. The repository’s main boundary is between version-controlled config and externally managed exceptions. Most configs live in git, but some large or awkward files are intentionally excluded; the README calls out `pipeline/title-boundary/lookup.csv` as stored in S3 and manually maintained.

7. GitHub Actions in `.github/workflows/` implement the repository’s operational controls. There are workflows for validating endpoints, standardizing CSVs, adding data asynchronously, managing CA geographies, testing, and uploading to S3. This means CI/CD here is about config hygiene and publication, not app deployment.

8. The `.github/scripts/` directory contains repository-maintenance automation for things like endpoint checks, deduplication of CA geographies, retiring old CA data, and standardizing CSV files. These are supporting tools for keeping the config corpus consistent across many dataset folders.

9. `bin/` contains operational helper scripts such as `batch_assign_entities.py` and `fix_dates.py`, which likely apply bulk corrections to the configuration or generated data. They sit outside the main config model but support data cleanup and migration tasks.

10. `create_collection.py` and the `makerules/` plus `Makefile` layer suggest a templated/scaffolded workflow for creating or updating dataset collections and pipeline assets. The repo is designed to be regenerated or synchronized from conventions rather than hand-edited ad hoc.

11. The `tests/` tree provides three levels of assurance: acceptance tests around dataset config, integration tests for CSV processing, and unit tests for helper functions. That reflects a repo whose correctness depends on structure and conventions of many small files rather than on one large codebase.

12. `metadata.json` and `requirements.txt` indicate a Python-based toolchain for validation and transformation of these CSV configuration assets. The Python scripts and tests are the only executable logic; the primary artifact remains the configuration data itself.

13. For an architecture diagram, the central node is the config repository, with two major data stores (`collection/` and `pipeline/`), surrounded by maintenance automation (`scripts/`, `bin/`, GitHub Actions), and an external publication sink in S3 for excluded or uploaded artifacts. The intended flow is: source collection config → normalized pipeline/collection CSVs → validation/standardization in CI → publication/use by downstream digital land services.

Main entry points: [`pipeline`](https://github.com/digital-land/config/tree/main/pipeline) (Pipelines), [`collection`](https://github.com/digital-land/config/tree/main/collection) (Collections), [`.github/workflows`](https://github.com/digital-land/config/blob/main/.github/workflows) (Workflows), [`.github/scripts`](https://github.com/digital-land/config/blob/main/.github/scripts) (GitHub scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core config"]
  node_repo["Config repo<br/>source-of-truth"]
  node_collection[("Collections<br/>dataset configs")]
  node_pipeline[("Pipelines<br/>normalization rules")]
  node_collection_source["Source CSV<br/>collection spec"]
  node_collection_endpoint["Endpoint CSV<br/>collection spec"]
  node_collection_legacy["Legacy map<br/>collection spec"]
  node_pipeline_rules["Rule files<br/>pipeline spec"]
  node_pipeline_entity["Entity mapping<br/>pipeline spec"]
  node_pipeline_expect["Expectations<br/>pipeline spec"]
end

subgraph group_ops["Ops and automation"]
  node_gh_workflows["Workflows<br/>ci automation<br/>[workflows]"]
  node_gh_scripts["GitHub scripts<br/>maintenance automation<br/>[scripts]"]
  node_bin_scripts["Bin scripts<br/>ops utilities"]
  node_s3_sink[("S3 storage<br/>external sink")]
  node_downstream(("Downstream services<br/>consumers"))
end

subgraph group_quality["Quality and tooling"]
  node_makefiles["Make layer<br/>scaffold"]
  node_create_collection["Scaffold tool<br/>python utility"]
  node_tests["Tests<br/>verification suite"]
  node_python_tooling["Python tools<br/>runtime support<br/>[requirements.txt]"]
end

node_repo -->|"contains"| node_collection
node_repo -->|"contains"| node_pipeline
node_collection -->|"defines"| node_collection_source
node_collection -->|"defines"| node_collection_endpoint
node_collection -->|"defines"| node_collection_legacy
node_pipeline -->|"uses"| node_pipeline_rules
node_pipeline -->|"uses"| node_pipeline_entity
node_pipeline -->|"uses"| node_pipeline_expect
node_pipeline -.->|"exception"| node_s3_sink
node_makefiles -->|"generates"| node_collection
node_makefiles -->|"generates"| node_pipeline
node_create_collection -->|"supports"| node_makefiles
node_gh_workflows -->|"runs"| node_gh_scripts
node_gh_workflows -->|"executes"| node_tests
node_gh_workflows -->|"publishes"| node_s3_sink
node_gh_scripts -->|"checks"| node_collection
node_gh_scripts -->|"checks"| node_pipeline
node_bin_scripts -->|"fixes"| node_collection
node_bin_scripts -->|"fixes"| node_pipeline
node_tests -->|"depends on"| node_python_tooling
node_python_tooling -->|"enables"| node_gh_workflows
node_collection -->|"feeds"| node_downstream
node_pipeline -->|"feeds"| node_downstream

click node_collection "https://github.com/digital-land/config/tree/main/collection"
click node_pipeline "https://github.com/digital-land/config/tree/main/pipeline"
click node_makefiles "https://github.com/digital-land/config/tree/main/Makefile"
click node_create_collection "https://github.com/digital-land/config/blob/main/create_collection.py"
click node_tests "https://github.com/digital-land/config/tree/main/tests"
click node_python_tooling "https://github.com/digital-land/config/blob/main/requirements.txt"
click node_gh_workflows "https://github.com/digital-land/config/blob/main/.github/workflows"
click node_gh_scripts "https://github.com/digital-land/config/blob/main/.github/scripts"
click node_bin_scripts "https://github.com/digital-land/config/tree/main/bin"

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_repo,node_collection,node_pipeline,node_collection_source,node_collection_endpoint,node_collection_legacy,node_pipeline_rules,node_pipeline_entity,node_pipeline_expect toneBlue
class node_gh_workflows,node_gh_scripts,node_bin_scripts,node_s3_sink,node_downstream toneAmber
class node_makefiles,node_create_collection,node_tests,node_python_tooling toneMint
```

## Components

### Core config

Version-controlled CSV definitions for collections and pipelines.

- **Config repo**: source-of-truth · Central repository for normalized dataset and pipeline configuration.
- [Collections](https://github.com/digital-land/config/tree/main/collection): dataset configs · Dataset-level published collection definitions, one folder per domain. · `collection`
- [Pipelines](https://github.com/digital-land/config/tree/main/pipeline): normalization rules · Per-dataset transformation and validation rules expressed as CSV files. · `pipeline`
- **Source CSV**: collection spec · Defines where each collection pulls data from.
- **Endpoint CSV**: collection spec · Defines the published endpoint for a collection.
- **Legacy map**: collection spec · Retains old resource mappings for compatibility.
- **Rule files**: pipeline spec · Representative CSV rule sets for filtering, combining, converting, defaulting, looking up, patching, skipping, and transforming.
- **Entity mapping**: pipeline spec · Entity organisation and legacy entity mapping used during normalization.
- **Expectations**: pipeline spec · Schema and content checks applied to pipeline output.

### Ops and automation

Repository-maintenance scripts and CI workflows.

- [Workflows](https://github.com/digital-land/config/blob/main/.github/workflows): ci automation · GitHub Actions for validation, standardization, async add-data, CA geography management, testing, and S3 upload. · `.github/workflows`
- [GitHub scripts](https://github.com/digital-land/config/blob/main/.github/scripts): maintenance automation · Repository maintenance scripts for endpoint checks, deduplication, retirement, and CSV standardization. · `.github/scripts`
- [Bin scripts](https://github.com/digital-land/config/tree/main/bin): ops utilities · Operational helper scripts for bulk fixes and migrations. · `bin`
- **S3 storage**: external sink · External storage for excluded or uploaded artifacts such as manually maintained lookup files.
- **Downstream services**: consumers · Services that consume the published normalized configurations.

### Quality and tooling

Scaffolding, tests, and Python support code.

- [Make layer](https://github.com/digital-land/config/tree/main/Makefile): scaffold · Makefile and makerules used to create and maintain standardized assets. · `Makefile`
- [Scaffold tool](https://github.com/digital-land/config/blob/main/create_collection.py): python utility · Script for creating or updating collection structures. · `create_collection.py`
- [Tests](https://github.com/digital-land/config/tree/main/tests): verification suite · Acceptance, integration, and unit tests for repository conventions and CSV processing. · `tests`
- [Python tools](https://github.com/digital-land/config/blob/main/requirements.txt): runtime support · Python packaging and metadata supporting validation and transformation scripts. · `requirements.txt`

## Connections

- Config repo → Collections: contains · The repository stores collection configs as a top-level subsystem.
- Config repo → Pipelines: contains · The repository stores pipeline configs as a top-level subsystem.
- Collections → Source CSV: defines · Each collection folder includes source definitions.
- Collections → Endpoint CSV: defines · Each collection folder includes endpoint definitions.
- Collections → Legacy map: defines · Each collection folder preserves legacy resource mappings.
- Pipelines → Rule files: uses · Pipeline folders are composed of repeated CSV rule files.
- Pipelines → Entity mapping: uses · Pipelines include entity resolution and legacy entity mapping.
- Pipelines → Expectations: uses · Pipelines include expectation checks for normalized outputs.
- Pipelines → S3 storage: exception · One pipeline lookup file is intentionally kept outside git in S3.
- Make layer → Collections: generates · Make rules help create and maintain collection structures.
- Make layer → Pipelines: generates · Make rules help create and maintain pipeline structures.
- Scaffold tool → Make layer: supports · The scaffold script complements the Make-driven workflow.
- Workflows → GitHub scripts: runs · CI workflows call repository-maintenance scripts.
- Workflows → Tests: executes · The test workflow validates repository behavior and conventions.
- Workflows → S3 storage: publishes · Upload workflow sends selected artifacts to S3.
- GitHub scripts → Collections: checks · Maintenance scripts validate and standardize collection config files.
- GitHub scripts → Pipelines: checks · Maintenance scripts validate and standardize pipeline config files.
- Bin scripts → Collections: fixes · Operational helpers apply bulk corrections to config data.
- Bin scripts → Pipelines: fixes · Operational helpers apply bulk corrections to pipeline data.
- Tests → Python tools: depends on · Tests exercise the Python-based validation and processing toolchain.
- Python tools → Workflows: enables · Python tooling underpins workflow validation and standardization jobs.
- Collections → Downstream services: feeds · Published collection config is consumed by downstream digital land services.
- Pipelines → Downstream services: feeds · Normalized pipeline outputs are consumed by downstream digital land services.
