# digitaltwinconsortium/aas-repository architecture

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

- Interactive diagram: https://gitdiagram.com/digitaltwinconsortium/aas-repository
- Repository: https://github.com/digitaltwinconsortium/aas-repository

## Overview

##### Project Type and Purpose
- This is a full-stack ASP.NET Core application implementing the IEC 63278 Asset Administration Shell (AAS) Repository.
- It exposes standardized REST APIs for AAS and OPC UA, a browser-based UI (Razor/Blazor), Swagger documentation, and integrates with multiple external services (WattTime, Azure Data Explorer, Dynamics 365, CESMII SMIP, time-series DB, etc.).

##### File-Structure Analysis
- Top-level: AAS-Repository.sln, Dockerfile, CI workflows (.github), README.
- src/: the main ASP.NET Core project, containing:
- Controllers/ – REST API controllers for AAS, OPC UA, browser UI
- Pages/ & Shared/ & Views/ – Razor pages, layouts, Blazor components for the UI
- Models/ – AAS domain classes (AssetAdministrationShell, Submodel, ConceptDescription, etc.)
- Services/ – Business-logic and integration services (AssetAdministrationShellEnvironmentService, ADXDataService, ProductCarbonFootprintService, SMIPDataService, DynamicsDataService, WattTimeClient, UAClient)
- SimpleServer.cs – embedded OPC UA server host
- Program.cs & Startup.cs – application setup, middleware (BasicAuth, Swagger, routing)
- wwwroot/ – static assets (CSS, fonts)

##### Key Components & Layers
a. Presentation Layer (UI)
– Browser clients load Razor/Blazor pages from the ASP.NET Core host.
– Swagger UI is served at /swagger for API exploration.

b. API Layer
– ASP.NET Core MVC controllers receiving HTTP requests:
· AssetAdministrationShellRegistryApi
· AssetAdministrationShellRepositoryApi
· SubmodelRepositoryApi
· ConceptDescriptionRepositoryApi
· SerializationApi
· UaServerController
· BrowserController
– Basic authentication middleware protects endpoints.

c. Business Logic Layer
– Services orchestrate domain use cases:
· AssetAdministrationShellEnvironmentService (in-memory store of loaded nodesets & AAS environment)
· ProductCarbonFootprintService (calculates PCF using scope 1/2/3 logic)
· ADXDataService, DynamicsDataService, SMIPDataService, WattTimeClient, UAClient (integration adapters)
· NodesetFileNodeManager (manages OPC UA nodeset XML loading)

d. Integration Layer / External Systems
– Azure Data Explorer cluster (time-series operational data)
– Dynamics 365 ERP instance
– WattTime REST API (electricity carbon intensity)
– CESMII SMIP GraphQL API
– Upstream AAS supply-chain servers
– Embedded OPC UA server (SimpleServer) for runtime exposure of loaded AAS models

##### Relationships & Data Flows
- User Browser ↔ (HTTPS) ↔ Razor/Blazor UI ↔ Controllers
- Controllers → Services → (in-memory) AAS environment
- Services ↔ External APIs (ADX, Dynamics, WattTime, SMIP)
- Controllers ↔ Embedded OPC UA server endpoint (via UaServerController)
- Controllers → Swagger middleware → API documentation

