Compare Swiss electricity prices. Project ownership: Federal Electricity Commission ElCom | Read-only mirror of https://github.com/visualize-admin/electricity-prices-switzerland — visualize.admin.ch. Issues & pull requests at the source.
  • TypeScript 99.8%
  • JavaScript 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-12-02 14:57:46 +01:00
.github ci: skip the E2E tests for outdated commits (ELC-744) 2026-11-12 10:24:50 +01:00
.storybook
.vscode feat: Migrate to pnpm 2026-01-27 12:49:49 +01:00
codemods
docs fix(mocks): accept enum values as strings in recorded GraphQL mocks (ELC-747) 2026-11-30 17:13:43 +01:00
jenkins
public
scripts fix(mocks): accept enum values as strings in recorded GraphQL mocks (ELC-747) 2026-11-30 17:13:43 +01:00
sparql-notebooks
src chore(locales): sync the latest German and Italian translations from Accent 2026-12-02 14:50:51 +01:00
typings chore: Remove mdx 2026-01-13 12:42:00 +01:00
.cfignore
.dockerignore chore: Ignore unneeded files when building the docker image 2026-10-27 11:02:32 +01:00
.env.development feat: Add sunshine current period (fix #675) 2026-08-27 09:43:06 +02:00
.eslintrc.json chore: mark ESLint config as root so lint works in nested worktrees 2026-10-07 13:41:34 +02:00
.gitattributes chore: allow changelog to merge via union 2026-09-02 15:41:59 +02:00
.gitignore chore: ignore local .oc state directory 2026-10-27 11:07:23 +01:00
.nvmrc chore: update to Node.js 26 2026-10-27 11:07:22 +01:00
.oxlintrc.json feat: Migrate to pnpm 2026-01-27 12:49:49 +01:00
.prettierrc
.svgrrc
.trivyignore refactor: Remove trivy ignores 2026-03-17 17:22:41 +01:00
.vercelignore
accent.json
babel.config.js fix: Correct locale extraction 2026-01-29 15:10:31 +01:00
biome.json
book.sparqlbook
CHANGELOG.md chore: v2.58.10 2026-12-02 14:57:46 +01:00
CLAUDE.md refactor: Slim down CLAUDE.md, extract into files 2026-03-17 08:38:36 +01:00
codegen.yml feat: operatorMeanObservations returns operator figures per period 2026-10-08 08:41:08 +02:00
CODEOWNERS
configure-proxy.js
docker-compose.yml feat: Add Redis service to docker-compose 2026-01-22 15:10:07 +01:00
Dockerfile chore: v2.58.9 2026-12-02 10:57:41 +01:00
flake.lock chore: update to Node.js 26 2026-10-27 11:07:22 +01:00
flake.nix chore: update to Node.js 26 2026-10-27 11:07:22 +01:00
k6-load-test.ts
knip.config.ts chore: quiet pre-push hook output, fix knip hints and unused var 2026-10-15 13:42:48 +02:00
lefthook.yml chore: quiet pre-push hook output, fix knip hints and unused var 2026-10-15 13:42:48 +02:00
LICENSE
lingui.config.js
next-env.d.ts
next.config.ts fix: resolve Dependabot alerts via dep bumps and pnpm overrides 2026-10-15 13:14:10 +02:00
package.json chore: v2.58.10 2026-12-02 14:57:46 +01:00
playwright.config.ts ci: retry failed Playwright tests once instead of twice (ELC-717) 2026-11-10 14:00:41 +01:00
pnpm-lock.yaml chore: v2.58.9 2026-12-02 10:57:41 +01:00
pnpm-workspace.yaml chore: Lint 2026-01-27 17:21:51 +01:00
README.md fix: keep Vercel builds on Node.js 24 2026-10-27 11:24:03 +01:00
sentry.edge.config.ts feat: Use Sentry for metrics 2026-01-26 10:14:33 +01:00
sentry.server.config.ts fix: disable Sentry in non-production environments on server 2026-04-08 13:44:07 +00:00
shell.nix chore: update to Node.js 26 2026-10-27 11:07:22 +01:00
storybook-index.json
sunshine.sparqlbook feat: Update sparql book with way to get operator name 2026-05-11 14:24:33 +02:00
tpo.config.json
tsconfig.json
tsconfig.test.json
vite.config.ts
vitest.config.ts test: render the price components card in vitest 2026-10-14 17:14:08 +02:00
vitest.shims.d.ts

ElCom Electricity Price Website

An electricity price comparison website for Switzerland that provides interactive maps, charts, and time-series visualizations of electricity prices from Swiss providers. Built with Next.js 15, TypeScript, and Material-UI, the application exposes a GraphQL API, which uses the Swiss Federal Administration Open Data (LINDAS) to get data on operator, prices, municipalities.

For development patterns and coding guidelines, see Claude.md.

Configuration through Environment Variables

Variable Required Example Value
SPARQL_ENDPOINT yes https://lindas.admin.ch/query
SPARQL_EDITOR yes https://lindas.admin.ch/sparql
GITLAB_WIKI_TOKEN yes xyz
GITLAB_WIKI_URL yes https://gitlab.ldbar.ch/api/v4/projects/9999/wikis
I18N_DOMAINS {"de": "www.elcom.local", "fr": "fr.elcom.local", "it": "it.elcom.local"}
BASIC_AUTH_CREDENTIALS user:password
MATOMO_ID 123
CURRENT_PERIOD 2022
FIRST_PERIOD 2009
PUBLIC_URL no http://localhost:3000
EIAM_CERTIFICATE_PASSWORD yes See in Elcom PWD certificates in 1Password
EIAM_CERTIFICATE_CONTENT yes See in Elcom PWD certificates in 1Password. Result of cat certificate.p12 | base64
GEVER_BINDING_IPSTS https://idp-cert.gate-r.eiam.admin.ch/auth/sts/v14/certificatetransport. Ask Roger Flurry.
GEVER_BINDING_RPSTS https://feds-r.eiam.admin.ch/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256
GEVER_BINDING_SERVICE https://api-bv.egov-abn.uvek.admin.ch/BusinessManagement/GeverService/GeverServiceAdvanced.svc

Development Environment

To start the development environment, you need Node.js (v26 recommended) and pnpm as package manager.

Vercel still builds with Node.js 24 because it does not support 26 yet, so engines.node in package.json stays at 24.x.

The usage of Nix to install system-level packages is recommended.

Setting up the dev environment

Ensure that Node.js and pnpm are available in your environment

Install system-level dependencies

Either use the installers

Or – if using Nix – entering a new Nix shell will install Node.js and pnpm automatically:

nix develop

Run the application setup

Run the setup script:

pnpm setup

This will install npm dependencies and run setup scripts.

Dev server

Once the application's set up, you can start the development server with

pnpm dev

👉 In Visual Studio Code, you also can run the default build task (CMD-SHIFT-B) to start the dev server, and TypeScript checker (you'll need Nix for that to work).

Versioning

New versions of package.json are built on CI into a separate image that will be deployed to the test environment.

pnpm version

This will prompt for a new version. The postversion script will automatically try to push the created version tag to the origin repo.

Localization

The application supports German (de), French (fr), Italian (it), English (en), and AA (test language). Translations are managed using Lingui with Accent for translation management.

Project in Accent.

Workflow

# Extract translatable strings from source code
pnpm locales:extract

# Manage translations via Accent interface
pnpm locales:browse

# Pull translations from Accent service
pnpm locales:sync

# Compile translations (runs automatically during pnpm build)
pnpm locales:compile

Preparing geodata

Run

make geodata

Since Switzerland's municipalities can change each year, the yearly Shapefiles from 2010 on prepared by BFS will be downloaded and transformed into TopoJSON format which can be loaded efficiently client-side.

The detailed transformation steps are described in this project's Makefile.

Http Proxy

On the government infrastructure, an HTTP proxy is used for external requests. This is for example used to fetch the gitlab content. The proxy is configured via the ./configure-proxy.js script that is required in the package.json start command. It uses the HTTP_PROXY environment variable

  • For some of the server requests (SAML requests), we must not use this proxy, and the agent is configured there manually.
  • For external requests that should use the proxy, we can use https.globalAgent.
const https = require('https')
const data = fetch(url, {
  agent: https.globalAgent
})

EIAM certificates

EIAM certificates are used to authenticate against the GEVER API serving the electricity provider documents.

They are stored in 1Password as "Elcom PWD certificates".

EIAM certificate content and password are passed as environment variable. The certificate content is a p12 certificate encoded as base 64.

In dev, you have to edit env.local to add the EIAM_CERTIFICATE_CONTENT and EIAM_CERTIFICATE_PASSWORD variables.

# Get the base64 certificate content that can be put in EIAM_CERTIFICATE_CONTENT
cat ../../../vault/svc.spw-d.elcom.admin.ch.p12 | base64

Git hooks

Optional pre-push checks (lint, knip, types, locales) with lefthook. See Git Hooks.

Load testing

See Load Testing document for more information.

Energy prices CLI

A debugging tool for the energy prices map, usable by humans and AI agents alike. See Energy Prices CLI.

Docker

Both the frontend and the screenshot service can be built as docker images and spin up through docker-compose.

pnpm docker:build # Build the image and tag it as interactivethings/electricity-prices-switzerland
docker compose up

Trivy is used for vulnerability scanning and must pass for the image to be accepted on the Federal Administration infrastructure. A check is done before publishing the docker image on GHCR. It can also be run against a local image.

pnpm docker:trivy # Runs trivy against interactivethings/electricity-prices-switzerland:latest

SPARQL notebook

A notebook containing Elcom specific SPARQL queries is available at ./book.sparqlbook. You need the SPARQL Notebook Extension to open it.

Home map screenshots

It is possible to regenerate the home map screenshots automatically using Playwright.

pnpm design:generate-home-maps