# jorgesoap/aveva_trn architecture

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

- Interactive diagram: https://gitdiagram.com/jorgesoap/aveva_trn
- Repository: https://github.com/jorgesoap/aveva_trn

## Overview

##### Main Components
- Sample Exercises: The core of the project is composed of multiple exercises (Ex1, Ex2, Ex3, Ex4, Ex5) that each focus on a separate aspect of interacting with the PI System via the AFSDK.
- AF Database: The provided “AF Database - Green Power Company.xml” is central to the sample’s operation. It represents the external PI/AF data source that each exercise interacts with.
- Test Suite: The “Tests” folder contains test projects which are used both for unit-level and integrated testing of the sample solutions.
- Configuration & Build Infrastructure: Files like appsettings.placeholder.json (to be renamed and filled in as appsettings.json), Directory.Build.props, azure-pipelines.yml, and others support environment configuration, continuous integration, and enforcing coding styles.

##### Relationships and Interactions
- Test Projects → Exercise Projects: The test suite executes methods within the exercise projects to verify that each specific use case behaves as expected.
- Configuration Files → Exercise Projects and Tests: Global settings (such as configurations from app.config and appsettings.json) affect how the projects locate and interact with the AF Database.
- External Dependency → PI System Explorer/AF Database: The steps in the README indicate that users must import the provided AF database into PI System Explorer, which is a clear external dependency.
- CI/CD Infrastructure: Files like azure-pipelines.yml indicate integration with automated build and testing processes.

