Electrical Load List — calculation web app

A ready-to-run electrical calculation suite: a Rust engine behind a REST API and a Vue 3 + Vite interface built for engineers who have to defend the numbers. Three calculations are implemented so far — 01 load list, 02 cable sizing and 03 cathodic protection — all reproducing their source workbooks. Sign-in protected, with an optional self-hosted Cap CAPTCHA.

The engine reproduces the workbook calculation to the last decimal — continuous, intermittent, stand-by and spare loads per operating scenario, motor efficiency and power factor interpolated from the motor reference curve, maximum normal running load, peak load and total demand with spare contingency.

Calculation 01 — load list

For every consumer:

load factor   = absorbed power / nameplate rating
efficiency    = interpolated from the motor curve at that load factor
power factor  = interpolated from the motor curve at that load factor
consumed kW   = absorbed power / efficiency
consumed kVAr = consumed kW × tan(acos(cos φ))
FLC           = rated kW / (√3 × kV × efficiency × cos φ)

Per scenario (normal/holding, offloading, maintenance, essential, emergency, black start):

maximum normal running = continuous + max(30 % × intermittent, largest intermittent)
peak load              = continuous + 30 % × intermittent + max(10 % × stand-by, largest stand-by)
total demand           = peak load × (1 + 20 % contingency)

The 30 / 10 / 20 % factors are configurable in the UI and stored with the project.

Verification. The integration tests (backend/tests/workbook.rs) assert the totals of the source workbook within 1 × 10⁻⁶ kW:

ScenarioTotal demand (kW)Source
Normal/Holding31 140.75Summary table 1.0
Maintenance7 833.77Summary table 3.0
Essential11 614.19Summary table 4.0
Emergency1 929.79Recommendation 8.5

Calculation 02 — cable sizing

Reproduces 0000-EF-D-41335_0 Power Cable Sizing Calc.XLSX (AS/NZS 3008):

IFLC   = kW × 1000 / (k × V × cos φ)      k = 1.732 (3-phase) or 1 (1-phase)
IZ     = It × Cg × Ca                     It from the cable reference table
runs   = IFLC / IZ
VD     = k × IFLC × (L/1000) / runs × (R cos φ + X sin φ)
%VD    = VD / V × 100
%VDlast = sum of %VD along the chain (panel → … → last fixture)
Lmax   = (allowable % × V / 100) / (k × IFLC / runs × 1/1000 × (R cos φ + X sin φ))

Four checks per circuit: ampacity (IZ ≥ IFLC), protection coordination (IZ > IPR), voltage drop (%VDlast ≤ allowable) and maximum length (Lmax ≥ chain length). The 10 circuits of the source workbook reproduce to 1 × 10⁻⁶, including the cumulative drop per series chain (1.293 % for the lighting chain, 2.107 % for the socket chain).

Calculation 03 — cathodic protection

Reproduces Basic Cal SACP for Internal Tank - PT Pertamina MOR VII Sulawesi.xls for internal tank and vessel SACP, and extends the same method to piping, pipelines, external surfaces and ICCP (DNV RP B401 2005 / GS EP COR 201):

Cdu  = (Cd + (T − 25) × 0.001) × CBf        DNV temperature correction
Cap  = ε − 27 × (T − 20)                     Ah/kg at operating temperature
TWA  = shell area + head / bottom area       from the structure geometry
SA   = TWA + round(TWA × discrepancy, 2)     the workbook rounds the allowance to 2 dp
Ip   = SA × Cdu
M    = Ip × Y × 8760 / Cap / U × S           kg of anode material
N    = ceil(M / anode unit weight)

Four checks per item: anode capacity is positive, design current density is positive, the selected anode count covers the requirement, and the selected anodes reach the design life. ICCP replaces the mass balance with a groundbed count and a rectifier rating:

I_rect = Ip
V_rect = (Ip × (R_groundbed + R_cable) + back EMF) × (1 + margin)

External vertical and rectangular surfaces take an independent wall height; a blank height falls back to the length. Internal surfaces use the liquid height.

Verification. backend/tests/cathodic_workbook.rs asserts 23 sheets of the source workbook to 1 × 10⁻⁶: wetted and exposed area, current density, anode capacity, protection current, anode mass and anode count. Four sheets are documented one-offs and are not forced into the model — a dimensionally inconsistent partial-shell area, a current density that mixes the coating factor into the temperature term, and a 50 % wetted-area allowance.

Quick start

docker run --rm -p 8080:8080 -v loadlist-data:/app/data \
  -e AUTH_PASSWORD=choose-a-strong-password \
  ghcr.io/ashcoft/electricacl:latest

Open http://localhost:8080 and sign in as admin.

If AUTH_PASSWORD is not set, the service generates one on first boot and prints it once:

