# neugates/neuopc architecture

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

- Interactive diagram: https://gitdiagram.com/neugates/neuopc
- Repository: https://github.com/neugates/neuopc

## Overview

##### Main Components
- OPC DA Client Components:
- Projects such as DaClient and neuclient include classes for browsing, discovery, and client interactions (e.g., DaBrowse.cs, DaDiscovery.cs, and DaServer.cs). These serve as the bridge to the legacy OPC DA environment.
- OPC UA Server Components:
- Projects like UaServer and neuserver implement the server-side functionality. They include components such as NeuNodeManager and NeuServer which expose OPC UA services.
- Common Libraries and Shared Types:
- The Common and neulib directories contain shared types and utilities (e.g., CommonType.cs) used by various components to maintain consistency.
- GUI/Front-End:
- The neuopc project (with MainForm, Client.cs, and server/client classes) appears to be the client-side application, likely providing a desktop GUI interface for monitoring or interacting with the protocol conversion.
- Configuration and Assets:
- The assets directory stores images used in the README (and possibly as part of the UI), while configuration files (such as .config and app.config in the UaServer project) manage runtime or environment settings.

##### Component Relationships and Interactions
- The GUI Layer (neuopc) acts as the user interface and initiates actions that flow to the underlying business logic and protocol conversion libraries.
- The DaClient/neuclient projects interact with the legacy OPC DA services. They likely serve as adapters that convert calls or data formats from OPC DA.
- The UA server components (UaServer/neuserver) use the conversion results to expose the OPC UA protocol, ensuring that clients connecting via UA see a coherent, modern interface.
- The Common libraries provide shared domain models and utility methods that are used across different parts of the system.
- External dependencies (such as OPC Foundation’s NetStandard.Opc.Ua.Server package for the server side, Dapper and Serilog for logging and data access, and SQLite for data persistence in neuopc) should also be represented as adjunct components or libraries that the main parts leverage.

