# nhsisl/londonfhirservice architecture

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

- Interactive diagram: https://gitdiagram.com/nhsisl/londonfhirservice
- Repository: https://github.com/nhsisl/londonfhirservice

## Overview

London FHIR Service exposes FHIR patient data and management APIs, with a core layer for access checks, record retrieval, comparison, and operational telemetry. The principal request path is a client calling the STU3 structured-record endpoint, which delegates through coordination to patient orchestration and its provider/access dependencies. Background comparison and Manage API capabilities are represented from the tree, but their runtime wiring was not sampled; those links are marked unverified. The README provides no further product detail.

Main entry points: [`LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs) (Patient orchestration), [`LondonFhirService.Api/Controllers/STU3/PatientController.cs`](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Controllers/STU3/PatientController.cs) (STU3 patient endpoint), [`LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs`](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs) (Compare queue orchestration), [`LondonFhirService.Core/Services/Foundations/FhirRecords`](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/FhirRecords) (FHIR record service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["FHIR API"]
  node_patient_api["STU3 patient endpoint"]
  node_api_formatters["FHIR JSON formatters<br/>[Formatters]"]
  node_correlation["Correlation middleware"]
end

subgraph group_core["Core services"]
  node_patient_coord["Patient coordination<br/>[STU3]"]
  node_patient_orch["Patient orchestration"]
  node_patient_service["STU3 patient service<br/>[STU3]"]
  node_provider_service["Provider service<br/>[Providers]"]
  node_consumer_access["Consumer access<br/>[ConsumerAccesses]"]
  node_security["Security broker<br/>[Securities]"]
  node_sql_storage[("SQL storage broker")]
end

subgraph group_compare["Record comparison"]
  node_compare_worker["Comparison worker"]
  node_queue_orch["Compare queue orchestration"]
  node_comparison_orch["Comparison orchestration"]
  node_match_processing["Resource matching<br/>[ResourceMatchings]"]
  node_difference_service["Record differences"]
  node_fhir_record_service["FHIR record service<br/>[FhirRecords]"]
end

subgraph group_manage["Management API"]
  node_manage_client["Manage client<br/>[App.tsx]"]
  node_manage_api["Management controllers<br/>[Controllers]"]
end

subgraph group_ops["Operations"]
  node_audit_metric["Audit and metrics"]
  node_audit_storage["Audit metric storage"]
  node_purge_worker["Audit metric purge"]
end

node_fhir_client(("FHIR client"))
node_external_provider(("FHIR provider"))

node_fhir_client -->|"requests structured data"| node_patient_api
node_patient_api -->|"delegates request"| node_patient_coord
node_patient_coord -.->|"coordinates"| node_patient_orch
node_patient_orch -->|"retrieves record"| node_patient_service
node_patient_orch -->|"uses providers"| node_provider_service
node_patient_orch -->|"checks access"| node_consumer_access
node_patient_orch -->|"gets current user"| node_security
node_external_provider -.->|"serves FHIR data"| node_patient_service
node_compare_worker -.->|"processes queue"| node_queue_orch
node_queue_orch -->|"claims records"| node_fhir_record_service
node_queue_orch -->|"records differences"| node_difference_service
node_comparison_orch -->|"gets matcher"| node_match_processing
node_fhir_record_service -.->|"persists records"| node_sql_storage
node_manage_client -.->|"calls management API"| node_manage_api
node_manage_api -.->|"manages records"| node_fhir_record_service
node_audit_metric -.->|"stores telemetry"| node_audit_storage
node_purge_worker -.->|"purges telemetry"| node_audit_storage
node_api_formatters -.->|"formats FHIR JSON"| node_patient_api
node_correlation -.->|"provides correlation"| node_patient_api

click node_patient_api "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Controllers/STU3/PatientController.cs"
click node_api_formatters "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Api/Formatters"
click node_correlation "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Middlewares/CorrelationMiddleware.cs"
click node_patient_coord "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Coordinations/Patients/STU3"
click node_patient_orch "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs"
click node_patient_service "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/Patients/STU3"
click node_provider_service "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/Providers"
click node_consumer_access "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/ConsumerAccesses"
click node_security "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Brokers/Securities"
click node_compare_worker "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Workers/ComparisonWorker.cs"
click node_queue_orch "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs"
click node_comparison_orch "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/Comparisons/ComparisonOrchestrationService.cs"
click node_match_processing "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Processings/ResourceMatchings"
click node_difference_service "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/FhirRecordDifferences"
click node_fhir_record_service "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/FhirRecords"
click node_sql_storage "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Brokers/Storages/Sql/StorageBroker.FhirRecord.cs"
click node_manage_client "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Manage.Client/src/App.tsx"
click node_manage_api "https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Manage/Controllers"
click node_audit_metric "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Dispatchers/AuditAndMetricsDispatcher.cs"
click node_audit_storage "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Brokers/AuditAndMetrics/AuditAndMetricStorageBroker.Audits.cs"
click node_purge_worker "https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Workers/AuditAndMetricPurgeWorker.cs"

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_patient_api,node_api_formatters,node_correlation,node_fhir_client toneBlue
class node_patient_coord,node_patient_orch,node_patient_service,node_provider_service,node_consumer_access,node_security,node_sql_storage toneAmber
class node_compare_worker,node_queue_orch,node_comparison_orch,node_match_processing,node_difference_service,node_fhir_record_service toneMint
class node_manage_client,node_manage_api toneRose
class node_audit_metric,node_audit_storage,node_purge_worker,node_external_provider toneIndigo
```

## Components

### FHIR API

- [STU3 patient endpoint](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Controllers/STU3/PatientController.cs): `LondonFhirService.Api/Controllers/STU3/PatientController.cs`
- [FHIR JSON formatters](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Api/Formatters): `LondonFhirService.Api/Formatters`
- [Correlation middleware](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Middlewares/CorrelationMiddleware.cs): `LondonFhirService.Api/Middlewares/CorrelationMiddleware.cs`

### Core services

- [Patient coordination](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Coordinations/Patients/STU3): `LondonFhirService.Core/Services/Coordinations/Patients/STU3`
- [Patient orchestration](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs): `LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`
- [STU3 patient service](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/Patients/STU3): `LondonFhirService.Core/Services/Foundations/Patients/STU3`
- [Provider service](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/Providers): `LondonFhirService.Core/Services/Foundations/Providers`
- [Consumer access](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/ConsumerAccesses): `LondonFhirService.Core/Services/Foundations/ConsumerAccesses`
- [Security broker](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Brokers/Securities): `LondonFhirService.Core/Brokers/Securities`
- [SQL storage broker](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Brokers/Storages/Sql/StorageBroker.FhirRecord.cs): `LondonFhirService.Core/Brokers/Storages/Sql/StorageBroker.FhirRecord.cs`

### Record comparison

- [Comparison worker](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Workers/ComparisonWorker.cs): `LondonFhirService.Api/Workers/ComparisonWorker.cs`
- [Compare queue orchestration](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs): `LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs`
- [Comparison orchestration](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Services/Orchestrations/Comparisons/ComparisonOrchestrationService.cs): `LondonFhirService.Core/Services/Orchestrations/Comparisons/ComparisonOrchestrationService.cs`
- [Resource matching](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Processings/ResourceMatchings): `LondonFhirService.Core/Services/Processings/ResourceMatchings`
- [Record differences](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/FhirRecordDifferences): `LondonFhirService.Core/Services/Foundations/FhirRecordDifferences`
- [FHIR record service](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Core/Services/Foundations/FhirRecords): `LondonFhirService.Core/Services/Foundations/FhirRecords`

### Management API

- [Manage client](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Manage.Client/src/App.tsx): `LondonFhirService.Manage.Client/src/App.tsx`
- [Management controllers](https://github.com/nhsisl/londonfhirservice/tree/main/LondonFhirService.Manage/Controllers): `LondonFhirService.Manage/Controllers`

### Operations

- [Audit and metrics](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Dispatchers/AuditAndMetricsDispatcher.cs): `LondonFhirService.Api/Dispatchers/AuditAndMetricsDispatcher.cs`
- [Audit metric storage](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Core/Brokers/AuditAndMetrics/AuditAndMetricStorageBroker.Audits.cs): `LondonFhirService.Core/Brokers/AuditAndMetrics/AuditAndMetricStorageBroker.Audits.cs`
- [Audit metric purge](https://github.com/nhsisl/londonfhirservice/blob/main/LondonFhirService.Api/Workers/AuditAndMetricPurgeWorker.cs): `LondonFhirService.Api/Workers/AuditAndMetricPurgeWorker.cs`

### Other components

- **FHIR client**
- **FHIR provider**

## Connections

- FHIR client → STU3 patient endpoint: requests structured data (evidence: `LondonFhirService.Api/Controllers/STU3/PatientController.cs`)
- STU3 patient endpoint → Patient coordination: delegates request (evidence: `LondonFhirService.Api/Controllers/STU3/PatientController.cs`)
- Patient coordination → Patient orchestration: coordinates
- Patient orchestration → STU3 patient service: retrieves record (evidence: `LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`)
- Patient orchestration → Provider service: uses providers (evidence: `LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`)
- Patient orchestration → Consumer access: checks access (evidence: `LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`)
- Patient orchestration → Security broker: gets current user (evidence: `LondonFhirService.Core/Services/Orchestrations/Patients/STU3/Stu3PatientOrchestrationService.cs`)
- FHIR provider → STU3 patient service: serves FHIR data
- Comparison worker → Compare queue orchestration: processes queue
- Compare queue orchestration → FHIR record service: claims records (evidence: `LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs`)
- Compare queue orchestration → Record differences: records differences (evidence: `LondonFhirService.Core/Services/Orchestrations/CompareQueue/CompareQueueOrchestrationService.cs`)
- Comparison orchestration → Resource matching: gets matcher (evidence: `LondonFhirService.Core/Services/Orchestrations/Comparisons/ComparisonOrchestrationService.cs`)
- FHIR record service → SQL storage broker: persists records
- Manage client → Management controllers: calls management API
- Management controllers → FHIR record service: manages records
- Audit and metrics → Audit metric storage: stores telemetry
- Audit metric purge → Audit metric storage: purges telemetry
- FHIR JSON formatters → STU3 patient endpoint: formats FHIR JSON
- Correlation middleware → STU3 patient endpoint: provides correlation
