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%
  • JavaScript 0.6%
  • Dockerfile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-24 13:00:08 +02:00
.github chore(deps): consolidate dependabot GitHub Actions bumps 2026-08-20 14:01:37 +02:00
.storybook fix: Repair two stories 2025-09-18 11:01:19 +02:00
.vscode feat: Migrate to pnpm 2026-01-27 12:49:49 +01:00
codemods
docs feat: Fallback to 2025 for offers 2026-08-19 17:24:56 +02:00
jenkins
public feat: Update maps 2026-01-06 14:49:55 +01:00
scripts feat: Add energy prices debugging CLI 2026-08-19 17:04:43 +02:00
sparql-notebooks
src Merge pull request #673 from visualize-admin/fix/667-municipality-comparison 2026-08-20 13:59:34 +02:00
typings chore: Remove mdx 2026-01-13 12:42:00 +01:00
.cfignore
.dockerignore feat: Ignore dockerfile when copying allow for cache reuse 2026-01-27 14:55:54 +01:00
.env.development chore: udpate current period to 2027 2026-08-13 15:27:16 +02:00
.eslintrc.json fix: Ignore generated file 2026-01-13 09:36:52 +01:00
.gitignore chore: Ignore vercel env file 2026-01-26 10:14:33 +01:00
.nvmrc chore: Upgrade Node.js from 22 to 24 2026-08-19 14:17:30 +02: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 refactor: apply biome rule lint/suspicious/noGlobalIsFinite 2025-10-01 10:13:02 +02:00
book.sparqlbook
CHANGELOG.md chore: v2.49.0 2026-08-24 13:00:08 +02:00
CLAUDE.md refactor: Slim down CLAUDE.md, extract into files 2026-03-17 08:38:36 +01:00
codegen.yml refactor: Rename for better searchability 2025-08-25 15:45:49 +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.49.0 2026-08-24 13:00:08 +02:00
flake.lock
flake.nix feat: Migrate to pnpm 2026-01-27 12:49:49 +01:00
k6-load-test.ts
knip.config.ts chore: Add typescript language server for claude 2026-05-26 09:17:47 +02:00
LICENSE
lingui.config.js
next-env.d.ts feat: Make power stability horizontal stacked bars responsive 2026-01-13 09:36:51 +01:00
next.config.ts feat: Update swiss-federal-ci 2026-04-16 14:56:31 +02:00
package.json chore: v2.49.0 2026-08-24 13:00:08 +02:00
playwright.config.ts fix: suppress consent banner in Playwright tests via storageState 2026-04-16 21:26:12 +02:00
pnpm-lock.yaml chore: v2.49.0 2026-08-24 13:00:08 +02:00
pnpm-workspace.yaml chore: Lint 2026-01-27 17:21:51 +01:00
README.md feat: Add energy prices debugging CLI 2026-08-19 17:04:43 +02: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 feat: Migrate to pnpm 2026-01-27 12:49:49 +01:00
storybook-index.json feat: Update storybook ndex 2025-09-18 11:00:51 +02:00
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 feat: Use argosScreenshot helper + argos playwright reporter 2025-11-13 10:57:30 +01:00
tsconfig.test.json refactor: Rename ScatterPlot into DotPlot for clarity 2025-07-09 12:06:23 +02:00
vite.config.ts
vitest.config.ts chore: Converge integration tests to use BASE_URL env variable 2026-04-07 16:49:02 +02:00
vitest.shims.d.ts refactor: Rename ScatterPlot into DotPlot for clarity 2025-07-09 12:06:23 +02:00

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 (v22 recommended) and pnpm as package manager.

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

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