docker logs <container> | grep "initial login"
# initial login: admin / 1f9c0b…      change it with AUTH_PASSWORD or: electricacl --reset-password

Docker Compose

cp .env.example .env      # set AUTH_PASSWORD
docker compose up -d

CAPTCHA with Cap

Cap is a self-hosted, privacy-first CAPTCHA: the browser solves a proof-of-work challenge instead of clicking traffic lights. The image bundles the widget, and the app proxies the Cap API through /cap/<site-key>/ so the CAPTCHA server never has to be publicly reachable and no CORS rules are involved.

cp .env.example .env                 # set AUTH_PASSWORD and CAP_ADMIN_KEY
docker compose --profile captcha up -d          # app + Cap + Valkey
ADMIN_KEY=$CAP_ADMIN_KEY ./tools/cap_create_site.sh electricacl
# {"siteKey":"2186d3ff68","secretKey":"sk-..."}

Put the two values in .env and restart the app:

CAP_UPSTREAM=http://cap:3000
CAP_SITE_KEY=2186d3ff68
CAP_SECRET=sk-...
docker compose up -d

The sign-in form now requires a solved challenge. The dashboard of the Cap server is on http://localhost:3000 (password = CAP_ADMIN_KEY).

If Cap is hosted somewhere public, skip the proxy and point the browser at it directly with CAP_API_ENDPOINT=https://cap.example.com/<site-key>/ plus CAP_SECRET; that takes precedence over CAP_UPSTREAM/CAP_SITE_KEY. Set COOKIE_SECURE=true whenever the app is served over HTTPS.

Configuration

VariableDefaultPurpose
PORT8080HTTP port
DATA_DIR./dataLoad list state and credentials
STATIC_DIR./staticFrontend bundle served by the same process
AUTH_USERNAMEadminSign-in user name
AUTH_PASSWORDgeneratedSign-in password (≥ 8 characters)
COOKIE_SECUREfalseMark the session cookie Secure (enable behind HTTPS)
CAP_API_ENDPOINT–Public Cap site endpoint, e.g. https://cap.example.com/<site>/
CAP_UPSTREAM–Internal Cap URL for same-origin mode, e.g. http://cap:3000
CAP_SITE_KEY–Cap site key used by the /cap/<site>/ proxy
CAP_SECRET–Cap site secret used for siteverify
RUST_LOGinfoLog filter

The binary also answers --healthcheck (used by the image HEALTHCHECK) and --reset-password (regenerates the password and prints it).

