Switch from hostname+HTTPS (insight-dev.xinion.lan) to IP+HTTP (172.20.10.59) for alpha/dev deployment without DNS. Key changes: - Cookie secure/sameSite flags environment-conditional (fixes HTTP auth) - docker-compose.yml: remove HTTPS, update host rules, reduce PG memory - Traefik: disable TLS, update CORS/CSP for HTTP - Add Prisma init migration (7 tables) and admin seed script - Generate package-lock.json for npm ci in Docker builds - Update all documentation for IP-based access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
12 KiB
INSIGHT MVP - Aenderungsprotokoll
Stand: 2026-03-08
Aktueller Sprint: Sprint 1 (Alpha)
Aenderungen in dieser Session
1. Projektinitialisierung & Infrastruktur-Definition
Was wurde gemacht:
-
SSH Keys erstellt
- Deploy-Key (
.keys/deploy_ed25519) fuer Server-Zugriff - CI/CD-Key (
.keys/cicd_ed25519) fuer Forgejo Actions Pipeline
- Deploy-Key (
-
Infrastruktur-Definition erstellt (
docs/INFRASTRUCTURE.md)- ProxmoxVE VM-Spezifikation: Ubuntu 24.04 LTS, 4 vCPU, 8 GB RAM, 60 GB SSD
- Docker-Netzwerk-Architektur mit 3 isolierten Netzwerken
- Komplette Service-Landschaft definiert
- Schritt-fuer-Schritt VM-Setup Anleitung
-
Zugangsdaten-Dokument erstellt (
docs/ACCESS.md)- Server-IP: 172.20.10.59 (insight-dev-01)
- Git-Server: 172.20.10.11 (GAIA-GIT)
- Alle SSH-Keys, Ports, Befehle dokumentiert
-
Projektstruktur aufgesetzt (packages/core-service, packages/frontend, config, .forgejo)
-
Basis-Konfigurationsdateien (.gitignore, .env.example, README.md)
2. Forgejo Git-Server Konfiguration
Was wurde auf dem Git-Server (172.20.10.11) gemacht:
- Docker Engine 29.3 installiert (fuer Forgejo Actions Runner)
- Forgejo Actions aktiviert (
[actions] ENABLED = truein app.ini) - Container Registry aktiviert (
[packages] ENABLED = truein app.ini) - Forgejo Runner v6.3.1 installiert und registriert
- Runner-Name:
insight-runner - Labels:
ubuntu-latest(docker://node:20) - Laeuft als Systemd-Service (
forgejo-runner.service)
- Runner-Name:
- Repository Secrets angelegt:
SSH_DEPLOY_KEY- CI/CD Private KeyDEPLOY_HOST- 172.20.10.59DEPLOY_USER- deployREGISTRY_USER- gitadminREGISTRY_PASSWORD- Forgejo Access Token
- Branch Protection eingerichtet:
main: Kein direkter Push, 1 Approval erforderlichdevelop: Kein direkter Push, 1 Approval erforderlich
- Forgejo Setup-Anleitung erstellt (
docs/FORGEJO_SETUP.md)
3. Server-Setup (insight-dev-01)
Was wurde auf dem Entwicklungsserver (172.20.10.59) gemacht:
- SSH Public Keys hinterlegt in
/home/deploy/.ssh/authorized_keys- Deploy-Key (
insight-deploy@xinion.lan) - fuer manuellen Zugriff - CI/CD-Key (
insight-cicd@xinion.lan) - fuer Forgejo Actions Pipeline
- Deploy-Key (
- SSH-Zugang getestet - Key-basierter Login als
deployfunktioniert
4. Docker Compose & Service-Konfiguration
Erstellte Dateien:
-
docker-compose.yml- Alle Basis-Services:- Traefik 3 (API Gateway, Reverse Proxy, Rate Limiting)
- PostgreSQL 16-alpine (Performance-Tuning: 1GB shared_buffers, 4GB cache)
- PgBouncer (Connection Pooling, Transaction Mode)
- Redis 7-alpine (Cache, Sessions, Token-Revocation)
- step-ca (Interne Certificate Authority fuer mTLS - geplant)
- Core-Service (NestJS) mit Traefik-Labels
- Frontend (React) mit Traefik-Labels
- 3 isolierte Docker-Netzwerke (insight-web, insight-db, insight-cache)
- Health-Checks fuer alle Services
-
docker-compose.observability.yml- Monitoring-Stack:- Prometheus (Metrics-Sammlung, 30 Tage Retention)
- Grafana (Dashboards, automatisch provisionierte Datenquellen)
- Loki (Log-Aggregation)
- Promtail (Docker Log-Collector)
- Tempo (Distributed Tracing, OTLP gRPC)
- cAdvisor (Container-Metriken)
- PostgreSQL Exporter (DB-Metriken)
-
Konfigurationsdateien:
config/traefik/dynamic/tls.yml- TLS deaktiviert (Alpha/Dev)config/traefik/dynamic/middlewares.yml- Security-Headers, CORS, Compressionconfig/prometheus/prometheus.yml- Scrape-Konfigurationconfig/loki/loki.yml- Log-Storage-Konfigurationconfig/promtail/promtail.yml- Docker-Log-Collectorconfig/tempo/tempo.yml- Tracing-Backendconfig/grafana/provisioning/datasources/datasources.yml- Auto-Provisioningconfig/postgres/init/01-init-extensions.sql- DB-Extensions (uuid-ossp, pgcrypto, pg_trgm)
5. NestJS Core-Service Implementierung
Projekt-Setup:
package.jsonmit allen Dependencies (NestJS 10, Prisma 6, Passport, JWT, bcrypt, TOTP)tsconfig.jsonmit strict: true, noImplicitAny, strictNullChecksDockerfile(Multi-Stage: base, deps, development, build, production)nest-cli.jsonKonfiguration
Implementierte Module:
-
Auth-Modul (
src/core/auth/)AuthService: Login (E-Mail/Passwort), Token-Refresh, Logout, Token-RevocationAuthController: POST /login, /refresh, /logoutJwtStrategy: RS256 Passport-StrategyTotpService: TOTP 2FA (Google Authenticator kompatibel)LoginDto: Validierung mit class-validator- Account-Lockout nach 5 Fehlversuchen (15 Min Sperre)
- Refresh-Token als HttpOnly Cookie (secure/sameSite umgebungsabhaengig)
- Token-Rotation mit Redis-basierter Familien-Erkennung
-
Users-Modul (
src/core/users/)UsersService: CRUD, Bcrypt Cost 12, Passwort-HashingUsersController: GET /me, GET /users, POST /users, PATCH /users/:id- DTOs: CreateUserDto, UpdateUserDto
- Paginierung mit Meta-Informationen
-
Tenants-Modul (
src/core/tenants/)TenantsService: CRUD, Member-ManagementTenantsController: CRUD + POST /:id/members, DELETE /:id/members/:userId- DTOs: CreateTenantDto, UpdateTenantDto, AddMemberDto
- Slug-Validierung (URL-freundlich)
-
Infrastruktur-Module:
PrismaService: PostgreSQL-Verbindung (platform_core)TenantPrismaService: Dynamische Tenant-DB-Verbindungen mit CachingRedisService: Token-Blocklist, Refresh-Token-Familien, generischer CacheHealthController: GET /health (DB + Redis Status)
-
Common (Guards, Decorators, Filter):
@Public()Decorator fuer oeffentliche Routen@Roles()Decorator fuer rollenbasierte Zugriffskontrolle@CurrentUser()Decorator fuer User-Extraktion aus JWTJwtAuthGuard(global) mit Token-Revocation-CheckRolesGuardfuer Rollen-PruefungGlobalExceptionFilterfuer strukturierte Fehlerantworten
-
Config:
validateConfig()mit class-validator fuer Umgebungsvariablen
6. Prisma-Schemas & Migration
-
core.schema.prisma(platform_core Datenbank):User- Plattform-Benutzer (mit Login-Tracking, 2FA)AuthProvider- Multi-Provider Auth (LOCAL, MS_SSO, M2M)Tenant- Mandanten mit JSON-SettingsTenantMembership- User-Tenant-Zuordnung (M:N)Module- Verfuegbare Plattform-ModuleTenantModule- Module pro TenantAuditLog- Plattform-weites Audit-Log
-
tenant.schema.prisma(tenant_{slug} Datenbanken):Contact- CRM-Kontakte (Person/Organisation)Activity- CRM-Aktivitaeten (Notiz, Anruf, E-Mail, Meeting, Task)- Referenz-Schema fuer Sprint 2 (CRM-Modul)
-
Erste Migration erstellt (
prisma/migrations/20260308000000_init/)- 7 Tabellen, alle Indizes und Foreign Keys
migration_lock.tomlfuer Prisma
-
Seed-Script erstellt (
prisma/seed.ts)- Erstellt Platform-Admin:
admin@xinion.de/ChangeMe123! - Bcrypt Cost 12, Rolle: PLATFORM_ADMIN
- Erstellt Platform-Admin:
7. React Frontend-Shell
Projekt-Setup:
package.jsonmit React 18, Vite 6, React Router 6, TanStack Query 5, Axiostsconfig.jsonmit strict TypeScriptvite.config.tsmit API-Proxy und Path-AliasesDockerfile(Multi-Stage: development mit Vite, production mit Nginx)nginx.conf(SPA-Routing, Security-Headers, Caching)
Implementierte Komponenten:
-
Auth-System (
src/auth/)AuthContext+useAuth()Hook: Login, Logout, Silent RefreshLoginPage: E-Mail/Passwort + optionaler TOTP 2FA-Code- Access-Token NUR im Memory (kein localStorage!)
- Automatischer Silent Refresh via HttpOnly Cookie
-
API-Client (
src/api/client.ts)- Axios-Instanz mit automatischem Token-Handling
- Request-Interceptor fuer Authorization-Header
- Response-Interceptor fuer automatisches Token-Refresh bei 401
-
App-Shell (
src/shell/)App: React Router mit PrivateRoute-GuardAppLayout: Sidebar-Navigation + OutletDashboardPage: Willkommens-Seite
-
Admin-Bereich (
src/admin/)AdminUsersPage: Benutzer-Tabelle mit PaginierungAdminTenantsPage: Mandanten-Tabelle mit Member-Count
-
Styling:
- CSS Custom Properties (Farben, Layout, Schatten, Radien)
- CSS Modules fuer komponentenspezifische Styles
- Responsive Sidebar-Layout
8. CI/CD Pipelines
-
.forgejo/workflows/ci.yml- Continuous Integration:- Trigger: Push auf alle Branches + Pull Requests
- Core-Service: npm ci, Prisma Generate, Lint, Type-Check, Test, Build
- Frontend: npm ci, Lint, Type-Check, Build
-
.forgejo/workflows/deploy.yml- Deployment:- Trigger: Push auf main/develop
- Build Docker-Images (Core + Frontend)
- Push in Forgejo Container Registry
- SSH-Deploy auf insight-dev-01
- Health-Check Verifizierung
9. IP-basierte Deployment-Anpassung (HTTP statt HTTPS)
Grund: Kein DNS-Eintrag vorhanden, Zugriff nur ueber IP 172.20.10.59.
Geaenderte Dateien:
-
auth.controller.ts- Cookie secure/sameSite umgebungsabhaengigsecure: true->secure: process.env.NODE_ENV === 'production'sameSite: 'strict'->isProduction ? 'strict' : 'lax'- Betrifft
setRefreshTokenCookie()undlogout()
-
docker-compose.yml- HTTP + IP Umstellung- HTTPS-Redirect entfernt
- TLS-Entrypoint deaktiviert, Port 443 entfernt
- Alle Host-Rules:
insight-dev.xinion.lan->172.20.10.59 - Alle Entrypoints:
websecure->web - URL-Defaults auf
http://172.20.10.59 - PostgreSQL Memory reduziert (1GB/4GB/256MB fuer 8GB RAM VM)
- JWT-Keys Volume-Mount hinzugefuegt:
./keys:/app/keys:ro
-
config/traefik/dynamic/tls.yml- TLS-Konfiguration deaktiviert -
config/traefik/dynamic/middlewares.yml- HSTS-Headers entfernt
- CSP:
wss://insight-dev.xinion.lan->ws://172.20.10.59 - CORS:
https://insight-dev.xinion.lan->http://172.20.10.59
-
main.ts- CORS-Fallback aufhttp://172.20.10.59 -
env.validation.ts- APP_URL Default aufhttp://172.20.10.59 -
.env.example- Alle URLs aufhttp://172.20.10.59 -
package-lock.json- Generiert fuer core-service und frontend (npm ci braucht diese) -
Dokumentation aktualisiert:
docs/INFRASTRUCTURE.md- HTTP statt HTTPS, IP statt DNSdocs/ACCESS.md- Ports, URLs, Default-ZugangsdatenREADME.md- Setup-Anleitung, URLs, Seed-Befehle
Naechste Schritte
- SSH Deploy Keys auf insight-dev-01 Server hinterlegen
docker-compose.ymlerstellen (alle Basis-Services)docker-compose.observability.ymlerstellen- NestJS Core-Service implementieren (Auth, Users, Tenants)
- Prisma-Schemas erstellen (core + tenant)
- React Frontend-Shell implementieren
- CI/CD Pipelines (.forgejo/workflows/) definieren
- Codebase auf HTTP + IP (172.20.10.59) umstellen
- Seed-Script erstellen (admin@xinion.de)
- Prisma-Migration erstellen (init)
- package-lock.json generieren
- Dokumentation aktualisieren
- Commit & Push auf develop
- LVM-Festplatte auf Server erweitern (60GB -> voll nutzbar)
- Docker + Docker Compose auf insight-dev-01 installieren
- Repo klonen, .env + JWT-Keys auf Server erstellen
- Services starten, Migration + Seed ausfuehren
- Erster End-to-End Test (Login -> Dashboard)
Offene Fragen / Abhaengigkeiten
- DNS-Eintrag
insight-dev.xinion.lanwird spaeter eingerichtet (dann HTTPS aktivieren) - LVM auf Server muss erweitert werden (60GB Disk, nur ~56GB sichtbar)