| title | Overview | ||
|---|---|---|---|
| type | overview | ||
| summary | Master summary of the OCPP CP Simulator — what it is, how the pieces fit together, the workspace packages and their boundaries, and where to read next. | ||
| sources |
|
||
| updated | 2026-11-15 |
What it is. A charge-point (CP) simulator for OCPP — primarily 1.6J, also
2.0.1 / 2.1 over WebSocket and 1.2 / 1.5 / 1.6S over SOAP — built for
AI-agent testing, CI automation and CSMS development. One TypeScript core
(the ChargePoint domain under packages/core/src/cp/) is exposed through several
interfaces: a browser console, a desktop app, a headless CLI, a multi-CP
daemon with a Socket.IO control plane and an MCP endpoint, and a Docker image.
┌──────────────── interfaces ─────────────────┐
you / agent → │ Web console │ Desktop app │ CLI │ MCP client │
└──────┬────────────┬─────────┬────────┬──────┘
│ Remote │ sidecar │ --json │ POST /mcp
▼ ▼ │ ▼
┌────────────────────────────────────────────┐
│ Daemon: Socket.IO control plane (rpc/event) │ ← Docker image
│ CP registry · scenarios · logs · state-db │
└───────────────────┬────────────────────────┘
│ OCPP-J (ws/wss) or OCPP-S (SOAP)
▼
CSMS (SteVe, gocpp, yours)
- Interfaces — Web console (Local mode in a tab or Remote mode against a daemon), Desktop app, CLI, Daemon, MCP endpoint, Docker image. Pick one with Choosing an interface.
- Control plane — every Socket.IO client of the daemon (web console in
Remote mode, CLI client modes, external agents) speaks the same
contract:
rpcacks andeventpushes, zod-validated, closed error codes. REST and the Unix socket were removed (migration). - MCP — a separate transport for LLM agents: stateless JSON-RPC over
POST /mcp, exposing the same daemon methods as tools (MCP endpoint); it has no event push. - Scenarios — scripted CP behavior is a node-graph JSON
(Scenario format, JSON Schema in
packages/core/schema/), authored in the editor or loaded from files / built-in templates (including 47 OCPP 1.6 certification test cases). Runs produce a machine-readable verdict with conformance and compatibility axes. - Vehicles — reusable vehicle profiles imported from the external Open EV Directory catalog, saved locally and copied into a connector's, the default or a scenario's EV settings, so simulations never depend on the catalog.
- Observability — one log line shape everywhere;
wire frames can be streamed as a versioned trace
and analyzed with
analyze(OCPP DebugKit); each charge point keeps an operational timeline that correlates injected network faults with the recovery they cause, and a charging-session history that sums up each transaction (duration, energy, stop reason, outcome) whatever its OCPP version. - Operations — state persistence (SQLite in the daemon, sql.js in the browser), access control (bind gate, Basic Auth, CORS, reverse proxies), network simulation (seeded latency / disconnects).
- Protocol coverage — OCPP versions & transports, OCPP 1.6 security profiles; message types are generated from the vendored OCA schemas.
- Verification — unit / Bun tests, a gocpp e2e suite, the steve-verify harness and a Testcontainers example (Testing strategy, CSMS peers).
The repository is a Bun workspace
(#578): packages/*
hold the code that runs in both Bun and the browser, apps/* the two programs
built from it, and the root package.json stays the published
ocpp-cp-simulator package (the CLI bundle plus the web console). Everything
else at the root — index.html, public/, vite.config.ts, src-tauri/,
docs/, e2e/, scripts/, examples/, docker/ — is shared tooling and
keeps its place; Vite's root is the repository root.
Dependency rules between the packages are executable (bun run check:boundaries
in CI). scripts/check-package-boundaries.ts
is the canonical definition: PACKAGE_MAP assigns every file under
packages/ and apps/ to its package, ALLOWED_DEPENDENCIES is the
dependency table below, and --list <package> and --json print the files and
the package-to-package import counts.
bun run check:boundaries also runs
scripts/check-direct-time.ts: the code
under packages/core/src/cp/domain/ and application/ reads time and arms
timers through the charge point's SimClock, and draws random numbers and ids
from its RngStreams (Charger engine).
The script lists every direct Date.now(), argument-less new Date(),
performance.now(), Math.random(), crypto.randomUUID() and global timer
call that is left, against a shrinking exemption list (EXEMPTIONS): it fails
on a use the list does not allow and on an entry that allows more than the file
has. It also runs scripts/check-single-writer.ts:
only packages/core/src/cp/application/engine/ may assign a connector's status,
availability, scheduledAvailability, currentErrorCode, errorInfo or
vendorErrorCode, transaction, transactionId or a transaction's fields (Charger engine).
Last, scripts/check-file-size.ts backs ESLint's max-lines ratchet: non-test files stay under 800 lines, and the files already over (listed in scripts/file-size-allowlist.json) may not grow; the script fails on an entry for a missing file, a file over 800 lines without an entry, or a file larger than its entry, and only warns (slack: …) when an entry is larger than its file or still lists a file that now fits, so a split PR need not touch the allowlist (--update lowers or drops those entries and never raises one).
Package (@ocpp-cp-simulator/<dir>) |
Holds | May depend on |
|---|---|---|
packages/ocpp |
the generated OCPP message types and validators (src/) and the vendored OCA schemas (vendor/ocpp-schemas/) |
nothing |
packages/ocpp-rpc |
the domain-free OCPP-J frame codec and RPC endpoint (src/; protocol stack), portable |
ocpp |
packages/contracts |
the wire contract of the daemon (src/; control plane) |
nothing |
packages/trace |
the log-to-trace adapter (src/; trace format) |
nothing |
packages/k6-runtime |
the k6 runtime files copied verbatim into an export (src/) and the ambient k6 module types (k6-types.d.ts) |
nothing |
packages/vehicle |
the protocol-independent vehicle behavior domain (src/): what a vehicle asks for and when, a pure function of its inputs and the instant |
nothing |
packages/core |
the charge point and the scenario engine (src/cp/, src/scenario/), scenario templates and blueprints (src/utils/), the shared test helpers (src/test/) and the scenario JSON Schema (schema/) |
ocpp, ocpp-rpc, contracts, trace, k6-runtime, vehicle |
packages/client |
how a UI or tool talks to a daemon or to an in-process engine (src/interfaces/, src/remote/, src/configPort.ts, src/RuntimeMode.ts, src/sqlite/SqliteConnectorSettingsRepository.ts) |
core, contracts, ocpp, trace |
apps/cli |
the CLI, the daemon, the MCP endpoint, export-k6 and analyze (src/), and the tests that build the CLI bundle and the Tauri sidecar (src/build/) |
every package except apps/web |
apps/web |
the browser console: components, console pages, hooks and providers (src/data/), store, lib, assets, and the jsdom test setup |
every package except apps/cli |
Packages are private, versionless and have no build step: each package.json
exposes its sources through "exports": { "./*": "./src/*.ts" } (plus explicit
entries for the few JSON files other packages import), so a specifier mirrors
the path under src/ — @ocpp-cp-simulator/core/cp/domain/charge-point/ChargePoint.
Bun, Vite and tsc (moduleResolution: bundler) read the TypeScript directly
through the workspace links. Only packages/ocpp-rpc has a curated entry
point (src/index.ts), and only by convention: its manifest still exports
"./*". Publishable packages with curated exports are the plan of
Reusable OCPP protocol stack
(#978).
Third-party dependencies are still declared once, in the root package.json.
Each package has a composite tsconfig.json that extends
tsconfig.base.json and references the packages it depends on; bun run typecheck is tsc -b.
Rules the check enforces:
- An import (value,
import type,export … from,import(),new URL("./x", import.meta.url), relative,@/or@ocpp-cp-simulator/…) from a package into one that is not in its "may depend on" column fails, type-only imports included: TypeScript project references forbid cycles at the type level too. Test files are checked like any other and belong to the package of the directory they sit in. - Across packages the import must be an
@ocpp-cp-simulator/<package>/…specifier that resolves through the package'sexports, never a relative path into another package. Inside one package imports stay relative (insideapps/webthe@/alias,apps/web/src, also works). - Each
package.jsonis private, named after its directory, and declares exactly theworkspace:*dependencies its imports need — no more, no less. The rootpackage.jsonmust not useworkspace:anywhere, or the published tarball would not install outside the repository. ocpp,contracts,trace,k6-runtime,vehicle,coreandclientmust run in both Bun and the browser, so their non-test files may not importreact*,jotai,zustand,@xyflow/*,@radix-ui/*, Vite-only specifiers (?url,?raw,virtual:),bun:*or Node built-ins, except for the files on the commented allow-list in the script (today the daemon's two SQLite stores,BunSqliteDatabase.tsandNodeSqliteDatabase.tsinpackages/core/src/cp/infrastructure/persistence/). Type-only imports of such packages are erased and not flagged.- A file under
packages/orapps/that matches noPACKAGE_MAPentry fails the check, so a new workspace directory has to be registered on purpose. Known exceptions go in the script'sKNOWN_VIOLATIONS/TEST_ALLOW_LIST, each with a reason; a stale entry also fails. - Inside
packages/core/src/cp/the layers have a direction (#571):domain/imports onlydomain/andshared/;application/importsdomain/,application/andshared/, neverinfrastructure/;infrastructure/may import every layer;shared/imports onlyshared/.domain/andshared/also may not import core code outsidesrc/cpor anything underapps/; other workspace packages stay governed by the table above. Type-only imports count, test files are not checked. The script'sLAYER_EXEMPTIONSlist is empty since #575 movedChargePoint's last imports ofapplication/behind domain interfaces, which meets the goal of the epic #577; the list is kept, so a new violation fails, and so would an entry that no longer matches. - A file under
packages/orapps/, test files included, may not reach itself through static value imports, in one package or across several; there is no allow-list for this rule.import, a side-effect import,export … from(export *included, even of a types-only module) andrequirecount;import type,export type … from,import("x").Tand a dynamicimport()do not (#570). The ESLint rule@typescript-eslint/consistent-type-importsmakes an import used only as a type say so, or it would count here.scripts/ande2e/are not scanned.
The conventions come from
#576. The charge point
lives in cp/, split in four layers; their import direction is the layer
bullet above, not repeated here.
cp/domain/— the charge point's state and invariants (charge point, connector, session, reservation, security, topology, …) and the ports it needs, such as the repository interfaces andLogSinkunderdomain/persistence/, the transport ports underdomain/transport/(ChargePointSocket,RawFrameSink,OcppCallActions) andChargePointDeps, what a charge point is built with.domain/engine/holds the engine and behavior vocabulary (ChargerState,EngineEvent,PersistedEngineState, the behavior rules) and the interfacesChargePointsees its engine and behavior registry through (ChargePointEngine,ChargePointBehaviorRegistry);domain/services/holds the interfaces of its heartbeat, state manager and operational timeline (ChargePointHeartbeat,ChargePointStateManager,ChargePointTimeline) and the state-history types (StateSnapshot,StateTransition,ValidationResult).domain/charge-point/ChargePointTypes.tsholds the option, outcome and policy types andPowerStateErrorofChargePoint;ChargePoint.tsre-exports them, so imports do not change (#877). The rest of the class is split into collaborators beside it (cellular link, client certificate switch, call overrides, authorization flow, meter sampling, device model publisher, configuration wiring, power loss, Reset OnIdle, connection timeouts, plug-in flow, connector wiring, boot lifecycle, outage lifecycle, connector status control, charging profile control, station messaging and notifications, capability gate, idTag source), each taking an explicit host interface;ChargePointCollaborators.tsbuilds them from oneStationContextandChargePointSetup.tsholds the end of the constructor.ChargePoint.tskeeps the public members as thin delegates.cp/application/— the use cases that drive the domain: the charger engine and its behaviors, services (state history, heartbeat, operational timeline), the scenario engine (application/scenario/) and run verification, and the ports they own, such asScenarioRepositoryandScenarioRunRepository. The engine, the behavior registry and the services implement thedomain/engine/anddomain/services/interfaces.cp/infrastructure/— adapters to the outside: WebSocket and SOAP transports, the SQLite stores, schema and migrations (infrastructure/persistence/, since #573), HTTP (fileUpload.ts), the vehicle catalog, andLogRepository(log persistence, ininfrastructure/persistence/).infrastructure/charge-point/createChargePoint.tsis the composition root of a charge point (#575): the CLI, the web console, the benches, the e2e suites and the tests build one through it (onlyChargePoint.deps.test.tscalls the constructor with their own deps), and it passes theChargePointconstructor itsChargePointDeps— the transport factory (createDefaultTransport.ts), the factories of the engine, the behavior registry, the heartbeat, the state manager and the timeline, and thetransactionsport bound todefault.transaction(DEFAULT_SERVICESincreateDefaultServices.ts), aLogRepositoryover the charge point's database (a no-op one without a database), the charge point's repositories (createChargePointRepositories: SQLite over its database, no-ops without one, #878), andUploadFilefor GetDiagnostics.cp/shared/— dependency-free utilities: clock, RNG, timers, logger, event emitter, reconnect policy, redaction.
Outside cp/: scenario/ holds the scenario-format helpers (schema
validation, loading, connection rules, partial matching), utils/ the built-in
scenario templates and blueprints, types/ ambient declarations
(webcrypto-globals.d.ts), and test/ the shared test helpers, behavior
suites, golden-wire rig and regression tests.
Tests go in a __tests__/ folder beside the code they cover (outside cp/,
src/test/ and the two template tests in utils/ are the exceptions). A
*.bun.test.ts file runs under bun test; any other *.test.ts(x) runs
under vitest, which excludes the Bun files.
| If you are… | Start with |
|---|---|
| New to the project | This page, then Choosing an interface |
| Automating a CSMS test | Driving from an AI agent, Control plane |
| Writing a scenario | Scenario format, Scenario templates |
| Deploying | Docker image, Access control |
| Debugging a session | analyze, Log format, Trace format |
| Maintaining this wiki (human or LLM) | Conventions, CLAUDE.md, Index, Log archive |