# defra/apha-cdc-apps architecture

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

- Interactive diagram: https://gitdiagram.com/defra/apha-cdc-apps
- Repository: https://github.com/defra/apha-cdc-apps

## Overview

D2R2 is an APHA web application for authoring, reviewing, versioning, and publishing structured animal-disease surveillance profiles. Users enter through the MVC portal, which calls the REST API; API feature endpoints dispatch profile, species, and report operations, with profile search and management forming a central workflow. The API also exposes contributor, section, note, prioritisation, reference-data, user, and static-report capabilities. The README documents the portal/API split and CIDM external sign-in. Several feature and persistence relationships are represented only at subsystem level because their implementation was not sampled.

Main entry points: [`src/CDC.Api/Program.cs`](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Program.cs) (REST API), [`src/CDC.Web/Program.cs`](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Program.cs) (MVC portal), [`src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs`](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs) (Profile management), [`src/CDC.Web/Features/Account/AccountController.cs`](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Features/Account/AccountController.cs) (Account flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web portal"]
  node_portal["MVC portal<br/>[Program.cs]"]
  node_account["Account flow"]
  node_api_client["Typed API client<br/>[ApiClient.cs]"]
end

subgraph group_api["Profile API"]
  node_api_host["REST API<br/>[Program.cs]"]
  node_profile_search["Profile search"]
  node_profile_management["Profile management"]
  node_manage_handler["Manage query handler"]
  node_sections["Profile sections<br/>[ProfileSections]"]
  node_contributors["Contributors"]
  node_notes["Profile notes<br/>[ProfileNotes]"]
  node_reports["Profile reports"]
end

subgraph group_domain["Supporting capabilities"]
  node_species["Species taxonomy"]
  node_prioritisation["Prioritisation"]
  node_reference["Reference data<br/>[ReferenceData]"]
  node_users["User resolution<br/>[Users]"]
  node_static_reports["Static reports<br/>[StaticReports]"]
end

subgraph group_auth["Authentication"]
  node_cidm["CIDM sign-in"]
  node_entra["Entra sign-in"]
end

subgraph group_storage["Persistence"]
  node_database[("Relational database")]
end

node_user(("Profile users"))

node_user -->|"uses"| node_portal
node_portal -.->|"routes requests"| node_account
node_portal -->|"configures"| node_api_client
node_api_client -->|"calls HTTP API"| node_api_host
node_api_host -->|"serves searches"| node_profile_search
node_api_host -->|"serves management"| node_profile_management
node_profile_management -->|"dispatches query"| node_manage_handler
node_manage_handler -->|"calls service"| node_profile_management
node_api_host -.->|"serves"| node_sections
node_api_host -.->|"serves"| node_contributors
node_api_host -.->|"serves"| node_notes
node_api_host -->|"serves reports"| node_reports
node_api_host -->|"serves taxonomy"| node_species
node_api_host -.->|"serves"| node_prioritisation
node_api_host -.->|"serves"| node_reference
node_api_host -.->|"serves"| node_users
node_api_host -.->|"serves"| node_static_reports
node_account -->|"starts external sign-in"| node_cidm
node_portal -->|"registers internal sign-in"| node_entra
node_profile_search -.->|"reads profiles"| node_database
node_profile_management -.->|"persists changes"| node_database
node_reports -->|"reads and writes"| node_database

click node_portal "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Program.cs"
click node_account "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Features/Account/AccountController.cs"
click node_api_client "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Infrastructure/ApiClient.cs"
click node_api_host "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Program.cs"
click node_profile_search "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileSearch/Queries/GetAllProfilesQueryHandler.cs"
click node_profile_management "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs"
click node_manage_handler "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileManagement/Queries/GetManageProfileQueryHandler.cs"
click node_sections "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileSections"
click node_contributors "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileContributors"
click node_notes "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileNotes"
click node_reports "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileReports/ProfileReportsController.cs"
click node_species "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/Species/SpeciesController.cs"
click node_prioritisation "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/PrioritisationVariables"
click node_reference "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ReferenceData"
click node_users "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/Users"
click node_static_reports "https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/StaticReports"
click node_cidm "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Auth.Cidm/CidmAuthenticationExtensions.cs"
click node_entra "https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Auth.Entra/EntraAuthenticationExtensions.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_portal,node_account,node_api_client,node_user toneBlue
class node_api_host,node_profile_search,node_profile_management,node_manage_handler,node_sections,node_contributors,node_notes,node_reports toneAmber
class node_species,node_prioritisation,node_reference,node_users,node_static_reports toneMint
class node_cidm,node_entra toneRose
class node_database toneIndigo
```

## Components

### Web portal

- [MVC portal](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Program.cs): `src/CDC.Web/Program.cs`
- [Account flow](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Features/Account/AccountController.cs): `src/CDC.Web/Features/Account/AccountController.cs`
- [Typed API client](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Web/Infrastructure/ApiClient.cs): `src/CDC.Web/Infrastructure/ApiClient.cs`

### Profile API

- [REST API](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Program.cs): `src/CDC.Api/Program.cs`
- [Profile search](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileSearch/Queries/GetAllProfilesQueryHandler.cs): `src/CDC.Api/Features/ProfileSearch/Queries/GetAllProfilesQueryHandler.cs`
- [Profile management](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs): `src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs`
- [Manage query handler](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileManagement/Queries/GetManageProfileQueryHandler.cs): `src/CDC.Api/Features/ProfileManagement/Queries/GetManageProfileQueryHandler.cs`
- [Profile sections](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileSections): `src/CDC.Api/Features/ProfileSections`
- [Contributors](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileContributors): `src/CDC.Api/Features/ProfileContributors`
- [Profile notes](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ProfileNotes): `src/CDC.Api/Features/ProfileNotes`
- [Profile reports](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/ProfileReports/ProfileReportsController.cs): `src/CDC.Api/Features/ProfileReports/ProfileReportsController.cs`

### Supporting capabilities

- [Species taxonomy](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Api/Features/Species/SpeciesController.cs): `src/CDC.Api/Features/Species/SpeciesController.cs`
- [Prioritisation](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/PrioritisationVariables): `src/CDC.Api/Features/PrioritisationVariables`
- [Reference data](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/ReferenceData): `src/CDC.Api/Features/ReferenceData`
- [User resolution](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/Users): `src/CDC.Api/Features/Users`
- [Static reports](https://github.com/defra/apha-cdc-apps/tree/main/src/CDC.Api/Features/StaticReports): `src/CDC.Api/Features/StaticReports`

### Authentication

- [CIDM sign-in](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Auth.Cidm/CidmAuthenticationExtensions.cs): `src/CDC.Auth.Cidm/CidmAuthenticationExtensions.cs`
- [Entra sign-in](https://github.com/defra/apha-cdc-apps/blob/main/src/CDC.Auth.Entra/EntraAuthenticationExtensions.cs): `src/CDC.Auth.Entra/EntraAuthenticationExtensions.cs`

### Persistence

- **Relational database**

### Other components

- **Profile users**

## Connections

- Profile users → MVC portal: uses
- MVC portal → Account flow: routes requests
- MVC portal → Typed API client: configures (evidence: `src/CDC.Web/Program.cs`)
- Typed API client → REST API: calls HTTP API
- REST API → Profile search: serves searches (evidence: `src/CDC.Api/Features/ProfileSearch/Queries/GetAllProfilesQueryHandler.cs`)
- REST API → Profile management: serves management (evidence: `src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs`)
- Profile management → Manage query handler: dispatches query (evidence: `src/CDC.Api/Features/ProfileManagement/ProfileManagementController.cs`)
- Manage query handler → Profile management: calls service (evidence: `src/CDC.Api/Features/ProfileManagement/Queries/GetManageProfileQueryHandler.cs`)
- REST API → Profile sections: serves
- REST API → Contributors: serves
- REST API → Profile notes: serves
- REST API → Profile reports: serves reports (evidence: `src/CDC.Api/Features/ProfileReports/ProfileReportsController.cs`)
- REST API → Species taxonomy: serves taxonomy (evidence: `src/CDC.Api/Features/Species/SpeciesController.cs`)
- REST API → Prioritisation: serves
- REST API → Reference data: serves
- REST API → User resolution: serves
- REST API → Static reports: serves
- Account flow → CIDM sign-in: starts external sign-in (evidence: `src/CDC.Web/Features/Account/AccountController.cs`)
- MVC portal → Entra sign-in: registers internal sign-in (evidence: `src/CDC.Web/Program.cs`)
- Profile search → Relational database: reads profiles
- Profile management → Relational database: persists changes
- Profile reports → Relational database: reads and writes (evidence: `src/CDC.Api/Features/ProfileReports/ProfileReportsController.cs`)
