How azure-samples/digital-twins-explorer works
Project Type & Purpose
• The project is a full-stack application designed to help developers interact with Azure Digital Twins.
• It consists of a React-based client application (front end) and serverless back-end components implemented as Azure Functions (backend) that facilitate proxying requests, handling live telemetry via SignalR, and receiving notifications via Event Grid.
Analysis of the File Structure
• The top-level contains documentation, licensing, deployment scripts (e.g. Dockerfile, ARM templates under the “deployment” directory), and the “functions” folder for Azure Functions.
• The “client” folder holds the entire frontend code: configuration files, ESLint configuration, public assets (HTML and localization files) and a detailed “src” directory with multiple components (GraphViewerComponent, ModelViewerComponent, TwinViewerComponent, etc.), services (API, SignalR, Import/Export, Event), and utilities.
• The presence of extensive component subdirectories in “client/src/components” strongly indicates a modular, component-based UI built with React and using patterns like pub/sub messaging (via an EventService) to handle inter-component communication.
• The “functions” folder contains C#-based Azure Functions that play roles as Proxy, SignalR handlers, and EventGrid receivers, which are essential for communication with Azure Digital Twins in both local and cloud deployments.
• The “deployment” folder includes ARM templates which denote the infrastructure-as-code aspects needed for cloud deployment.
Elements
a. Main Components:
• Azure Functions (Backend Services): Identify key functions such as:
▪ Proxy function – for request forwarding to the Azure Digital Twins service.
▪ SignalR function – for live telemetry and client notifications.
▪ EventGrid function – for handling events from Azure Digital Twins.
• External Azure Services:
▪ Azure Digital Twins – the core external service holding the twin data.
▪ Azure SignalR – used to enable real-time client updates in the cloud.
▪ Azure Event Grid – for receiving and broadcasting event notifications.
• Deployment/Containerization: Include Docker (for containerized deployment) and ARM templates (for resource provisioning in Azure).
b. Relationships & Interactions:
▪ The React client issuing API calls (and using pub/sub events internally) to the Azure Functions proxy.
▪ Azure Functions interacting with the Azure Digital Twins service to retrieve and update twin data.
▪ Real-time communication flows from the SignalR function back to the client.
▪ Event flows from Azure Digital Twins sent via Event Grid to the functions and pushed to the client.
c. Architectural Patterns & Design Principles:
• Separation of concerns: UI (client) is decoupled from business logic/network calls in the backend (Azure Functions).
• Use of serverless architectures for backend processing and real-time communications.
• Use of plugin extensibility for import/export features, as well as a pub/sub event system for inter-component messaging within the client.
• Use of proxying (both in local development via setupProxy.js and in cloud deployments via Function proxies).
d. Technologies, Frameworks, and Libraries:
• Frontend: React, Golden Layout (for dynamic panel layouts), ESLint (code quality), and additional libraries such as Office Fabric UI for command bars.
• Backend: C# in Azure Functions, .NET Core, and integration with Azure services (Digital Twins, SignalR, Event Grid).
• Build/Deployment: Docker for containerization, ARM templates for infrastructure provisioning, and Node.js for the client’s development environment.