The development stack was running permanently on a server: polling file watchers, a healthcheck that rendered a full page every five seconds and no memory limit grew next dev to 10 GB and pushed the host into swap. - add compose.prod.yaml running compiled output in separate api/web services - make the Dockerfile multi-stage with dev and prod targets, prune devDependencies and run the runtime image as node instead of root - bake API_INTERNAL_URL at build time; next start ignores it at runtime because rewrite destinations are resolved into routes-manifest.json - drop CHOKIDAR_USEPOLLING and WATCHPACK_POLLING - probe /health instead of /, which redirects to /projects and made every healthcheck render the project list - give every service a memory limit and forbid swap in production - rename the development compose project to leistungsbilanz-dev so its down command cannot target the production stack - bind development ports to localhost - close the http server and the SQLite handle on SIGTERM/SIGINT - match probe user agents in the navigation log filter; Node's fetch sends one, so the previous check never matched - exit docker-start.sh when either supervised process dies - remove drizzle.config.js, a compiled copy drizzle-kit never reads, and the pre-Next index.html/styles.css leftovers Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
140 lines
4.5 KiB
Markdown
Executable file
140 lines
4.5 KiB
Markdown
Executable file
# 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. Unterstützt sind der lokale
|
|
Entwicklungsbetrieb (`compose.yaml`) und ein Einzelbenutzer-Deployment im
|
|
vertrauenswürdigen Netz (`compose.prod.yaml`). Authentifizierung,
|
|
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
|
|
|
|
```powershell
|
|
git clone <repository-url>
|
|
Set-Location leistungsbilanz-ts
|
|
docker compose up --build --detach
|
|
```
|
|
|
|
Danach:
|
|
|
|
- Frontend: <http://localhost:3001>
|
|
- API-Healthcheck: <http://localhost:3000/health>
|
|
|
|
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.
|
|
|
|
```powershell
|
|
docker compose ps
|
|
docker compose logs --follow
|
|
docker compose down
|
|
```
|
|
|
|
`compose.yaml` startet Entwicklungsserver mit Quellcode-Mounts, veröffentlicht
|
|
seine Ports nur auf `127.0.0.1` und ist **kein Produktionsdeployment**. Es
|
|
gehört nicht in den Dauerbetrieb: `next dev` und `tsx watch` erzeugen auch ohne
|
|
Benutzer dauerhaft Last und wachsen im Speicher.
|
|
|
|
## Deployment
|
|
|
|
```bash
|
|
docker compose -f compose.prod.yaml up --build --detach
|
|
```
|
|
|
|
Startet die kompilierte API und `next start` in getrennten Containern, mit
|
|
Speicherlimits und ohne Dateibeobachter. Das Frontend hört auf Port 3090, die
|
|
API ist nur intern erreichbar. Vorbereitung eines bestehenden Datenvolumes und
|
|
weitere Details stehen in [Deployment und Betrieb](docs/deployment.md).
|
|
|
|
## Direkte lokale Entwicklung
|
|
|
|
Voraussetzungen:
|
|
|
|
- Node.js 22
|
|
- npm
|
|
|
|
```powershell
|
|
npm ci
|
|
npm run db:migrate
|
|
npm run db:verify:circuit-schema
|
|
npm run dev:api
|
|
```
|
|
|
|
In einem zweiten Terminal:
|
|
|
|
```powershell
|
|
npm run dev:web
|
|
```
|
|
|
|
Frontend und API laufen anschließend auf denselben Ports wie im Docker-Setup.
|
|
|
|
## Qualitätssicherung
|
|
|
|
```powershell
|
|
npm test
|
|
npm run build:api
|
|
npm run build:web
|
|
npm run typecheck:scripts
|
|
npx tsc --noEmit -p tsconfig.next.json
|
|
```
|
|
|
|
Wichtige Datenbankbefehle:
|
|
|
|
```powershell
|
|
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
|
|
|
|
- [Dokumentationsübersicht](docs/README.md)
|
|
- [Aktuelle Architektur](docs/current-architecture.md)
|
|
- [Editor-Interaktionen](docs/circuit-list-editor-interactions.md)
|
|
- [API des Stromkreislisten-Editors](docs/circuit-list-editor-api.md)
|
|
- [Entwicklungs- und Contributor-Workflow](docs/development-workflow.md)
|
|
- [Bekannte Einschränkungen](docs/circuit-list-editor-known-limitations.md)
|
|
- [Roadmap](docs/spec/07-implementation-phases-todo.md)
|
|
|
|
Für LLM-gestützte Änderungen enthält [AGENTS.md](AGENTS.md) die verbindlichen
|
|
Domänenregeln, unterstützten Einstiegspunkte und Architekturgrenzen.
|