No description
Find a file
Grovy311 37a70b6b36 Add the rough power balance module for early design phases
In LPH 2/3 there are no circuits yet, but the office needs a power
balance by DIN 276 cost group, as in the Excel template "Leistungsbilanz -
KG400": each trade enters consumers by piece or by area (W/m²) with GLF
and cos phi; the balance sums AV and SV per cost group, adds a reserve and
derives the maximum current.

The module is separate from the circuit structure: own tables
(migration 0010), own folder src/estimate-balance and an import-free
shared calculation used by API and UI. Writes go through project commands
(estimate-balance.insert/.update/.delete with complete documents), so
revision checks and Undo/Redo apply; it is not part of project snapshots
or transfer yet. A comparison endpoint sums the device rows of all circuit
lists by cost group (longest prefix) against the estimate.

The UI adds a sidebar entry, a list of Stände (template KG 400, empty or
copy) and a spreadsheet-like editor with autosave, AMEV picker for the
GLF, totals, reserve, maximum current, comparison table and print layout.
The tests reproduce the template example exactly (143.24 kW, 148.48 kVA,
157.56 kW / 163.33 kVA with 10 % reserve, 235.75 A). See
docs/estimate-balance.md and issue #7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 17:39:28 +02:00
docs Add the rough power balance module for early design phases 2026-09-26 17:39:28 +02:00
dynamo Add Revit Dynamo diagnostic scripts 2026-08-23 23:13:35 +02:00
scripts Add the rough power balance module for early design phases 2026-09-26 17:39:28 +02:00
src Add the rough power balance module for early design phases 2026-09-26 17:39:28 +02:00
tests Add the rough power balance module for early design phases 2026-09-26 17:39:28 +02:00
.dockerignore Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
.gitignore Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
AGENTS.md Add the rough power balance module for early design phases 2026-09-26 17:39:28 +02:00
compose.dev.yaml Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
compose.yaml Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
Dockerfile Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
drizzle.config.ts first commit 2026-04-30 18:22:10 +02:00
next-env.d.ts Update generated Next.js types 2026-07-22 23:08:32 +02:00
next.config.mjs Add local uris to nextjs config 2026-08-06 18:58:56 +02:00
package-lock.json Upgrade project to Node 24 2026-08-23 18:05:50 +02:00
package.json Run the Docker stack on built output instead of dev servers 2026-08-23 18:25:06 +02:00
README.md Harden the container runtime and shut down cleanly 2026-09-16 11:04:34 +02:00
tsconfig.json Add configurable structured logging 2026-08-06 19:45:39 +02:00
tsconfig.next.json Add configurable structured logging 2026-08-06 19:45:39 +02:00
tsconfig.scripts.json Add configurable structured logging 2026-08-06 19:45:39 +02:00

Leistungsbilanz

Leistungsbilanz ist eine Webanwendung für die elektrische Ausführungsplanung. Im Mittelpunkt steht ein tabellenähnlicher Stromkreislisten-Editor, der Stromkreise, Gerätezeilen und wiederverwendbare Projektgeräte fachlich getrennt behandelt.

Das Projekt befindet sich in aktiver Entwicklung. Der lokale Entwicklungsbetrieb mit SQLite und Docker Compose ist unterstützt. Ein Produktionsdeployment, Mehrbenutzerbetrieb und der Revit-/IFCGUID-Datenaustausch sind noch nicht implementiert.