##### Architectural Patterns & Design Principles
- Layered Architecture: Presentation → API → Business Logic → Integration → External Services
- Dependency Injection: all services and clients registered in Startup.cs
- Repository pattern (AssetAdministrationShellEnvironmentService acts as an in-memory repository)
- Adapter pattern for external integrations (WattTimeClient, ADXDataService, etc.)
- Use of standard protocols: HTTP/REST, GraphQL, OPC UA

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        Browser["Browser"]:::ui
        AppRazor["App.razor"]:::ui
        Imports["_Imports.razor"]:::ui
        Pages["Pages (Razor/Blazor)"]:::ui
        Shared["Shared (Layout)"]:::ui
        Views["Views (cshtml)"]:::ui
        SwaggerUI["Swagger UI (/swagger)"]:::ui
    end

    %% API Layer
    subgraph "API Layer"
        Program["Program.cs"]:::config
        Startup["Startup.cs"]:::config
        BasicAuth["BasicAuthenticationHandler"]:::config
        RegApi["AssetAdministrationShellRegistryApi"]:::api
        RepoApi["AssetAdministrationShellRepositoryApi"]:::api
        SubmodelApi["SubmodelRepositoryApi"]:::api
        ConceptApi["ConceptDescriptionRepositoryApi"]:::api
        SerializationApi["SerializationApi"]:::api
        UaServerCtrl["UaServerController"]:::api
        BrowserCtrl["BrowserController"]:::api
        DescriptionApi["DescriptionApi"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        EnvService["AssetAdministrationShellEnvironmentService"]:::business
        PCFService["ProductCarbonFootprintService"]:::business
        NodeManager["NodesetFileNodeManager"]:::business
    end

    %% Integration Adapters
    subgraph "Integration Adapters"
        ADX["ADXDataService"]:::integration
        Dynamics["DynamicsDataService"]:::integration
        SMIP["SMIPDataService"]:::integration
        WattTime["WattTimeClient"]:::integration
        UAClient["UAClient"]:::integration
        ServerHost["SimpleServer (Embedded OPC UA)"]:::integration
    end

    %% External Systems
    subgraph "External Systems"
        ADXCloud["Azure Data Explorer"]:::external
        DynamicsCloud["Dynamics 365 ERP"]:::external
        SMIPCloud["CESMII SMIP GraphQL API"]:::external
        WattTimeApi["WattTime REST API"]:::external
        AASCloud["Upstream AAS Supply-chain"]:::external
    end

    %% Connections
    Browser --> AppRazor
    AppRazor --> BrowserCtrl
    Imports --> BrowserCtrl
    Pages --> BrowserCtrl
    Shared --> BrowserCtrl
    Views --> BrowserCtrl
    Browser --> SwaggerUI
    SwaggerUI --> Startup
    Program --> Startup
    Startup --> BasicAuth
    BasicAuth --> RegApi
    BasicAuth --> RepoApi
    BasicAuth --> SubmodelApi
    BasicAuth --> ConceptApi
    BasicAuth --> SerializationApi
    BasicAuth --> UaServerCtrl
    BasicAuth --> BrowserCtrl
    BasicAuth --> DescriptionApi

    RegApi --> EnvService
    RepoApi --> EnvService
    SubmodelApi --> EnvService
    ConceptApi --> EnvService
    SerializationApi --> EnvService
    BrowserCtrl --> EnvService

    EnvService --> PCFService
    PCFService --> ADX
    PCFService --> Dynamics
    PCFService --> SMIP
    PCFService --> WattTime

    UaServerCtrl --> ServerHost
    UaServerCtrl --> NodeManager
    NodeManager --> ServerHost

    ADX --> ADXCloud
    Dynamics --> DynamicsCloud
    SMIP --> SMIPCloud
    WattTime --> WattTimeApi
    UAClient --> AASCloud

    %% Click Events
    click AppRazor "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/App.razor"
    click Imports "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/_Imports.razor"
    click Pages "https://github.com/digitaltwinconsortium/aas-repository/tree/masterV3/src/Pages/"
    click Shared "https://github.com/digitaltwinconsortium/aas-repository/tree/masterV3/src/Shared/"
    click Views "https://github.com/digitaltwinconsortium/aas-repository/tree/masterV3/src/Views/"
    click Program "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Program.cs"
    click Startup "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Startup.cs"
    click RegApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/AssetAdministrationShellRegistryApi.cs"
    click RepoApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/AssetAdministrationShellRepositoryApi.cs"
    click SubmodelApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/SubmodelRepositoryApi.cs"
    click ConceptApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/ConceptDescriptionRepositoryApi.cs"
    click SerializationApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/SerializationApi.cs"
    click UaServerCtrl "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/UaServerController.cs"
    click BrowserCtrl "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/BrowserController.cs"
    click DescriptionApi "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Controllers/DescriptionApi.cs"
    click EnvService "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Services/AssetAdministrationShellEnvironmentService.cs"
    click PCFService "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Services/ProductCarbonFootprintService.cs"
    click ADX "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Services/ADXDataService.cs"
    click Dynamics "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Services/DynamicsDataService.cs"
    click SMIP "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/Services/SMIPDataService.cs"
    click WattTime "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/WattTimeClient.cs"
    click UAClient "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/UAClient.cs"
    click NodeManager "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/NodesetFileNodeManager.cs"
    click ServerHost "https://github.com/digitaltwinconsortium/aas-repository/blob/masterV3/src/SimpleServer.cs"

    %% Styles
    classDef ui fill:#b3e6b3,stroke:#333,stroke-width:1px
    classDef api fill:#b3d9ff,stroke:#333,stroke-width:1px
    classDef config fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef business fill:#ffd9b3,stroke:#333,stroke-width:1px
    classDef integration fill:#e0b3ff,stroke:#333,stroke-width:1px
    classDef external fill:#d9d9d9,stroke:#333,stroke-width:1px
```
