- TypeScript 99%
- JavaScript 0.6%
- Shell 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github | ||
| scripts | ||
| src | ||
| swisstopo-s3-artifacts/test | ||
| tests | ||
| .gitignore | ||
| .inspector-ignore | ||
| .nvmrc | ||
| .prettierignore | ||
| .prettierrc | ||
| .releaserc.json | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| eslint.config.js | ||
| jest.integration.config.js | ||
| jest.unit.config.js | ||
| package.json | ||
| production-readiness-open-issues.md | ||
| README.md | ||
| translations-review.md | ||
| tsconfig.json | ||
| yarn.lock | ||
eMobility Backend
OCPI backend of ich-tanke-strom (ITS 2.0), the Swiss national access point (NAP) for charging infrastructure data run by the Swiss Federal Office of Energy (BFE). AWS Lambda functions written in TypeScript behind an API Gateway HTTP API, with DynamoDB, S3 and SQS.
- CPO-facing OCPI API (
/ocpi/{version}/…, OCPI 2.2.1 and 2.3.0): charge point operators register viacredentialsand pushlocations(incl. EVSEs and connectors) andtariffs. Every push is stored as raw data and handed to the data lakehouse (emobility-data-pipelines). EVSE status is also written straight to DynamoDB. - Public read-only OCPI API (
/ocpi/locations,/ocpi/tariffs,/ocpi/status, no authentication): serves the aggregated data to data consumers as OCPI 2.3.0. - Monitoring API (
/monitoring/cpos, Cognito login, BFE staff only): per-CPO onboarding figures for BFE's E-Mobility Monitoring page (emobility-monitoring-web). - GeoJSON emitter: publishes the map data for swisstopo.
Infrastructure (Lambdas, API Gateway, DynamoDB tables, CloudFront/WAF) is defined in the
prometheon-emobility-<env> Terraform repositories.
Deployed versions
| Environment | Version | Since (UTC) |
|---|---|---|
| dev | 1.5.0 | 2026-11-25 13:25 |
| test | 1.5.0 | 2026-11-25 13:27 |
| prod | 1.5.0 | 2026-11-25 13:59 |
Updated automatically by deployed-versions.yml
after every deploy, from deploy.auto.tfvars in prometheon-emobility-<env>. A version
there is rolled out by that repository's tofu apply, usually within a few minutes.
Architecture
CPO ──PUT/PATCH/DELETE /ocpi/{version}/…──▶ Lambda ──▶ S3 raw data ──▶ SQS ──▶ raw-data-loader ──▶ lakehouse landing zone
└──▶ DynamoDB ocpi-evse-current-status (live EVSE status)
lakehouse (Glue, a few times a day) ──▶ DynamoDB ocpi-locations / ocpi-tariffs (finished OCPI 2.3.0 objects)
└──▶ Gold JSON export (S3) ──▶ geojson-emitter (+ live status) ──▶ swisstopo GeoJSON
data consumer ──GET /ocpi/locations|tariffs|status──▶ CloudFront ──▶ Lambda ──▶ DynamoDB
Endpoints
CPO-facing (/ocpi/{version}/…, OCPI token via the Lambda authorizer):
| Module | Methods |
|---|---|
versions |
GET /ocpi/versions, GET /ocpi/{version} (no token) |
credentials |
POST, GET, PUT, DELETE |
locations |
PUT, PATCH for location, EVSE and connector |
tariffs |
PUT, DELETE |
Public (no authentication, no version segment):
| Route | Data |
|---|---|
GET /ocpi/locations?offset=&limit=&date_from= |
Published locations with EVSEs and connectors; limit 1–1000 |
GET /ocpi/locations/{country_code}/{party_id}/{location_id} |
One location, else 404 / 2003 |
GET /ocpi/tariffs?offset=&limit=&date_from= |
Valid (not deleted, not expired) tariffs; limit 1–1000 |
GET /ocpi/tariffs/{country_code}/{party_id}/{tariff_id} |
One tariff, else 404 / 2003 |
GET /ocpi/status?date_from=&limit= |
Live statuses received since date_from, oldest first; limit 1–5000 (default 5000), not paginated |
GET /ocpi/status/{country_code}/{party_id}/{location_id}/evses/{evse_uid} |
{status, last_updated} of one EVSE |
Lists use OCPI pagination: offset/limit, Link: <…>; rel="next", X-Total-Count,
X-Limit. date_from filters on last_updated. The location and tariff objects are
written by the Glue job; this repository only reads them. Their DynamoDB layout (GSI1 for
offset paging, GSI2 for date_from) is documented in emobility-data-pipelines
(docs/schemas.md). The consumer documentation is BFE's "Anleitung zum Datenbezug
«Ich tanke Strom»".
Monitoring (CORS from the API Gateway):
Protected by an API Gateway JWT authorizer for the Cognito pool prometheon-prod-userpool
(production eIAM, app clients emobility-monitoring-<env>). The handler additionally requires the
group in MONITORING_REQUIRED_GROUP (bfe-all, BFE staff) in the access token's cognito:groups
or an e-mail address from MONITORING_ALLOWED_EMAILS (comma-separated, the platform developers,
who sign in with AGOV but are not BFE staff) in its email claim, and answers 403 otherwise.
Without MONITORING_REQUIRED_GROUP it checks neither.
GET /monitoring/cpos returns, as OCPI data, every registered CPO (CPO roles in
ocpi-credentials, without tokens or URLs) merged with the per-CPO figures the Glue job
writes into ocpi-cpo-monitoring after each run: locations (total and published), EVSEs,
tariffs, status updates (24 h and per day over 7 days), last data, pending quarantine. A
party with figures but no credentials is listed with registered: false. The handler
derives each CPO's status at request time, in this order: REGISTERED (no data),
INACTIVE (latest data older than 48 h), FIRST_DATA (registered less than 14 days
ago), MASTER_DATA_ONLY (no status update in 24 h), else ACTIVE. The response also
holds the totals (summary), the previous run's totals (previous) and status_counts.
The table layout is documented in emobility-data-pipelines (docs/schemas.md).
Project structure
src/
├── functions/ # Lambda handlers (thin: validate → common → response)
│ ├── api/ocpi/ # CPO-facing OCPI API + authorizer
│ ├── api/public/ # public read-only API (locations, tariffs, status)
│ ├── api/monitoring/ # GET /monitoring/cpos for the E-Mobility Monitoring page
│ ├── geojson-emitter/ # swisstopo GeoJSON publication
│ └── raw-data-loader/ # SQS → lakehouse landing zone
└── common/ # shipped as Lambda layer, imported as /opt/nodejs/*
├── api/ # OCPI response/error types
├── aws/ # generic AWS clients and CRUD (DynamoDB, S3, SQS, …)
├── modules/<module>/ # module-specific OCPI types, DB access, transformations
└── utils/ # cross-module OCPI logic (guards, parsing, responses)
tests/
├── unit/ # mirrors src/, dependencies mocked
├── integration/ # against local AWS services (Ministack, needs Docker)
└── shared/ # fixtures and test data
Conventions (layering, test scope) are described in CLAUDE.md.
Development
Requires Node.js 22 or newer (.nvmrc) and Yarn.
yarn install
yarn build # TypeScript compile to dist/
yarn lint # ESLint
yarn test:unit # unit tests
yarn test:integration # integration tests; starts Ministack via Testcontainers, Docker must run
yarn prettier --write <path>
yarn package builds the deployment artifacts: dist/emobility-backend.zip (Lambda
functions), dist/common-layer.zip and dist/node-modules-layer.zip (Lambda layers).
Lambda configuration comes from environment variables set by Terraform, e.g. BASE_URL,
RAW_DATA_BUCKET_NAME, INGESTION_QUEUE_URL, DATA_LAKE_HOUSE_LANDING_ZONE_BUCKET_NAME,
CROSS_ACCOUNT_ROLE_LANDING_ZONE_ARN. DynamoDB table names are constants in
src/common/aws/constants.ts.
Releases and deployment
Versions are created automatically by semantic-release
from the commit messages on main:
- PRs are squash-merged, so the PR title becomes the commit message and must be a
Conventional Commit (checked by
pr-title.yml). feat:→ minor;fix:,perf:,refactor:,revert:,chore(deps):→ patch;feat!:or aBREAKING CHANGE:footer → major;docs:,ci:, otherchore:,test:,style:,build:→ no release.release.ymltags the version (novprefix, e.g.1.2.0), creates a GitHub release with notes, commits the same notes toCHANGELOG.md(chore(release): … [skip ci]) and deploys it to dev, then test, automatically. Prod stays manual.
| Workflow | Trigger | Purpose |
|---|---|---|
| Build & Test | PRs and pushes to main |
Build, lint, unit tests |
| PR Title | PRs | Conventional Commit title |
| Release | push to main |
semantic-release + CHANGELOG.md, then Publish & Deploy to dev, then test |
| Publish & Deploy Tag | manual | Promote a tag to an environment (prod; or redeploy dev/test) |
| Publish Tag / Deploy Tag | manual, or called by the above | Upload the artifacts to the environment's S3 artifact store / set backend_app_version in prometheon-emobility-<env> |
| Deploy Dev | manual | Deploy the current branch HEAD (by SHA) to dev for testing |
Deploying means committing the new backend_app_version to the environment's Terraform
repository, whose pipeline then applies it.