##### Architectural Patterns & Design Principles
- Layered Architecture or Adapter Pattern: The separation between DA client adapters (DaClient/neuclient), translation or conversion logic, and the OPC UA exposure (UaServer/neuserver) illustrates a pattern where legacy systems are “wrapped” or adapted for modern protocols.
- Separation of Concerns: Different projects are focused on distinct responsibilities (GUI, communication adapters, server logic, and common types), making the system easier to manage and extend.
- Use of Third-Party Libraries: Emphasize integration points for external NuGet packages (e.g., OpcNetApi, OpcComRcw, Dapper, Serilog) which are critical to fulfilling the functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% GUI/Front-End
    subgraph "GUI/Front-End"
        GUI_MainForm["neuopc: MainForm"]:::gui
        GUI_Client["neuopc: Client"]:::gui
        GUI_Program["neuopc: Program"]:::gui
    end

    %% OPC DA Client Components
    subgraph "OPC DA Client Components"
        DA_DaClient["DaClient: DaClient"]:::da
        DA_Browse["DaClient: DaBrowse"]:::da
        DA_Discovery["DaClient: DaDiscovery"]:::da
        DA_Server["DaClient: DaServer"]:::da
        neuDA_DaClient["neuclient: DaClient"]:::da
        neuDA_Browse["neuclient: DaBrowse"]:::da
        neuDA_Discovery["neuclient: DaDiscovery"]:::da
        neuDA_Server["neuclient: DaServer"]:::da
    end

    %% OPC UA Server Components
    subgraph "OPC UA Server Components"
        UA_UaServer["UaServer: UaServer"]:::ua
        UA_NeuServer["UaServer: NeuServer"]:::ua
        UA_NeuNodeManager["UaServer: NeuNodeManager"]:::ua
        nUA_proj["neuserver: neuuserver csproj"]:::ua
        nUA_NeuServer["neuserver: NeuServer"]:::ua
        nUA_NeuNodeManager["neuserver: NeuNodeManager"]:::ua
        nUA_UaServer["neuserver: UaServer"]:::ua
    end

    %% Common Libraries and Shared Types
    subgraph "Common Libraries and Shared Types"
        Common_CommonType["Common: CommonType"]:::common
        Common_csproj["Common: Common csproj"]:::common
        nlib_CommonType["neulib: CommonType"]:::common
        nlib_csproj["neulib: neulib csproj"]:::common
    end

    %% Configuration and Assets
    subgraph "Configuration and Assets"
        Config["Configuration (.config)"]:::config
        Assets["Assets"]:::config
    end

    %% External Dependencies
    subgraph "External Dependencies"
        ext_OPC["OPC_Foundation_NetStandard.Opc.Ua.Server"]:::external
        ext_Dapper["Dapper"]:::external
        ext_Serilog["Serilog"]:::external
        ext_SQLite["SQLite"]:::external
    end

    %% Connections: GUI to OPC DA Clients
    GUI_MainForm -->|"initiates"| DA_DaClient
    GUI_Client -->|"initiates"| neuDA_DaClient

    %% Connections: OPC DA Clients to OPC UA Servers
    DA_Server -->|"convertsTo"| UA_UaServer
    neuDA_Server -->|"convertsTo"| nUA_UaServer

    %% Connections: Common Libraries used by components
    GUI_MainForm -->|"uses"| Common_CommonType
    DA_DaClient -->|"uses"| Common_CommonType
    neuDA_DaClient -->|"uses"| nlib_CommonType
    UA_UaServer -->|"uses"| Common_CommonType
    nUA_UaServer -->|"uses"| nlib_CommonType

    %% Connections: Configuration applied to components
    Config -->|"configures"| UA_UaServer
    Config -->|"configures"| nUA_UaServer
    Config -->|"configures"| GUI_MainForm

    %% Connections: External Dependencies integrated with components
    ext_OPC -->|"integratesWith"| UA_UaServer
    ext_Dapper -->|"integratesWith"| neuDA_DaClient
    ext_Serilog -->|"integratesWith"| DA_DaClient
    ext_SQLite -->|"integratesWith"| GUI_Client

    %% Styles
    classDef gui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef da fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ua fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef common fill:#E8DAEF,stroke:#AF7AC5,stroke-width:2px;
    classDef config fill:#FADBD8,stroke:#EC7063,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;

    %% Click Events for GUI/Front-End
    click GUI_MainForm "https://github.com/neugates/neuopc/blob/main/neuopc/MainForm.cs"
    click GUI_Client "https://github.com/neugates/neuopc/blob/main/neuopc/Client.cs"
    click GUI_Program "https://github.com/neugates/neuopc/blob/main/neuopc/Program.cs"

    %% Click Events for OPC DA Client Components - DaClient
    click DA_DaClient "https://github.com/neugates/neuopc/blob/main/DaClient/DaClient.cs"
    click DA_Browse "https://github.com/neugates/neuopc/blob/main/DaClient/DaBrowse.cs"
    click DA_Discovery "https://github.com/neugates/neuopc/blob/main/DaClient/DaDiscovery.cs"
    click DA_Server "https://github.com/neugates/neuopc/blob/main/DaClient/DaServer.cs"

    %% Click Events for OPC DA Client Components - neuclient
    click neuDA_DaClient "https://github.com/neugates/neuopc/blob/main/neuclient/DaClient.cs"
    click neuDA_Browse "https://github.com/neugates/neuopc/blob/main/neuclient/DaBrowse.cs"
    click neuDA_Discovery "https://github.com/neugates/neuopc/blob/main/neuclient/DaDiscovery.cs"
    click neuDA_Server "https://github.com/neugates/neuopc/blob/main/neuclient/DaServer.cs"

    %% Click Events for OPC UA Server Components - UaServer
    click UA_UaServer "https://github.com/neugates/neuopc/blob/main/UaServer/UaServer.cs"
    click UA_NeuServer "https://github.com/neugates/neuopc/blob/main/UaServer/NeuServer.cs"
    click UA_NeuNodeManager "https://github.com/neugates/neuopc/blob/main/UaServer/NeuNodeManager.cs"

    %% Click Events for OPC UA Server Components - neuserver
    click nUA_proj "https://github.com/neugates/neuopc/blob/main/neuserver/neuserver.csproj"
    click nUA_NeuServer "https://github.com/neugates/neuopc/blob/main/neuserver/NeuServer.cs"
    click nUA_NeuNodeManager "https://github.com/neugates/neuopc/blob/main/neuserver/NeuNodeManager.cs"
    click nUA_UaServer "https://github.com/neugates/neuopc/blob/main/neuserver/UaServer.cs"

    %% Click Events for Common Libraries and Shared Types
    click Common_CommonType "https://github.com/neugates/neuopc/blob/main/Common/CommonType.cs"
    click Common_csproj "https://github.com/neugates/neuopc/blob/main/Common/Common.csproj"
    click nlib_CommonType "https://github.com/neugates/neuopc/blob/main/neulib/CommonType.cs"
    click nlib_csproj "https://github.com/neugates/neuopc/blob/main/neulib/neulib.csproj"

    %% Click Events for Configuration and Assets
    click Config "https://github.com/neugates/neuopc/blob/main/.config/dotnet-tools.json"
    click Assets "https://github.com/neugates/neuopc/tree/main/assets/"
```
