# hdruk/gateway-api architecture

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

- Interactive diagram: https://gitdiagram.com/hdruk/gateway-api
- Repository: https://github.com/hdruk/gateway-api
- Video tour (about a minute): https://gitdiagram.com/hdruk/gateway-api/video

## Overview

HDR UK Gateway API is a Laravel backend for Gateway clients. Its primary workflow is an HTTP request routed to versioned API controllers, which validate and handle domain operations and return API responses; the repository also supports metadata federation ingestion, dataset versioning, audit logging, and external metadata translation. The graph highlights those domain stages and the model layer. Some controller and model behavior is represented by directory-level nodes because only selected files were sampled; unsampled connections are omitted.

Main entry points: [`app/Traits/GatewayMetadataIngestionTrait.php`](https://github.com/hdruk/gateway-api/blob/dev/app/Traits/GatewayMetadataIngestionTrait.php) (Federation ingestion), [`app/Services/GatewayMetadataIngestionService.php`](https://github.com/hdruk/gateway-api/blob/dev/app/Services/GatewayMetadataIngestionService.php) (Ingestion service), [`app/Auditor/Auditor.php`](https://github.com/hdruk/gateway-api/blob/dev/app/Auditor/Auditor.php) (Audit logger), [`app/Http/Controllers/Api/V1/ReviewController.php`](https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V1/ReviewController.php) (Review endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API delivery"]
  node_routes["API route registry<br/>[routes.php]"]
  node_routes2["V2 route registry<br/>[routes_v2.php]"]
  node_controllers["Versioned API controllers"]
  node_review["Review endpoints"]
  node_darreview["DAR review endpoints"]
  node_network["Custodian networks"]
end

subgraph group_domain["Gateway domain"]
  node_entities["Gateway entities"]
  node_dataset["Dataset records<br/>[Dataset.php]"]
  node_version["Dataset versions<br/>[DatasetVersion.php]"]
  node_team["Team records<br/>[Team.php]"]
  node_application["API applications<br/>[Application.php]"]
  node_database[("Gateway database")]
end

subgraph group_federation["Metadata federation"]
  node_gmi["Ingestion service"]
  node_ingest["Federation ingestion"]
  node_mmc["Metadata translation"]
  node_federationcmd["Ingestion command"]
end

subgraph group_operations["Audit and services"]
  node_audit["Audit logger<br/>[Auditor.php]"]
  node_auditjob["Audit log job<br/>[AuditLogJob.php]"]
end

node_client(("API client"))
node_traser["TRASER service"]

node_client -->|"sends request"| node_routes
node_routes -->|"dispatches"| node_controllers
node_routes2 -->|"dispatches"| node_network
node_review -->|"reads reviews"| node_entities
node_review -->|"logs actions"| node_audit
node_darreview -->|"logs actions"| node_audit
node_network -->|"uses records"| node_entities
node_federationcmd -->|"runs ingestion"| node_gmi
node_gmi -->|"loads team"| node_team
node_gmi -->|"onboards metadata"| node_ingest
node_ingest -->|"reads and updates"| node_dataset
node_ingest -->|"versions metadata"| node_version
node_ingest -->|"translates metadata"| node_mmc
node_mmc -->|"calls translation"| node_traser
node_audit -->|"dispatches job"| node_auditjob
node_dataset -.->|"queries records"| node_database
node_version -.->|"queries records"| node_database
node_team -.->|"queries records"| node_database
node_application -.->|"stores records"| node_database

click node_routes "https://github.com/hdruk/gateway-api/blob/dev/config/routes.php"
click node_routes2 "https://github.com/hdruk/gateway-api/blob/dev/config/routes_v2.php"
click node_controllers "https://github.com/hdruk/gateway-api/tree/dev/app/Http/Controllers/Api"
click node_review "https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V1/ReviewController.php"
click node_darreview "https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V1/DataAccessApplicationReviewController.php"
click node_network "https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V2/DataCustodianNetworksController.php"
click node_entities "https://github.com/hdruk/gateway-api/tree/dev/app/Models"
click node_dataset "https://github.com/hdruk/gateway-api/blob/dev/app/Models/Dataset.php"
click node_version "https://github.com/hdruk/gateway-api/blob/dev/app/Models/DatasetVersion.php"
click node_team "https://github.com/hdruk/gateway-api/blob/dev/app/Models/Team.php"
click node_application "https://github.com/hdruk/gateway-api/blob/dev/app/Models/Application.php"
click node_gmi "https://github.com/hdruk/gateway-api/blob/dev/app/Services/GatewayMetadataIngestionService.php"
click node_ingest "https://github.com/hdruk/gateway-api/blob/dev/app/Traits/GatewayMetadataIngestionTrait.php"
click node_mmc "https://github.com/hdruk/gateway-api/blob/dev/app/MetadataManagementController/MetadataManagementController.php"
click node_federationcmd "https://github.com/hdruk/gateway-api/blob/dev/app/Console/Commands/GatewayMetadataIngestion.php"
click node_audit "https://github.com/hdruk/gateway-api/blob/dev/app/Auditor/Auditor.php"
click node_auditjob "https://github.com/hdruk/gateway-api/blob/dev/app/Jobs/AuditLogJob.php"

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_routes,node_routes2,node_controllers,node_review,node_darreview,node_network,node_client toneBlue
class node_entities,node_dataset,node_version,node_team,node_application,node_database toneAmber
class node_gmi,node_ingest,node_mmc,node_federationcmd toneMint
class node_audit,node_auditjob toneRose
class node_traser toneIndigo
```

## Components

### API delivery

- [API route registry](https://github.com/hdruk/gateway-api/blob/dev/config/routes.php): `config/routes.php`
- [V2 route registry](https://github.com/hdruk/gateway-api/blob/dev/config/routes_v2.php): `config/routes_v2.php`
- [Versioned API controllers](https://github.com/hdruk/gateway-api/tree/dev/app/Http/Controllers/Api): `app/Http/Controllers/Api`
- [Review endpoints](https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V1/ReviewController.php): `app/Http/Controllers/Api/V1/ReviewController.php`
- [DAR review endpoints](https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V1/DataAccessApplicationReviewController.php): `app/Http/Controllers/Api/V1/DataAccessApplicationReviewController.php`
- [Custodian networks](https://github.com/hdruk/gateway-api/blob/dev/app/Http/Controllers/Api/V2/DataCustodianNetworksController.php): `app/Http/Controllers/Api/V2/DataCustodianNetworksController.php`

### Gateway domain

- [Gateway entities](https://github.com/hdruk/gateway-api/tree/dev/app/Models): `app/Models`
- [Dataset records](https://github.com/hdruk/gateway-api/blob/dev/app/Models/Dataset.php): `app/Models/Dataset.php`
- [Dataset versions](https://github.com/hdruk/gateway-api/blob/dev/app/Models/DatasetVersion.php): `app/Models/DatasetVersion.php`
- [Team records](https://github.com/hdruk/gateway-api/blob/dev/app/Models/Team.php): `app/Models/Team.php`
- [API applications](https://github.com/hdruk/gateway-api/blob/dev/app/Models/Application.php): `app/Models/Application.php`
- **Gateway database**

### Metadata federation

- [Ingestion service](https://github.com/hdruk/gateway-api/blob/dev/app/Services/GatewayMetadataIngestionService.php): `app/Services/GatewayMetadataIngestionService.php`
- [Federation ingestion](https://github.com/hdruk/gateway-api/blob/dev/app/Traits/GatewayMetadataIngestionTrait.php): `app/Traits/GatewayMetadataIngestionTrait.php`
- [Metadata translation](https://github.com/hdruk/gateway-api/blob/dev/app/MetadataManagementController/MetadataManagementController.php): `app/MetadataManagementController/MetadataManagementController.php`
- [Ingestion command](https://github.com/hdruk/gateway-api/blob/dev/app/Console/Commands/GatewayMetadataIngestion.php): `app/Console/Commands/GatewayMetadataIngestion.php`

### Audit and services

- [Audit logger](https://github.com/hdruk/gateway-api/blob/dev/app/Auditor/Auditor.php): `app/Auditor/Auditor.php`
- [Audit log job](https://github.com/hdruk/gateway-api/blob/dev/app/Jobs/AuditLogJob.php): `app/Jobs/AuditLogJob.php`

### Other components

- **API client**
- **TRASER service**

## Connections

- API client → API route registry: sends request (evidence: `config/routes.php`)
- API route registry → Versioned API controllers: dispatches (evidence: `config/routes.php`)
- V2 route registry → Custodian networks: dispatches (evidence: `config/routes_v2.php`)
- Review endpoints → Gateway entities: reads reviews (evidence: `app/Http/Controllers/Api/V1/ReviewController.php`)
- Review endpoints → Audit logger: logs actions (evidence: `app/Http/Controllers/Api/V1/ReviewController.php`)
- DAR review endpoints → Audit logger: logs actions (evidence: `app/Http/Controllers/Api/V1/DataAccessApplicationReviewController.php`)
- Custodian networks → Gateway entities: uses records (evidence: `app/Http/Controllers/Api/V2/DataCustodianNetworksController.php`)
- Ingestion command → Ingestion service: runs ingestion (evidence: `app/Console/Commands/GatewayMetadataIngestion.php`)
- Ingestion service → Team records: loads team (evidence: `app/Services/GatewayMetadataIngestionService.php`)
- Ingestion service → Federation ingestion: onboards metadata (evidence: `app/Services/GatewayMetadataIngestionService.php`)
- Federation ingestion → Dataset records: reads and updates (evidence: `app/Traits/GatewayMetadataIngestionTrait.php`)
- Federation ingestion → Dataset versions: versions metadata (evidence: `app/Traits/GatewayMetadataIngestionTrait.php`)
- Federation ingestion → Metadata translation: translates metadata (evidence: `app/Traits/GatewayMetadataIngestionTrait.php`)
- Metadata translation → TRASER service: calls translation (evidence: `app/MetadataManagementController/MetadataManagementController.php`)
- Audit logger → Audit log job: dispatches job (evidence: `app/Auditor/Auditor.php`)
- Dataset records → Gateway database: queries records
- Dataset versions → Gateway database: queries records
- Team records → Gateway database: queries records
- API applications → Gateway database: stores records
