mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-25 07:36:39 +02:00
Eigenstaendiger NestJS-Service unter packages/crm-service/ mit: - Prisma Schema (app_crm): Contact, Activity, Pipeline, PipelineStage, Deal - JWT RS256 Auth mit shared Public Key und Token-Revocation - Multi-Tenancy: TenantGuard + tenantId-Filter auf allen Queries - CRUD-Module: Contacts, Activities, Pipelines, Deals - Docker-Integration: docker-compose.crm.yml (Port 3100, Traefik-Route /api/v1/crm) - Health-Check, Swagger, GlobalExceptionFilter, Pagination Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
79 lines
3.2 KiB
Markdown
79 lines
3.2 KiB
Markdown
# CRM-Service - Zusammenfassung
|
|
|
|
## Stand: 2026-03-10
|
|
|
|
### Was wurde erstellt
|
|
|
|
Der CRM-Service als eigenstaendiges NestJS-Package unter `packages/crm-service/`.
|
|
|
|
### Struktur
|
|
|
|
```
|
|
packages/crm-service/
|
|
package.json — Dependencies (NestJS 10, Prisma, Passport, ioredis)
|
|
tsconfig.json — Strict TypeScript
|
|
nest-cli.json — NestJS CLI Config
|
|
Dockerfile — Multi-Stage (base, deps, development, build, production)
|
|
.dockerignore — Excludes
|
|
prisma/
|
|
crm.schema.prisma — Eigenes Schema (app_crm) mit eigenem Client-Output
|
|
src/
|
|
main.ts — Bootstrap (Port 3100, Prefix: api/v1/crm, Swagger)
|
|
app.module.ts — Root Module mit globalem JwtAuthGuard + ExceptionFilter
|
|
config/ — Umgebungsvariablen-Validierung
|
|
prisma/ — CrmPrismaService (eigener Client)
|
|
redis/ — RedisService (Token-Blocklist, Cache)
|
|
auth/ — JWT Strategy (RS256), JwtAuthGuard, RolesGuard, TenantGuard
|
|
common/ — Decorators (@Public, @Roles, @CurrentUser), Pagination, ExceptionFilter
|
|
contacts/ — CRUD: Kontakte (PERSON, ORGANIZATION)
|
|
activities/ — CRUD: Aktivitaeten (NOTE, CALL, EMAIL, MEETING, TASK)
|
|
pipelines/ — CRUD: Sales-Pipelines mit Stages
|
|
deals/ — CRUD: Deals mit Pipeline/Stage-Zuordnung
|
|
```
|
|
|
|
### Datenbank-Modelle (app_crm Schema)
|
|
|
|
- **Contact** — Kontakte mit Typen, Adresse, Tags, Audit-Trail
|
|
- **Activity** — Aktivitaeten verknuepft mit Kontakten
|
|
- **Pipeline** — Konfigurierbare Sales-Pipelines pro Tenant
|
|
- **PipelineStage** — Stufen innerhalb einer Pipeline
|
|
- **Deal** — Verkaufschancen mit Wert, Status, Pipeline-Zuordnung
|
|
|
|
### API-Endpunkte
|
|
|
|
| Methode | Pfad | Beschreibung |
|
|
|---------|------|-------------|
|
|
| GET/POST | /api/v1/crm/contacts | Liste / Erstellen |
|
|
| GET/PATCH/DELETE | /api/v1/crm/contacts/:id | Detail / Update / Delete |
|
|
| GET/POST | /api/v1/crm/activities | Liste / Erstellen |
|
|
| GET/PATCH/DELETE | /api/v1/crm/activities/:id | Detail / Update / Delete |
|
|
| GET/POST | /api/v1/crm/pipelines | Liste / Erstellen |
|
|
| GET/PATCH/DELETE | /api/v1/crm/pipelines/:id | Detail / Update / Delete |
|
|
| POST/DELETE | /api/v1/crm/pipelines/:id/stages | Stage hinzufuegen/entfernen |
|
|
| GET/POST | /api/v1/crm/deals | Liste / Erstellen |
|
|
| GET/PATCH/DELETE | /api/v1/crm/deals/:id | Detail / Update / Delete |
|
|
| GET | /health | Health-Check (public) |
|
|
|
|
### Docker-Integration
|
|
|
|
- `docker-compose.crm.yml` im Projekt-Root
|
|
- Port: 3100
|
|
- Netzwerke: insight-web, insight-db, insight-cache
|
|
- Traefik-Route: /api/v1/crm/*
|
|
- JWT Public Key als Read-Only Volume
|
|
|
|
### Sicherheit
|
|
|
|
- JWT RS256 Validierung mit shared Public Key
|
|
- Token-Revocation via Redis (blocked:{jti})
|
|
- Multi-Tenancy: Alle Queries filtern nach tenantId
|
|
- TenantGuard sichert mandantenbezogenen Zugriff
|
|
- Globaler ValidationPipe (whitelist + forbidNonWhitelisted)
|
|
- Strict TypeScript, kein `any`
|
|
|
|
### Naechste Schritte
|
|
|
|
1. `npm install` in packages/crm-service/
|
|
2. Prisma Migration: `npx prisma migrate dev --schema=prisma/crm.schema.prisma --name init`
|
|
3. Docker Build testen
|
|
4. Integration mit laufender Plattform testen
|