Authentication

  • Passwords are stored as Argon2 hashes in DATA_DIR/credentials.json (mode 0600); the password itself is never written to disk.
  • Sessions are stateless: an HMAC-SHA256 signed cookie (HttpOnly, SameSite=Lax, 12 h expiry) signed with a random key stored beside the credentials.
  • Five failed attempts from one address lock that address out for five minutes.
  • Every API route except /api/health and /api/auth/* requires a valid session; the SPA shell is public so the login page can load.
  • Cap is verified server-side against <endpoint>/siteverify with the site secret before a session is issued. The widget is bundled (works offline) and can talk to Cap through the app's own /cap/<site-key>/ proxy, so only one host has to be exposed.
  • Without CAPTCHA configuration the challenge is skipped and the login page says so.

Interface

  • Dashboard — KPI cards, load build-up per category, peak composition, generator sizing options, connected load by voltage level and area, scenario comparison, data-quality findings.
  • Load list — 656 consumers, filter by area/voltage/duty/class/status, search, sort, page, inline edit of absorbed and rated power, CSV and PDF export.
  • Consumer detail — live recalculation while you type, with the formula and the substituted numbers on screen, plus warnings for a missing duty, a missing scenario or a motor rating that is not in the reference table.
  • Motor data — the 80-row efficiency / power factor reference table.
  • Cable sizing — 10 circuits with ampacity, protection, voltage-drop and length checks, series chains for cumulative drop, an editable AS/NZS 3008 reference table and CSV export.
  • Method & basis — the calculation chain and the workbook verification.
  • PDF report — one click from the top bar or the dashboard: A4 report with the key figures, load build-up, generator sizing, scenario comparison and the full load list (repeating header, page numbers). Generated in the service, so it also works from the API without a browser.

Local development

Requirements: Rust stable, Node 22, Python 3 with openpyxl only if you want to re-extract the seed.

# terminal 1 - API (generates and prints a password on first run)
cd backend
cargo run                      # http://localhost:8080

# terminal 2 - Vite with /api proxy
cd frontend
npm install
npm run dev                    # http://localhost:5173

Build the bundle and let the Rust service serve it:

make build
cd backend && STATIC_DIR=../frontend/dist cargo run

Tests and checks:

make test     # cargo test + vue-tsc + vitest
make lint     # cargo clippy -D warnings
make fmt

The frontend unit tests cover the browser-side calculation mirror (frontend/src/lib/calc.test.ts).

API

Public routes:

MethodPathDescription
GET/api/healthLiveness probe
GET/api/auth/configSession state and CAPTCHA settings
POST/api/auth/login{username, password, cap_token}
POST/api/auth/logoutClears the session cookie

Session required (cookie eacl_session):

MethodPathDescription
GET/api/stateItems + derived values + all summaries
GET/api/summariesScenario summaries only
GET/api/motor-tableMotor reference curve
GET/api/settingsContingency and diversity factors
PUT/api/settingsUpdate the factors
POST/api/load-itemsCreate a consumer
PUT/api/load-items/{id}Update a consumer
DELETE/api/load-items/{id}Delete a consumer
POST/api/load-items/{id}/duplicateDuplicate a consumer
PUT/api/load-itemsReplace the whole list ({"items": [...]})
POST/api/load-items/resetRestore the embedded source data
GET/api/export/csvCSV export including all derived values
GET/api/export/pdf?scenario=normalPDF report: summary, scenarios, load list
GET/api/cable/stateCable circuits + reference table + stats
POST/api/cable/circuitsCreate a cable circuit
PUT/api/cable/circuits/{id}Update a cable circuit
DELETE/api/cable/circuits/{id}Delete a cable circuit
POST/api/cable/circuits/{id}/duplicateDuplicate a cable circuit
PUT/api/cable/referenceReplace the cable reference table
POST/api/cable/circuits/resetRestore the source cable schedule
GET/api/export/cable.csvCable schedule with every computed value

Example:

curl -s -c /tmp/jar -X POST localhost:8080/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"username":"admin","password":"choose-a-strong-password"}'
curl -s -b /tmp/jar localhost:8080/api/state | jq '.summaries[0].demand'
# { "kw": 31140.746828032006, "kvar": 15939.711911076838, "kva": 34983.128719189815 }

Project layout

backend/            Rust service (axum)
  src/calc/         load list engine + motor curve
  src/cable.rs      cable sizing engine (AS/NZS 3008)
  src/cable_store.rs cable schedule persistence
  src/cathodic.rs   cathodic protection engine (DNV RP B401 / GS EP COR)
  src/cathodic_store.rs cathodic schedule persistence
  src/report.rs     PDF report
  src/auth.rs       sessions, Argon2 credentials, Cap verification
  src/models.rs     data model (items, duties, scenarios, settings)
  src/store.rs      persistence (JSON on disk, seed embedded in the binary)
  src/api.rs        REST handlers and the auth middleware
  data/seed.json    consumers + motor table extracted from the workbook
  data/cable_seed.json cable schedule + AS/NZS 3008 reference values
  data/cathodic_seed.json cathodic items extracted from the SACP workbook
  tests/            workbook verification + HTTP auth tests
frontend/           Vue 3 + TypeScript + Vite
tools/              extract_seed.py / extract_cable_seed.py / extract_cathodic_seed.py - regenerate the seeds
docker-compose.yml  app, plus Cap + Valkey under the `captcha` profile
Dockerfile          multi-stage build, unprivileged runtime
.releaserc.json     semantic-release configuration
.github/workflows   CI, Release (semantic-release + versioned image), Container image (snapshots)

Data flow: the seed is extracted once from LOAD LIST.xlsx (make seed) and embedded in the binary, so the image is self-contained. At runtime the service copies it into DATA_DIR on first start and persists every edit there.

Releases

Versions, the changelog and the container tags are produced automatically by semantic-release from Conventional Commits. Nothing is versioned by hand.

Commit messageRelease
fix: correct stand-by diversitypatch
feat: add cable sizing screenminor
feat!: change the calculation APImajor
docs:, chore:, test:, refactor:none

On every push to main the Release workflow analyses the commits, writes CHANGELOG.md, tags vX.Y.Z, opens the GitHub release and publishes the matching image:

docker pull ghcr.io/ashcoft/electricacl:1.2.3   # exact release
docker pull ghcr.io/ashcoft/electricacl:1.2     # latest patch of 1.2
docker pull ghcr.io/ashcoft/electricacl:latest  # latest release

Every push also publishes a moving sha-<short> tag through the Container image workflow, so a specific commit can be deployed before it is released.

The @semantic-release/git plugin commits CHANGELOG.md back to main. If main is protected, allow the GitHub Actions bot to bypass the rule (or drop that plugin from .releaserc.json).

Roadmap

The interface already reserves space for the next calculations in the suite:

  1. Load list — done.
  2. Cable sizing — done (ampacity, derating, voltage drop, protection coordination, max length).
  3. Cathodic protection — done for SACP (tank, vessel, piping, pipeline, internal/external) and ICCP current demand and rectifier sizing.
  4. Transformer and generator sizing.

License

MIT.