Docker Infrastructure:
- docker-compose.yml with Traefik 3, PostgreSQL 16, PgBouncer, Redis 7, step-ca
- docker-compose.observability.yml with Prometheus, Grafana, Loki, Tempo, Promtail
- Traefik dynamic config (TLS, security headers, CORS, compression)
- PostgreSQL init script (uuid-ossp, pgcrypto, pg_trgm extensions)
- Grafana auto-provisioned datasources (Prometheus, Loki, Tempo)
NestJS Core-Service:
- Auth module: Login (email/password), TOTP 2FA, JWT RS256, token refresh/revocation
- Users module: CRUD, bcrypt cost 12, pagination, role-based access
- Tenants module: CRUD, member management, slug validation
- Prisma schemas: core (Users, AuthProviders, Tenants, Modules, AuditLog)
tenant (Contacts, Activities - CRM reference for Sprint 2)
- TenantPrismaService: Dynamic per-tenant DB connections with caching
- RedisService: Token blocklist, refresh token families, generic cache
- Global JwtAuthGuard with @Public() decorator, RolesGuard, GlobalExceptionFilter
- Health endpoint with DB + Redis status checks
- Swagger API documentation (dev only)
- Multi-stage Dockerfile (dev + production)
React Frontend:
- Vite 6 + React 18 + TypeScript strict
- AuthContext with silent refresh (access token in memory, NOT localStorage)
- Login page with TOTP 2FA support
- App shell with sidebar navigation
- Admin pages: Users + Tenants management tables
- API client with automatic token refresh interceptor
- Multi-stage Dockerfile (dev + nginx production)
CI/CD Pipelines:
- ci.yml: Lint, type-check, test, build on all branches
- deploy.yml: Docker build, push to Forgejo registry, SSH deploy
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9.2 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, TLS, Rate Limiting)
- PostgreSQL 16-alpine (mit Performance-Tuning fuer 8GB RAM)
- PgBouncer (Connection Pooling, Transaction Mode)
- Redis 7-alpine (Cache, Sessions, Token-Revocation)
- step-ca (Interne Certificate Authority fuer mTLS)
- 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-Konfigurationconfig/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/Secure/SameSite=Strict Cookie
- 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
-
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)
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
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
- Docker + Docker Compose auf insight-dev-01 installieren
- .env-Datei auf Server anlegen (echte Passwoerter)
- JWT RS256 Schluessel generieren (fuer Token-Signierung)
- Erste Prisma-Migration ausfuehren
- Platform-Admin User anlegen (Seed)
- Erster End-to-End Test (Login -> Dashboard)
Offene Fragen / Abhaengigkeiten
- DNS-Eintrag
insight-dev.xinion.lanmuss auf 172.20.10.59 zeigen