Unterstützter Arbeitsablauf

  • Projekte, Verteilungen, Etagen und Räume verwalten
  • pro Verteilung geschützte Stromkreisgruppen für Beleuchtung, 1-phasige und 3-phasige Stromkreise verwalten
  • Hauptschalter, Überspannungsableiter, Gruppenschutz und zusätzliche Verteilergeräte in der Stromkreisliste abbilden
  • Schutzgeräte je Stromkreis und optional je Gruppe konfigurieren
  • leere, einzeilige und mehrzeilige Stromkreise abbilden
  • Stromkreise und Gerätezeilen per Drag-and-drop umstrukturieren
  • Projektgeräte einfügen, verknüpfen und kontrolliert synchronisieren
  • komplette Stromkreisblöcke filtern und sortieren
  • BMKs stabil halten und nur auf ausdrücklichen Befehl neu nummerieren
  • Änderungen projektweit und auch nach einem Reload rückgängig machen und wiederholen
  • benannte Sicherungspunkte anlegen, wiederherstellen und Revisionen einsehen
  • automatische Sicherungspunkte mit begrenzter Aufbewahrung nutzen

Technik

  • Next.js 16, React 19 und TypeScript für das Frontend
  • Express 5 und Zod für die API
  • SQLite, better-sqlite3 und Drizzle ORM für die Persistenz
  • eigener Spreadsheet-Grid statt eines Bootstrap-Tabellenframeworks
  • Node.js-Test-Runner für Domain-, Grid- und SQLite-Integrationstests

Schnellstart mit Docker

Voraussetzungen:

  • Git
  • Docker Desktop mit Docker Compose
git clone <repository-url>
Set-Location leistungsbilanz-ts
docker compose up --build --detach

Danach:

Die Express-API ist nicht mehr auf dem Host veröffentlicht. Sie hat keine Authentifizierung und ist nur innerhalb des Compose-Netzes erreichbar; der Zugriff läuft über den Rewrite im Web-Dienst.

Der API-Container führt ausstehende Migrationen und die Schemaprüfung beim Start automatisch aus. Die SQLite-Datei liegt auf dem Host unter data/leistungsbilanz.db und bleibt beim Stoppen erhalten.

Das Laufzeit-Image läuft als Benutzer node (UID 1000), nicht als root. Ein data/-Verzeichnis, das ein früherer root-Container angelegt hat, braucht deshalb einmalig sudo chown -R 1000:1000 data auf dem Host.

docker compose ps
docker compose logs --follow
docker compose down

compose.yaml startet den Produktionsstand: gebautes dist/ und next start, ohne Quellcode-Mounts und ohne Datei-Watcher, mit Speichergrenzen und ohne root-Rechte im Container. Details stehen in Deployment und Betrieb.

Für die Entwicklung mit Hot Reload gibt es einen eigenen Stack mit Quellcode-Mounts und Watchern:

docker compose -f compose.dev.yaml up --build --detach
docker compose -f compose.dev.yaml logs --follow
docker compose -f compose.dev.yaml down

Die Watcher darin laufen im Polling-Modus, weil Bind-Mounts unter Windows und macOS keine inotify-Events durchreichen. Das kostet dauerhaft CPU, auch wenn niemand die Anwendung benutzt — deshalb gehört dieser Stack nicht auf einen Server.

Direkte lokale Entwicklung

Voraussetzungen:

  • Node.js 24
  • npm
npm ci
npm run db:migrate
npm run db:verify:circuit-schema
npm run dev:api

In einem zweiten Terminal:

npm run dev:web

Frontend und API laufen anschließend auf denselben Ports wie im Docker-Setup.

Qualitätssicherung

npm test
npm run build:api
npm run build:web
npm run typecheck:scripts
npx tsc --noEmit -p tsconfig.next.json

Wichtige Datenbankbefehle:

npm run db:backup
npm run db:migrate
npm run db:verify:circuit-schema
npm run db:generate

db:backup verwendet die SQLite-Online-Backup-API und prüft das Ergebnis auf Integrität und Fremdschlüsselverletzungen. Migration 0000 ist die Release-Baseline für eine leere Datenbank; nachfolgende nummerierte Migrationen entwickeln diese Baseline additiv weiter. Datenbanken aus Entwicklungsständen vor der Baseline werden nicht unterstützt.

Dokumentation

Für LLM-gestützte Änderungen enthält AGENTS.md die verbindlichen Domänenregeln, unterstützten Einstiegspunkte und Architekturgrenzen.