##### Architectural Patterns and Design Principles
- Modular Design: Although these are sample exercises, each one is built as a separate module to demonstrate specific functionalities. This separation makes it easier to validate individual functionalities.
- Test-Driven Emphasis: The inclusion of tests for both unit and integration levels suggests that the project’s architecture is designed to encourage TDD practices.
- Configurability: The use of multiple config files (app.config, appsettings.json) emphasizes the importance of externalizing configurations.
- Simplistic and Educational Structure: As a “Getting Started” sample, the design intentionally focuses on clarity and step-by-step interaction with a core product (the PI System).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Build Infrastructure
    subgraph "Configuration & Build Infrastructure"
        Config["Configuration & Build Infrastructure"]:::config
        subgraph "Config Files"
            DBProps["Directory.Build.props"]:::config
            AppSettings["appsettings.placeholder.json"]:::config
            AzurePipelines["azure-pipelines.yml"]:::config
        end
    end

    %% Exercise Modules (Primary Versions)
    subgraph "Exercise Modules"
        Ex1Sln["Ex1: Connection and Hierarchy Basics"]:::exercise
        Ex2Sln["Ex2: Searching For Assets"]:::exercise
        Ex3Sln["Ex3: Reading And Writing Data"]:::exercise
        Ex4Sln["Ex4: Building An AF Hierarchy"]:::exercise
        Ex5Sln["Ex5: Working With Event Frames"]:::exercise
    end

    %% Alternate Versions of Exercise Modules
    subgraph "Alternate Exercise Directories"
        Ex1Alt["Ex1: Connection and Hierarchy Basics (Alternate)"]:::exercise
        Ex2Alt["Ex2: Searching For Assets (Alternate)"]:::exercise
        Ex3Alt["Ex3: Reading And Writing Data (Alternate)"]:::exercise
        Ex4Alt["Ex4: Building An AF Hierarchy (Alternate)"]:::exercise
        Ex5Alt["Ex5: Working With Event Frames (Alternate)"]:::exercise
    end

    %% Test Suite
    Tests["Tests"]:::test

    %% PI System Group
    subgraph "PI System"
        AFDB["(AF Database – Green Power Company)"]:::database
        PISE["PI System Explorer"]:::external
    end

    %% Connections from Configuration to Modules and Tests
    Config -->|"configures"| Ex1Sln
    Config -->|"configures"| Ex2Sln
    Config -->|"configures"| Ex3Sln
    Config -->|"configures"| Ex4Sln
    Config -->|"configures"| Ex5Sln
    Config -->|"configures"| Tests

    %% Connections from Config Files to Configuration (for illustration)
    DBProps --> Config
    AppSettings --> Config
    AzurePipelines --> Config

    %% Link Primary Exercise Modules to their Alternate Versions (dashed line)
    Ex1Sln -- "alt" --- Ex1Alt
    Ex2Sln -- "alt" --- Ex2Alt
    Ex3Sln -- "alt" --- Ex3Alt
    Ex4Sln -- "alt" --- Ex4Alt
    Ex5Sln -- "alt" --- Ex5Alt

    %% Tests validate each Exercise Module
    Tests -->|"tests"| Ex1Sln
    Tests -->|"tests"| Ex2Sln
    Tests -->|"tests"| Ex3Sln
    Tests -->|"tests"| Ex4Sln
    Tests -->|"tests"| Ex5Sln

    %% Exercise Modules interact with the AF Database
    Ex1Sln -->|"uses"| AFDB
    Ex2Sln -->|"uses"| AFDB
    Ex3Sln -->|"uses"| AFDB
    Ex4Sln -->|"uses"| AFDB
    Ex5Sln -->|"uses"| AFDB
    Ex1Alt -->|"uses"| AFDB
    Ex2Alt -->|"uses"| AFDB
    Ex3Alt -->|"uses"| AFDB
    Ex4Alt -->|"uses"| AFDB
    Ex5Alt -->|"uses"| AFDB

    %% External Tools interaction with AF Database
    PISE -->|"imports"| AFDB

    %% Click Events for Exercise Modules (Primary and Alternate)
    click Ex1Sln "https://github.com/jorgesoap/aveva_trn/tree/main/Ex1-Connection-And-Hierarchy-Basics-Sln"
    click Ex1Alt "https://github.com/jorgesoap/aveva_trn/tree/main/Ex1-Connection-And-Hierarchy-Basics"
    
    click Ex2Sln "https://github.com/jorgesoap/aveva_trn/tree/main/Ex2-Searching-For-Assets-Sln"
    click Ex2Alt "https://github.com/jorgesoap/aveva_trn/tree/main/Ex2-Searching-For-Assets"
    
    click Ex3Sln "https://github.com/jorgesoap/aveva_trn/tree/main/Ex3-Reading-And-Writing-Data-Sln"
    click Ex3Alt "https://github.com/jorgesoap/aveva_trn/tree/main/Ex3-Reading-And-Writing-Data"
    
    click Ex4Sln "https://github.com/jorgesoap/aveva_trn/tree/main/Ex4-Building-An-AF-Hierarchy-Sln"
    click Ex4Alt "https://github.com/jorgesoap/aveva_trn/tree/main/Ex4-Building-An-AF-Hierarchy"
    
    click Ex5Sln "https://github.com/jorgesoap/aveva_trn/tree/main/Ex5-Working-With-Event-Frames-Sln"
    click Ex5Alt "https://github.com/jorgesoap/aveva_trn/tree/main/Ex5-Working-With-EventFrames"
    
    %% Click Events for AF Database, Tests, and Config Files
    click AFDB "https://github.com/jorgesoap/aveva_trn/blob/main/AF Database - Green Power Company.xml"
    click Tests "https://github.com/jorgesoap/aveva_trn/tree/main/Tests"
    click DBProps "https://github.com/jorgesoap/aveva_trn/blob/main/Directory.Build.props"
    click AppSettings "https://github.com/jorgesoap/aveva_trn/blob/main/appsettings.placeholder.json"
    click AzurePipelines "https://github.com/jorgesoap/aveva_trn/blob/main/azure-pipelines.yml"

    %% Styles
    classDef exercise fill:#b3e5fc,stroke:#01579b,stroke-width:2px;
    classDef config fill:#ffcc80,stroke:#e65100,stroke-width:2px;
    classDef test fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef database fill:#ffe082,stroke:#ff9800,stroke-width:2px;
    classDef external fill:#d1c4e9,stroke:#673ab7,stroke-width:2px;
```
