# opensbr/digipoortwusconnection architecture

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

- Interactive diagram: https://gitdiagram.com/opensbr/digipoortwusconnection
- Repository: https://github.com/opensbr/digipoortwusconnection

## Overview

##### Project type and purpose
- This is a .NET console (or library) client application that uses WCF (“Connected Services”) to talk to the Dutch government’s Digipoort gateway.
- It provides sample code for three SOAP services: Aanleveren (sending messages), Ophalen (retrieving messages), and StatusInformatie (querying statuses).

##### File structure
- Top-level modules:
- Connected Services (auto-generated WCF proxies for each Digipoort endpoint)
- ServiceReferenceExtensions (partial classes to extend those proxies)
- WusChannel (custom binding, channel factory, certificate & security helpers)
- Helpers (file I/O, media-type constants)
- Program.cs (entry point / orchestration)
- app.config (endpoints, bindings, credentials, certificates)
- No database or UI layers—this is a pure client‐to‐external‐services integration sample.

##### Key insights from the README
- Purpose: demonstrate how to connect, authenticate, and exchange messages with Digipoort.
- Technologies: .NET WCF, custom bindings, X.509 certificates, SOAP over TLS.

a. Main components:
- Client Application (Program.cs)
- ServiceReference proxies (3 SOAP clients)
- ServiceReferenceExtensions (custom request builders)
- WusChannel module (binding & security)
- Helpers (FileIO, MediaTypeNames)
- Configuration (app.config + certificate file)
- External Digipoort endpoints (Aanleveren, Ophalen, StatusInformatie)
b. Relationships/interactions:
- Program invokes ServiceReferenceExtensions → they decorate messages and invoke ServiceReference proxy classes.
- Those proxies use WusChannelFactory (with WusCustomBinding + certificate loaded from app.config) to open a secure SOAP channel.
- Messages traverse over TLS to the external Digipoort services.
- Responses return along the same path back into Program.
- Helpers are used by both Program and ServiceReferenceExtensions for reading files and setting media types.
c. Architectural patterns/principles:
- Separation of concerns:
- “Core logic” in Program
- “Transport” in WusChannel
- “Service contracts” in Connected Services proxies
- “Extensions” in partial classes
- “Utilities” in Helpers
- Configuration-driven endpoints & credentials (no hard-coding)
- Dependency injection can be layered in later for testability (e.g., inject IWusChannelFactory)
d. Key technologies/frameworks:
- .NET Framework (C#)
- WCF Connected Services (SOAP + WSDL)
- Custom WCF binding (WusCustomBinding)
- X.509 certificate authentication (cs-bedrijven_procesinfrastructuur_nl.crt)
- Partial classes for proxy extension

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Application"
        Program["Program (Entry Point)"]:::internal
        subgraph "ServiceReferenceExtensions"
            ExtAan["Aanleveren Extension"]:::internal
            ExtOph["Ophalen Extension"]:::internal
            ExtStat["StatusInformatie Extension"]:::internal
        end
        subgraph "Connected Services - Proxies"
            ProxyAan["ServiceReferenceAanleverenProxy"]:::internal
            ProxyOph["ServiceReferenceOphalenProxy"]:::internal
            ProxyStat["ServiceReferenceStatusInformatieProxy"]:::internal
        end
        subgraph "WusChannel"
            WusFactory["WusChannelFactory"]:::internal
            WusClient["WusClient"]:::internal
            WusProfile["WusConnectionProfile"]:::internal
            WusBinding["WusCustomBinding"]:::internal
            WusHelpers["WusHelpers"]:::internal
        end
        subgraph "Helpers"
            FileIO["FileIO"]:::internal
            MediaType["MediaTypeNames"]:::internal
        end
    end

    Config["Configuration & Cert Store"]:::config

    subgraph External
        ExtAanServ["Aanleveren Endpoint"]:::external
        ExtOphServ["Ophalen Endpoint"]:::external
        ExtStatServ["StatusInformatie Endpoint"]:::external
    end

    Program -->|uses| ExtAan
    Program -->|uses| ExtOph
    Program -->|uses| ExtStat
    Program -->|uses| FileIO
    Program -->|uses| MediaType

    ExtAan -->|builds request| ProxyAan
    ExtOph -->|builds request| ProxyOph
    ExtStat -->|builds request| ProxyStat

    ProxyAan -->|via WusChannel| WusClient
    ProxyOph -->|via WusChannel| WusClient
    ProxyStat -->|via WusChannel| WusClient

    WusClient --> WusFactory
    WusFactory --> WusBinding
    WusFactory --> WusProfile
    WusFactory --> Config
    WusProfile --> Config
    WusBinding --> Config
    WusHelpers --> Config

    WusClient -->|sends over TLS| ExtAanServ
    WusClient -->|sends over TLS| ExtOphServ
    WusClient -->|sends over TLS| ExtStatServ

    ExtAanServ -->|response| WusClient
    ExtOphServ -->|response| WusClient
    ExtStatServ -->|response| WusClient

    click Program "https://github.com/opensbr/digipoortwusconnection/blob/master/Program.cs"
    click ProxyAan "https://github.com/opensbr/digipoortwusconnection/blob/master/Connected Services/ServiceReferenceAanleveren/Reference.cs"
    click ProxyOph "https://github.com/opensbr/digipoortwusconnection/blob/master/Connected Services/ServiceReferenceOphalen/Reference.cs"
    click ProxyStat "https://github.com/opensbr/digipoortwusconnection/blob/master/Connected Services/ServiceReferenceStatusInformatie/Reference.cs"
    click ExtAan "https://github.com/opensbr/digipoortwusconnection/blob/master/ServiceReferenceExtensions/ServiceReferenceAanleverenPartial.cs"
    click ExtOph "https://github.com/opensbr/digipoortwusconnection/blob/master/ServiceReferenceExtensions/ServiceReferenceOphalenPartial.cs"
    click ExtStat "https://github.com/opensbr/digipoortwusconnection/blob/master/ServiceReferenceExtensions/ServiceReferenceStatusInformatiePartial.cs"
    click WusFactory "https://github.com/opensbr/digipoortwusconnection/blob/master/WusChannel/WusChannelFactory.cs"
    click WusClient "https://github.com/opensbr/digipoortwusconnection/blob/master/WusChannel/WusClient.cs"
    click WusProfile "https://github.com/opensbr/digipoortwusconnection/blob/master/WusChannel/WusConnectionProfile.cs"
    click WusBinding "https://github.com/opensbr/digipoortwusconnection/blob/master/WusChannel/WusCustomBinding.cs"
    click WusHelpers "https://github.com/opensbr/digipoortwusconnection/blob/master/WusChannel/WusHelpers.cs"
    click FileIO "https://github.com/opensbr/digipoortwusconnection/blob/master/Helpers/FileIO.cs"
    click MediaType "https://github.com/opensbr/digipoortwusconnection/blob/master/Helpers/MediaTypeNames.cs"
    click Config "https://github.com/opensbr/digipoortwusconnection/blob/master/app.config"

    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px;
```
