No description
- TypeScript 55.5%
- Go 32.1%
- CSS 10.7%
- Go Template 1.1%
- Dockerfile 0.4%
- Other 0.2%
|
All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| backend | ||
| deploy/helm/timetracker | ||
| frontend | ||
| .gitignore | ||
| README.md | ||
Elektropruefung
Tracks electrical devices and their DIN EN 50699 (VDE 0702) test cycles. Multi-tenant, multi-site.
backend/: Go, Gin, GORM (SQLite, MySQL, Postgres), gormigrate, swaggo, OIDC or local login, PDF reports.frontend/: React + Vite PWA. Works on phone and desktop, dark and light mode, offline entry with upload on reconnect.
Backend
cd backend
cp .env.example .env # adjust
go run . create-tenant --name "Firma"
go run . create-user --username admin --password '<8+ chars>' --admin --tenant 1 --role admin
go run . serve # API on :8080, Swagger at /api/v1/swagger/index.html
go test ./...
Commands: serve (default), migrate, create-tenant --name, create-user --username --password [--admin] [--tenant --role].
Regenerate the API docs after changing handler annotations:
cd backend && go run github.com/swaggo/swag/cmd/swag@v1.16.6 init -g api/server.go -o docs --parseDependency --parseInternal
Frontend
cd frontend
corepack enable # pnpm version comes from the packageManager field
pnpm install
pnpm dev # UI only, no API proxy
pnpm build # production build in dist/
The frontend makes no proxy. In production the ingress sends /api to the backend and / to the frontend on one host. Local pnpm dev has no API, so run the backend behind a same-host reverse proxy, or test on a cluster.
Concepts
- Tenant owns sites, devices and tests. A user has a role per tenant:
admin,tester(writes devices and tests),viewer. - Site has a type (office, workshop, construction site, ...). Picking the type fills in the interval.
- Interval resolves as: device override, then site interval. Site intervals come from the tenant override for the type, else the built-in default.
- Result is computed on the server from the measurements. Missing required measurements fail the test.
- Status:
failed(last test failed),expired,due_soon(within 30 days),ok,untested,retired. - Retiring a device (Ausmusterung) takes it out of the due lists and blocks new tests; its test records stay. It can be reactivated.
- Export: the device list downloads as CSV (semicolon, UTF-8 with BOM for Excel) with the same filters as the list.
- Members: admins list members, change roles and remove them. Nobody can change their own role or remove themselves, so a tenant keeps an admin.
- Registration: with
REGISTRATION_ENABLED=true, anyone can create a local account on the login page. Each new account gets its own tenant and is its admin. - Offline: GET responses are cached in IndexedDB. Writes that fail on the network go to an outbox and are sent when online. Tests carry a
clientId, so a resend is idempotent. - Languages: German and English. The UI picks the browser language on first visit; users switch in the top bar. Dictionaries live in
frontend/src/i18n/(en.tsis the source,de.tsmust have the same keys). API errors are translated by their message; PDF reports take?lang=de|en. - Updates of the PWA are never applied silently; the user is asked.
Before production use
- The VDE limits (
backend/vde/vde.go) follow DIN EN 50699 (VDE 0702:2021); tests of type "after repair" use the same limits and are labelled DIN EN 50678 (VDE 0701). Heating power (class I, from 3.5 kW) relaxes R_ISO and leakage limits. Default site intervals are DGUV V3 guide values: verify them against the company risk assessment. - Login and registration have no rate limiting yet. Put the API behind the ingress rate limit or add one.