How energinet-datahub/greenforce-frontend works
Purpose and deployable entry points
GreenForce is an Nx monorepo for the DataHub electricity-market frontend, its dedicated backend-for-frontend (BFF), shared domain libraries, and the Watt design system. The main runtime entry points are:
• Angular SPA: apps/dh/app-dh/src/main.ts, rooted by apps/dh/app-dh/src/app/datahub-app.component.ts.
• ASP.NET Core BFF: apps/dh/api-dh/source/DataHub.WebApi/Program.cs, built from apps/dh/api-dh/DataHub.WebApi.sln.
• Browser E2E application: apps/dh/e2e-dh/playwright.config.ts.
Frontend composition and routing
app-dh is intentionally thin; feature libraries hold business UI. Core shell routing and navigation compose domain shells and lazy feature routes:
• libs/dh/core/shell/src/dh-core-shell.routes.ts
• libs/dh/metering-point/feature-process-overview/src/routes.ts
• libs/dh/wholesale/shell/src/dh-wholesale-shell.routes.ts
Primary business surfaces include metering points/processes, market participants/administration, charges, wholesale calculations, reports, eSett exchange, conversations, notifications, and operational tooling.
Client data boundary
Frontend features use GraphQL documents and a shared Apollo-based access layer rather than calling subsystem APIs directly. The shared layer configures HTTP, SSE subscriptions, retries, scalar conversion, errors, and cache:
• libs/dh/shared/data-access-graphql/src/dh-apollo.ts
• libs/dh/shared/data-access-graphql/src/dh-http-link.ts
• libs/dh/shared/data-access-graphql/src/dh-sse-link.ts
Flow: Angular route/component → generated/typed GraphQL operation → Apollo links with authorization/error handling → DataHub BFF GraphQL endpoint. Subscriptions support live changes such as calculation and metering-point process updates.
Identity, authorization, and runtime configuration
The SPA loads API, app, and B2C settings at startup and uses MSAL/B2C plus an actor-scoped authorization model. It applies access tokens, selected-actor context, permissions, market-role guards, inactivity behavior, feature flags, and release toggles.
• libs/dh/shared/environments/src/dh-environment.ts
• libs/dh/auth/feature-msal/src/dh-b2c-config.ts
• libs/dh/shared/feature-authorization/src/dh-authorization.interceptor.ts
• libs/dh/shared/feature-authorization/src/permission.guard.ts
Environment JSON assets permit local, Docker, or overridden remote endpoints under libs/dh/shared/assets/src/assets/configuration.
BFF API and module boundary
The .NET 10 BFF presents GraphQL as its primary aggregation surface, with REST controllers retained for selected proxy/download/token endpoints. Registration and module discovery are centralized here:
• apps/dh/api-dh/source/DataHub.WebApi/Registration/GraphQLRegistrationExtensions.cs
• apps/dh/api-dh/source/DataHub.WebApi/Registration/ModuleExtensions.cs
• apps/dh/api-dh/source/DataHub.WebApi/Controllers/TokenController.cs
GraphQL modules map client-facing nodes, queries, mutations, types, authorization, and batching onto downstream data. Representative high-value modules:
• Electricity market/metering and measurements: apps/dh/api-dh/source/DataHub.WebApi/Modules/ElectricityMarket/ElectricityMarketModule.cs
• Market participants, actors, users, permissions: apps/dh/api-dh/source/DataHub.WebApi/Modules/MarketParticipant/MarketParticipantModule.cs
• Charges and charge links: apps/dh/api-dh/source/DataHub.WebApi/Modules/Charges/ChargesModule.cs
• Orchestrated market processes and calculations: apps/dh/api-dh/source/DataHub.WebApi/Modules/Processes/ProcessesModule.cs
• Reports and settlements: apps/dh/api-dh/source/DataHub.WebApi/Modules/SettlementReports/SettlementReportsModule.cs
Downstream integration and cross-cutting behavior
The BFF is an adapter/aggregator over DataHub subsystems through typed HTTP clients, including Electricity Market, Market Participant, eSett Exchange, imbalance prices, actor conversations, notifications, and legacy DH2 bridging:
• apps/dh/api-dh/source/DataHub.WebApi/Clients/ElectricityMarket/V1/ElectricityMarketClient.cs
• apps/dh/api-dh/source/DataHub.WebApi/Clients/MarketParticipant/V1/MarketParticipantClient.cs
• apps/dh/api-dh/source/DataHub.WebApi/Clients/ESettExchange/V1/ESettExchangeClient.cs
It forwards authenticated calls via apps/dh/api-dh/source/DataHub.WebApi/AuthorizedHttpClientFactory.cs, exposes health checks, and applies revision/audit logging through apps/dh/api-dh/source/DataHub.WebApi/Modules/RevisionLog/Middleware/RevisionLogMiddleware.cs. Docker assets exist for both SPA (Nginx) and BFF: apps/dh/app-dh/Dockerfile, apps/dh/api-dh/Dockerfile.
Shared platform
Watt is the reusable Angular design-system package consumed by features (libs/watt/package). Frontend observability integrates Application Insights and Microsoft Clarity:
• libs/dh/shared/util-application-insights/src/dh-application-insights.initializer.ts
• libs/dh/shared/feature-microsoft-clarity/src/dh-microsoft-clarity.initializer.ts
Main entry points: dh-core-shell.routes.ts Core shell routes · Program.cs BFF host · dh-apollo.ts Apollo data access · datahub-app.component.ts DataHub app root
Components 19
Angular SPA
Thin app shell composed from lazy domain libraries.
- SPA bootstrap
apps/dh/app-dh/src/main.ts - DataHub app root
apps/dh/app-dh/src/app/datahub-app.component.ts - Core shell routes · Composes navigation, domain shells, and lazy features.
libs/dh/core/shell/src/dh-core-shell.routes.ts - Process overview
libs/dh/metering-point/feature-process-overview/src/routes.ts - Wholesale shell
libs/dh/wholesale/shell/src/dh-wholesale-shell.routes.ts - Browser E2E
apps/dh/e2e-dh/playwright.config.ts
Client platform
Shared identity, data access, and observability services.
- Runtime environment · Loads API, app, and B2C settings.
libs/dh/shared/environments/src/dh-environment.ts - B2C and authorization · Applies tokens, actor context, permissions, and route guards.
libs/dh/shared/feature-authorization/src/dh-authorization.interceptor.ts - Apollo data access · Configures HTTP, SSE, retries, scalars, errors, and cache.
libs/dh/shared/data-access-graphql/src/dh-apollo.ts - SSE subscriptions · Delivers live calculation and process changes.
libs/dh/shared/data-access-graphql/src/dh-sse-link.ts - Watt design system
libs/watt/package - Client observability · Application Insights and Microsoft Clarity integration.
libs/dh/shared/util-application-insights/src/dh-application-insights.initializer.ts
DataHub BFF
ASP.NET Core aggregation boundary for DataHub subsystems.
- BFF host · GraphQL-first API with selected REST endpoints.
apps/dh/api-dh/source/DataHub.WebApi/Program.cs - GraphQL registration · Registers schema, modules, and GraphQL services.
apps/dh/api-dh/source/DataHub.WebApi/Registration/GraphQLRegistrationExtensions.cs - Domain GraphQL modules · Electricity market, participants, charges, processes, and reports.
apps/dh/api-dh/source/DataHub.WebApi/Modules/ElectricityMarket/ElectricityMarketModule.cs - Token REST endpoint · Retained proxy, download, and token API surface.
apps/dh/api-dh/source/DataHub.WebApi/Controllers/TokenController.cs - Authorized HTTP clients · Forwards authenticated typed requests to DataHub services.
apps/dh/api-dh/source/DataHub.WebApi/AuthorizedHttpClientFactory.cs - Revision audit log
apps/dh/api-dh/source/DataHub.WebApi/Modules/RevisionLog/Middleware/RevisionLogMiddleware.cs
Other components
- DataHub subsystems · Electricity Market, Market Participant, eSett, conversations, notifications, and DH2.
apps/dh/api-dh/source/DataHub.WebApi/Clients/ElectricityMarket/V1/ElectricityMarketClient.cs
Connections 23
- SPA bootstrap → DataHub app root: boots
- DataHub app root → Core shell routes: loads
- Core shell routes → Process overview: lazy route
- Core shell routes → Wholesale shell: domain route
- Core shell routes → Watt design system: renders with
- SPA bootstrap → Runtime environment: loads settings
- Runtime environment → B2C and authorization: configures
- Core shell routes → B2C and authorization: guards routes
- B2C and authorization → Apollo data access: adds auth context
- Process overview → Apollo data access: GraphQL operations
- Wholesale shell → Apollo data access: GraphQL operations
- Apollo data access → SSE subscriptions: subscriptions
- Apollo data access → BFF host: GraphQL HTTP
- SSE subscriptions → BFF host: live updates
- BFF host → GraphQL registration: configures
- GraphQL registration → Domain GraphQL modules: registers
- BFF host → Token REST endpoint: serves
- Domain GraphQL modules → Authorized HTTP clients: queries downstream
- Token REST endpoint → Authorized HTTP clients: proxies
- Authorized HTTP clients → DataHub subsystems: typed HTTP
- BFF host → Revision audit log: audits revisions
- DataHub app root → Client observability: initializes
- Browser E2E → DataHub app root: exercises