Outils pour utilisateurs

Outils du site


ujusum:3-codage:2-sprints:3-sprint-3

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

ujusum:3-codage:2-sprints:3-sprint-3 [2026/06/10 02:19] – créée 83.202.252.200ujusum:3-codage:2-sprints:3-sprint-3 [2026/06/10 14:39] (Version actuelle) 83.202.252.200
Ligne 9221: Ligne 9221:
  
 CRM Notes API CRM Notes API
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2 — Collaboration CRM Enterprise ======
 +
 +===== Objectif =====
 +
 +Transformer le système de notes CRM en véritable plateforme collaborative Enterprise.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Threads
 +
 +✓ Réponses aux notes
 +
 +✓ Réactions
 +
 +✓ Tâches liées
 +
 +✓ Assignation
 +
 +✓ Notifications temps réel
 +
 +✓ Timeline CRM unifiée
 +
 +✓ Collaboration multi-équipes
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Customer
 +
 +
 +
 +CRM Timeline
 +
 +
 +
 +Notes
 +
 +
 +
 +Threads
 +
 +
 +
 +Tasks
 +
 +
 +
 +Mentions
 +
 +
 +
 +Notifications
 +
 +
 +
 +Collaboration Hub
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — Support des Threads ======
 +
 +===== Ajouter dans CustomerNote =====
 +
 +<code prisma>
 +parentNoteId          String?
 +
 +threadRootId          String?
 +
 +replyCount            Int
 +                      @default(0)
 +</code>
 +
 +----
 +
 +====== Étape 2 — Relations ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +parentNote CustomerNote?
 +           @relation(
 +             "CustomerNoteThread",
 +             fields:[parentNoteId],
 +             references:[id]
 +           )
 +
 +replies CustomerNote[]
 +        @relation(
 +          "CustomerNoteThread"
 +        )
 +</code>
 +
 +----
 +
 +====== Étape 3 — Réactions ======
 +
 +===== Créer =====
 +
 +<code prisma>
 +model CustomerNoteReaction {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  noteId                String
 +
 +  userId                String
 +
 +  reaction              String
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  note                  CustomerNote
 +                        @relation(
 +                          fields:[noteId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  user                  User
 +                        @relation(
 +                          fields:[userId],
 +                          references:[id]
 +                        )
 +
 +  @@unique([
 +    noteId,
 +    userId,
 +    reaction
 +  ])
 +
 +  @@index([noteId])
 +
 +  @@index([userId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Tâches CRM ======
 +
 +===== Créer =====
 +
 +<code prisma>
 +model CustomerTask {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  customerId            String
 +
 +  noteId                String?
 +
 +  assignedToId          String?
 +
 +  createdById           String
 +
 +  title                 String
 +
 +  description           String?
 +
 +  priority              TaskPriority
 +
 +  status                TaskStatus
 +
 +  dueDate               DateTime?
 +
 +  completedAt           DateTime?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([customerId])
 +
 +  @@index([assignedToId])
 +
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum TaskPriority {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +
 +enum TaskStatus {
 +
 +  OPEN
 +
 +  IN_PROGRESS
 +
 +  COMPLETED
 +
 +  CANCELLED
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name crm_collaboration
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma generate
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-B ======
 +
 +===== Threads CRM =====
 +
 +----
 +
 +====== Étape 7 — Réponses ======
 +
 +===== Ajouter =====
 +
 +Dans :
 +
 +<code>
 +CustomerNoteService
 +</code>
 +
 +----
 +
 +===== Méthode =====
 +
 +<code ts>
 +replyToNote()
 +</code>
 +
 +----
 +
 +===== Workflow =====
 +
 +<code>
 +Note
 +
 +
 +
 +Réponse
 +
 +
 +
 +Thread
 +
 +
 +
 +Timeline
 +</code>
 +
 +----
 +
 +====== Étape 8 — Exemple ======
 +
 +<code>
 +Client VIP
 +
 +
 +
 +Note commerciale
 +
 +
 +
 +Réponse finance
 +
 +
 +
 +Réponse support
 +</code>
 +
 +----
 +
 +===== Résultat =====
 +
 +<code>
 +Conversation CRM unifiée
 +</code>
 +
 +----
 +
 +====== Étape 9 — Lecture Thread ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /customers/{id}/notes/{noteId}/thread
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code>
 +Arborescence complète
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-C ======
 +
 +===== Réactions =====
 +
 +----
 +
 +====== Étape 10 — Réactions supportées ======
 +
 +<code>
 +LIKE
 +
 +IMPORTANT
 +
 +FOLLOW_UP
 +
 +DONE
 +
 +WARNING
 +</code>
 +
 +----
 +
 +====== Étape 11 — Service ======
 +
 +===== Ajouter =====
 +
 +<code ts>
 +addReaction()
 +
 +removeReaction()
 +
 +listReactions()
 +</code>
 +
 +----
 +
 +====== Étape 12 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +POST /notes/{noteId}/reactions
 +
 +DELETE /notes/{noteId}/reactions
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-D ======
 +
 +===== Assignation CRM =====
 +
 +----
 +
 +====== Étape 13 — Assignation ======
 +
 +===== Ajouter dans CustomerNote =====
 +
 +<code prisma>
 +assignedToId String?
 +</code>
 +
 +----
 +
 +===== Relation =====
 +
 +<code prisma>
 +assignedTo User?
 +</code>
 +
 +----
 +
 +====== Étape 14 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +PUT /notes/{noteId}/assign
 +</code>
 +
 +----
 +
 +===== Exemple =====
 +
 +<code>
 +Client réclame facture
 +
 +
 +
 +Assigné Finance
 +</code>
 +
 +----
 +
 +====== Étape 15 — Notification ======
 +
 +===== Déclencher =====
 +
 +<code>
 +Notification
 +
 +Email
 +
 +In-App
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-E ======
 +
 +===== Tâches CRM =====
 +
 +----
 +
 +====== Étape 16 — CustomerTaskService ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-task.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createTask()
 +
 +assignTask()
 +
 +completeTask()
 +
 +cancelTask()
 +</code>
 +
 +----
 +
 +====== Étape 17 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET    /customers/{id}/tasks
 +
 +POST   /customers/{id}/tasks
 +
 +PUT    /customers/{id}/tasks/{taskId}
 +
 +DELETE /customers/{id}/tasks/{taskId}
 +</code>
 +
 +----
 +
 +====== Étape 18 — Exemple ======
 +
 +<code>
 +Rappeler client
 +
 +
 +
 +Assigner commercial
 +
 +
 +
 +Date limite
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-F ======
 +
 +===== Notifications Temps Réel =====
 +
 +----
 +
 +====== Étape 19 — WebSocket ======
 +
 +===== Réutiliser =====
 +
 +Infrastructure :
 +
 +<code>
 +Notification Gateway
 +</code>
 +
 +prévue en Sprint 9.
 +
 +----
 +
 +====== Étape 20 — Événements ======
 +
 +<code>
 +NOTE_CREATED
 +
 +NOTE_REPLY
 +
 +NOTE_MENTION
 +
 +NOTE_ASSIGNED
 +
 +TASK_CREATED
 +
 +TASK_COMPLETED
 +</code>
 +
 +----
 +
 +====== Étape 21 — Canal ======
 +
 +<code>
 +tenant:{tenantId}
 +
 +crm:{customerId}
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-G ======
 +
 +===== Timeline CRM Unifiée =====
 +
 +----
 +
 +====== Étape 22 — Création ======
 +
 +<code>
 +crm-timeline.service.ts
 +</code>
 +
 +----
 +
 +===== Sources =====
 +
 +<code>
 +CustomerNote
 +
 +CustomerDocument
 +
 +CustomerTag
 +
 +CustomerTask
 +
 +Reservation
 +
 +Invoice
 +
 +Communication
 +</code>
 +
 +----
 +
 +====== Étape 23 — Timeline ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /customers/{id}/timeline
 +</code>
 +
 +----
 +
 +===== Exemple =====
 +
 +<code json>
 +[
 +  {
 +    "type":"NOTE",
 +    "date":"2026-01-01"
 +  },
 +  {
 +    "type":"TASK",
 +    "date":"2026-01-03"
 +  },
 +  {
 +    "type":"DOCUMENT",
 +    "date":"2026-01-05"
 +  }
 +]
 +</code>
 +
 +----
 +
 +====== Étape 24 — Filtres ======
 +
 +<code>
 +Notes
 +
 +Documents
 +
 +Tâches
 +
 +Tags
 +
 +Réservations
 +
 +Factures
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-H ======
 +
 +===== Collaboration Dashboard =====
 +
 +----
 +
 +====== Étape 25 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm/collaboration/dashboard
 +</code>
 +
 +----
 +
 +===== KPI =====
 +
 +<code>
 +Notes ouvertes
 +
 +Tâches ouvertes
 +
 +Mentions non lues
 +
 +Assignations
 +
 +Threads actifs
 +</code>
 +
 +----
 +
 +====== Étape 26 — Exemple ======
 +
 +<code json>
 +{
 +  "openTasks":42,
 +  "activeThreads":17,
 +  "unreadMentions":9
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-I ======
 +
 +===== Audit & Historisation =====
 +
 +----
 +
 +====== Étape 27 — CustomerHistory ======
 +
 +===== Journaliser =====
 +
 +<code>
 +NOTE_REPLIED
 +
 +NOTE_ASSIGNED
 +
 +TASK_CREATED
 +
 +TASK_COMPLETED
 +</code>
 +
 +----
 +
 +====== Étape 28 — AuditLog ======
 +
 +===== Ajouter =====
 +
 +<code>
 +CRM_THREAD_CREATED
 +
 +CRM_NOTE_REACTION
 +
 +CRM_TASK_CREATED
 +
 +CRM_TASK_ASSIGNED
 +
 +CRM_TASK_COMPLETED
 +</code>
 +
 +----
 +
 +====== Sprint 3-F.2-J ======
 +
 +===== Préparation Sprint 9 =====
 +
 +----
 +
 +===== Compatible =====
 +
 +<code>
 +Campaign
 +
 +MarketingEvent
 +
 +NotificationCenter
 +
 +Realtime Communication
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +AiConversation
 +
 +Recommendation
 +
 +AutomationScenario
 +
 +KnowledgeDocument
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise CRM
 +
 +Collaboration Analytics
 +
 +Customer Intelligence
 +
 +Unified Timeline
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-F.2 est terminé lorsque :
 +
 +<code>
 +✓ Threads CRM
 +
 +✓ Réponses aux notes
 +
 +✓ Réactions
 +
 +✓ Assignation
 +
 +✓ Tâches CRM
 +
 +✓ Notifications temps réel
 +
 +✓ Timeline unifiée
 +
 +✓ Dashboard collaboration
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +CustomerNoteReaction
 +
 +CustomerTask
 +
 +CustomerTaskService
 +
 +CrmTimelineService
 +
 +CRM Collaboration API
 +
 +Unified CRM Timeline
 +
 +Realtime CRM Events
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1 — Gestion des Communications Client ======
 +
 +===== Objectif =====
 +
 +Implémenter la couche CRM Communication centralisée permettant de tracer toutes les interactions client.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Emails
 +
 +✓ SMS
 +
 +✓ Appels
 +
 +✓ Historique communications
 +
 +✓ Timeline CRM
 +
 +✓ Audit
 +
 +✓ Statistiques
 +
 +✓ Préparation Marketing
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Customer
 +
 +
 +
 +CustomerCommunication
 +
 +
 +
 +Email
 +
 +SMS
 +
 +Calls
 +
 +
 +
 +Timeline CRM
 +
 +
 +
 +Analytics
 +
 +
 +
 +Marketing
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-A ======
 +
 +===== Modèle Prisma =====
 +
 +----
 +
 +====== Étape 1 — Création CustomerCommunication ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model CustomerCommunication {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  customerId            String
 +
 +  userId                String?
 +
 +  communicationType     CommunicationType
 +
 +  direction             CommunicationDirection
 +
 +  status                CommunicationStatus
 +
 +  subject               String?
 +
 +  content               String?
 +
 +  externalReference     String?
 +
 +  provider              String?
 +
 +  sender                String?
 +
 +  recipient             String?
 +
 +  durationSeconds       Int?
 +
 +  scheduledAt           DateTime?
 +
 +  sentAt                DateTime?
 +
 +  deliveredAt           DateTime?
 +
 +  openedAt              DateTime?
 +
 +  repliedAt             DateTime?
 +
 +  metadata              Json?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  deletedAt             DateTime?
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  user                  User?
 +                        @relation(
 +                          fields:[userId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([customerId])
 +
 +  @@index([communicationType])
 +
 +  @@index([status])
 +
 +  @@index([createdAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — CommunicationType ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum CommunicationType {
 +
 +  EMAIL
 +
 +  SMS
 +
 +  PHONE_CALL
 +
 +  WHATSAPP
 +
 +  PUSH_NOTIFICATION
 +
 +  LETTER
 +
 +  INTERNAL_NOTE
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — Direction ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum CommunicationDirection {
 +
 +  INBOUND
 +
 +  OUTBOUND
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Status ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum CommunicationStatus {
 +
 +  DRAFT
 +
 +  SCHEDULED
 +
 +  SENT
 +
 +  DELIVERED
 +
 +  OPENED
 +
 +  REPLIED
 +
 +  FAILED
 +
 +  CANCELLED
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Relation Customer ======
 +
 +===== Ajouter =====
 +
 +Dans :
 +
 +<code prisma>
 +model Customer
 +</code>
 +
 +<code prisma>
 +communications CustomerCommunication[]
 +</code>
 +
 +----
 +
 +====== Étape 6 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name customer_communications
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma generate
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-B ======
 +
 +===== Module =====
 +
 +----
 +
 +====== Étape 7 — Création ======
 +
 +<code>
 +src/modules/customer-communications
 +
 +├── application
 +
 +│   └── dto
 +
 +│       ├── create-customer-communication.dto.ts
 +
 +│       ├── communication-query.dto.ts
 +
 +│       └── communication-response.dto.ts
 +
 +├── domain
 +
 +│   └── services
 +
 +│       └── customer-communication.service.ts
 +
 +├── presentation
 +
 +│   └── controllers
 +
 +│       └── customer-communication.controller.ts
 +
 +└── customer-communication.module.ts
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-C ======
 +
 +===== DTOs =====
 +
 +----
 +
 +====== Étape 8 — Create DTO ======
 +
 +===== Créer =====
 +
 +<code>
 +create-customer-communication.dto.ts
 +</code>
 +
 +----
 +
 +===== Implémentation =====
 +
 +<code ts>
 +export class CreateCustomerCommunicationDto {
 +
 +  communicationType: string;
 +
 +  direction: string;
 +
 +  subject?: string;
 +
 +  content?: string;
 +
 +  recipient?: string;
 +
 +  sender?: string;
 +
 +  scheduledAt?: Date;
 +}
 +</code>
 +
 +----
 +
 +====== Étape 9 — Query DTO ======
 +
 +===== Ajouter =====
 +
 +<code ts>
 +export class CommunicationQueryDto {
 +
 +  communicationType?: string;
 +
 +  status?: string;
 +
 +  direction?: string;
 +
 +  page?: number = 1;
 +
 +  limit?: number = 25;
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-D ======
 +
 +===== CustomerCommunicationService =====
 +
 +----
 +
 +====== Étape 10 — Création ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-communication.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +findAll()
 +
 +findTimeline()
 +
 +create()
 +
 +markDelivered()
 +
 +markOpened()
 +
 +markReplied()
 +</code>
 +
 +----
 +
 +====== Étape 11 — Création ======
 +
 +===== Exemple =====
 +
 +<code ts>
 +await prisma.customerCommunication.create({
 +
 +  data: {
 +
 +    tenantId,
 +
 +    customerId,
 +
 +    userId,
 +
 +    ...dto
 +  }
 +});
 +</code>
 +
 +----
 +
 +====== Étape 12 — Historisation ======
 +
 +===== Ajouter =====
 +
 +Dans :
 +
 +<code>
 +CustomerHistory
 +</code>
 +
 +----
 +
 +===== Événements =====
 +
 +<code>
 +COMMUNICATION_CREATED
 +
 +EMAIL_SENT
 +
 +SMS_SENT
 +
 +CALL_LOGGED
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-E ======
 +
 +===== Emails =====
 +
 +----
 +
 +====== Étape 13 — Intégration ======
 +
 +===== Préparer =====
 +
 +<code>
 +EmailService
 +</code>
 +
 +----
 +
 +===== Fournisseurs =====
 +
 +<code>
 +SMTP
 +
 +SendGrid
 +
 +Mailgun
 +
 +AWS SES
 +</code>
 +
 +----
 +
 +====== Étape 14 — Workflow ======
 +
 +<code>
 +CRM
 +
 +
 +
 +Email
 +
 +
 +
 +Send
 +
 +
 +
 +Tracking
 +
 +
 +
 +Timeline
 +</code>
 +
 +----
 +
 +====== Étape 15 — Tracking ======
 +
 +===== Stocker =====
 +
 +<code>
 +sentAt
 +
 +deliveredAt
 +
 +openedAt
 +
 +repliedAt
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-F ======
 +
 +===== SMS =====
 +
 +----
 +
 +====== Étape 16 — Intégration ======
 +
 +===== Préparer =====
 +
 +<code>
 +SmsService
 +</code>
 +
 +----
 +
 +===== Fournisseurs =====
 +
 +<code>
 +Twilio
 +
 +OVH SMS
 +
 +MessageBird
 +</code>
 +
 +----
 +
 +====== Étape 17 — Tracking ======
 +
 +===== Stocker =====
 +
 +<code>
 +Sent
 +
 +Delivered
 +
 +Failed
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-G ======
 +
 +===== Appels =====
 +
 +----
 +
 +====== Étape 18 — Journalisation ======
 +
 +===== Ajouter =====
 +
 +<code>
 +PHONE_CALL
 +</code>
 +
 +----
 +
 +===== Métadonnées =====
 +
 +<code>
 +Duration
 +
 +Agent
 +
 +Outcome
 +
 +Recording
 +</code>
 +
 +----
 +
 +====== Étape 19 — Exemple ======
 +
 +<code json>
 +{
 +  "communicationType":"PHONE_CALL",
 +  "durationSeconds":420
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-H ======
 +
 +===== Timeline CRM =====
 +
 +----
 +
 +====== Étape 20 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /customers/{id}/communications/timeline
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code>
 +Communications
 +
 ++
 +
 +Notes
 +
 ++
 +
 +Documents
 +
 ++
 +
 +Tags
 +</code>
 +
 +----
 +
 +====== Étape 21 — Vue unifiée ======
 +
 +===== Exemple =====
 +
 +<code json>
 +[
 +  {
 +    "type":"EMAIL",
 +    "date":"2026-01-01"
 +  },
 +  {
 +    "type":"SMS",
 +    "date":"2026-01-02"
 +  },
 +  {
 +    "type":"CALL",
 +    "date":"2026-01-03"
 +  }
 +]
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-I ======
 +
 +===== Contrôleur =====
 +
 +----
 +
 +====== Étape 22 — Création ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-communication.controller.ts
 +</code>
 +
 +----
 +
 +===== Déclaration =====
 +
 +<code ts>
 +@ApiTags(
 +  'Customer Communications'
 +)
 +
 +@Controller(
 +  'customers/:id/communications'
 +)
 +
 +@UseGuards(
 +  JwtAuthGuard
 +)
 +</code>
 +
 +----
 +
 +====== Étape 23 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /customers/{id}/communications
 +
 +POST /customers/{id}/communications
 +
 +GET /customers/{id}/communications/timeline
 +</code>
 +
 +----
 +
 +====== Étape 24 — Recherche ======
 +
 +===== Ajouter =====
 +
 +Filtres :
 +
 +<code>
 +Type
 +
 +Statut
 +
 +Direction
 +
 +Période
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.1-J ======
 +
 +===== Audit & Analytics =====
 +
 +----
 +
 +====== Étape 25 — AuditLog ======
 +
 +===== Journaliser =====
 +
 +<code>
 +COMMUNICATION_CREATED
 +
 +EMAIL_DELIVERED
 +
 +EMAIL_OPENED
 +
 +SMS_DELIVERED
 +
 +CALL_CREATED
 +</code>
 +
 +----
 +
 +====== Étape 26 — KPI ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /customers/{id}/communications/statistics
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "emails":124,
 +  "sms":31,
 +  "calls":14,
 +  "openRate":67,
 +  "replyRate":19
 +}
 +</code>
 +
 +----
 +
 +====== Étape 27 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +communications.read
 +
 +communications.write
 +
 +communications.send
 +
 +communications.manage
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 9 ======
 +
 +Compatible avec :
 +
 +<code>
 +Campaign
 +
 +EmailCampaign
 +
 +SmsCampaign
 +
 +NotificationCenter
 +
 +RealtimeMessaging
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +AiConversation
 +
 +Recommendation
 +
 +AutomationScenario
 +
 +KnowledgeBase
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Customer Intelligence
 +
 +Communication Analytics
 +
 +Engagement Scoring
 +
 +Predictive CRM
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-G.1 est terminé lorsque :
 +
 +<code>
 +✓ CustomerCommunication créé
 +
 +✓ Emails tracés
 +
 +✓ SMS tracés
 +
 +✓ Appels tracés
 +
 +✓ Historique complet
 +
 +✓ Timeline CRM
 +
 +✓ AuditLog intégré
 +
 +✓ Statistiques CRM
 +
 +✓ Swagger documenté
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +CustomerCommunication
 +
 +CustomerCommunicationModule
 +
 +CustomerCommunicationController
 +
 +CustomerCommunicationService
 +
 +Communication Timeline
 +
 +Communication Analytics
 +</code>
 +
 +----
 +
 +====== Étape suivante ======
 +
 +====== Sprint 3-G.2 — Communication Intelligence & Omnicanal ======
 +
 +===== Objectif =====
 +
 +Faire évoluer le module CRM Communication vers une plateforme omnicanale Enterprise.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ WhatsApp
 +
 +✓ Messagerie instantanée
 +
 +✓ Templates
 +
 +✓ Campagnes
 +
 +✓ Analyse de sentiment
 +
 +✓ IA conversationnelle
 +
 +✓ Centre omnicanal
 +
 +✓ Communication Intelligence
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Customer
 +
 +
 +
 +Omnichannel Hub
 +
 +├── Email
 +├── SMS
 +├── WhatsApp
 +├── Chat
 +├── Push
 +├── Voice
 +
 +
 +
 +AI Intelligence
 +
 +
 +
 +Campaigns
 +
 +
 +
 +Analytics
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — CommunicationTemplate ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model CommunicationTemplate {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  name                  String
 +
 +  code                  String
 +
 +  channel               CommunicationChannel
 +
 +  subject               String?
 +
 +  content               String
 +
 +  variables             Json?
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  @@unique([
 +    tenantId,
 +    code
 +  ])
 +
 +  @@index([tenantId])
 +
 +  @@index([channel])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — OmnichannelConversation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model OmnichannelConversation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  customerId            String
 +
 +  channel               CommunicationChannel
 +
 +  status                ConversationStatus
 +
 +  subject               String?
 +
 +  startedAt             DateTime
 +                        @default(now())
 +
 +  lastMessageAt         DateTime?
 +
 +  closedAt              DateTime?
 +
 +  assignedToId          String?
 +
 +  sentimentScore        Float?
 +
 +  aiSummary             String?
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([customerId])
 +
 +  @@index([channel])
 +
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — ConversationMessage ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ConversationMessage {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  conversationId        String
 +
 +  direction             CommunicationDirection
 +
 +  messageType           String
 +
 +  content               String?
 +
 +  externalReference     String?
 +
 +  sentAt                DateTime
 +                        @default(now())
 +
 +  metadata              Json?
 +
 +  conversation          OmnichannelConversation
 +                        @relation(
 +                          fields:[conversationId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([conversationId])
 +
 +  @@index([sentAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum CommunicationChannel {
 +
 +  EMAIL
 +
 +  SMS
 +
 +  WHATSAPP
 +
 +  CHAT
 +
 +  PUSH
 +
 +  VOICE
 +}
 +
 +enum ConversationStatus {
 +
 +  OPEN
 +
 +  ASSIGNED
 +
 +  WAITING_CUSTOMER
 +
 +  CLOSED
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name omnichannel_communications
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-B ======
 +
 +===== Omnichannel Module =====
 +
 +----
 +
 +====== Étape 6 — Création ======
 +
 +<code>
 +src/modules/omnichannel
 +</code>
 +
 +----
 +
 +===== Structure =====
 +
 +<code>
 +omnichannel
 +
 +├── templates
 +
 +├── conversations
 +
 +├── whatsapp
 +
 +├── chat
 +
 +├── ai
 +
 +└── analytics
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-C ======
 +
 +===== WhatsApp Business =====
 +
 +----
 +
 +====== Étape 7 — WhatsApp Service ======
 +
 +===== Créer =====
 +
 +<code>
 +whatsapp.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +sendMessage()
 +
 +sendTemplate()
 +
 +receiveWebhook()
 +
 +markDelivered()
 +</code>
 +
 +----
 +
 +====== Étape 8 — Modèles WhatsApp ======
 +
 +===== Exemples =====
 +
 +<code>
 +Booking Confirmation
 +
 +Payment Reminder
 +
 +Welcome Message
 +
 +Review Request
 +
 +Check-In Reminder
 +</code>
 +
 +----
 +
 +====== Étape 9 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +POST /communications/whatsapp/send
 +
 +POST /communications/whatsapp/template
 +
 +POST /communications/whatsapp/webhook
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-D ======
 +
 +===== Messagerie Instantanée =====
 +
 +----
 +
 +====== Étape 10 — Chat Service ======
 +
 +===== Créer =====
 +
 +<code>
 +chat.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +startConversation()
 +
 +sendMessage()
 +
 +closeConversation()
 +
 +assignConversation()
 +</code>
 +
 +----
 +
 +====== Étape 11 — Temps réel ======
 +
 +===== Utiliser =====
 +
 +<code>
 +WebSocket Gateway
 +</code>
 +
 +----
 +
 +===== Événements =====
 +
 +<code>
 +CHAT_MESSAGE
 +
 +CHAT_TYPING
 +
 +CHAT_ASSIGNED
 +
 +CHAT_CLOSED
 +</code>
 +
 +----
 +
 +====== Étape 12 — Endpoints ======
 +
 +<code http>
 +GET  /conversations
 +
 +GET  /conversations/{id}
 +
 +POST /conversations/{id}/messages
 +
 +PUT  /conversations/{id}/assign
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-E ======
 +
 +===== Templates Enterprise =====
 +
 +----
 +
 +====== Étape 13 — Template Service ======
 +
 +===== Créer =====
 +
 +<code>
 +communication-template.service.ts
 +</code>
 +
 +----
 +
 +===== Variables =====
 +
 +<code>
 +{{customerName}}
 +
 +{{reservationNumber}}
 +
 +{{propertyName}}
 +
 +{{checkInDate}}
 +
 +{{amount}}
 +</code>
 +
 +----
 +
 +====== Étape 14 — Rendu ======
 +
 +===== Méthode =====
 +
 +<code ts>
 +renderTemplate()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Endpoints ======
 +
 +<code http>
 +GET    /communication-templates
 +
 +POST   /communication-templates
 +
 +PUT    /communication-templates/{id}
 +
 +DELETE /communication-templates/{id}
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-F ======
 +
 +===== Campagnes CRM =====
 +
 +----
 +
 +====== Étape 16 — CampaignCommunication ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model CampaignCommunication {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  name                  String
 +
 +  channel               CommunicationChannel
 +
 +  templateId            String?
 +
 +  targetSegment         String?
 +
 +  status                String
 +
 +  scheduledAt           DateTime?
 +
 +  sentAt                DateTime?
 +
 +  recipientsCount       Int
 +                        @default(0)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  @@index([tenantId])
 +
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 17 — Campagnes ======
 +
 +===== Types =====
 +
 +<code>
 +Newsletter
 +
 +Promotion
 +
 +Loyalty
 +
 +Upsell
 +
 +Cross-sell
 +
 +Retention
 +</code>
 +
 +----
 +
 +====== Étape 18 — Endpoints ======
 +
 +<code http>
 +GET    /campaigns
 +
 +POST   /campaigns
 +
 +POST   /campaigns/{id}/send
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-G ======
 +
 +===== Analyse de Sentiment =====
 +
 +----
 +
 +====== Étape 19 — Extension Conversation ======
 +
 +===== Utiliser =====
 +
 +<code prisma>
 +sentimentScore Float?
 +
 +aiSummary      String?
 +</code>
 +
 +----
 +
 +====== Étape 20 — Sentiment ======
 +
 +===== Service =====
 +
 +<code>
 +sentiment-analysis.service.ts
 +</code>
 +
 +----
 +
 +===== Résultat =====
 +
 +<code>
 +NEGATIVE
 +
 +NEUTRAL
 +
 +POSITIVE
 +</code>
 +
 +----
 +
 +====== Étape 21 — Exemple ======
 +
 +<code>
 +"Très satisfait"
 +
 +
 +
 +POSITIVE
 +
 +
 +
 +0.92
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-H ======
 +
 +===== IA Conversationnelle =====
 +
 +----
 +
 +====== Étape 22 — AI Conversation Service ======
 +
 +===== Créer =====
 +
 +<code>
 +conversation-ai.service.ts
 +</code>
 +
 +----
 +
 +===== Capacités =====
 +
 +<code>
 +Résumé automatique
 +
 +Détection intention
 +
 +Suggestions réponses
 +
 +Priorisation
 +</code>
 +
 +----
 +
 +====== Étape 23 — Suggestions ======
 +
 +===== Exemple =====
 +
 +<code>
 +Client demande remboursement
 +
 +
 +
 +Intent:
 +REFUND_REQUEST
 +
 +
 +
 +Réponse suggérée
 +</code>
 +
 +----
 +
 +====== Étape 24 — Résumé ======
 +
 +===== Générer =====
 +
 +<code>
 +aiSummary
 +</code>
 +
 +à la fermeture d'une conversation.
 +
 +----
 +
 +====== Sprint 3-G.2-I ======
 +
 +===== Centre Omnicanal =====
 +
 +----
 +
 +====== Étape 25 — Dashboard ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /omnichannel/dashboard
 +</code>
 +
 +----
 +
 +===== KPI =====
 +
 +<code>
 +Conversations ouvertes
 +
 +Temps réponse moyen
 +
 +Messages aujourd'hui
 +
 +Sentiment moyen
 +
 +Campagnes actives
 +</code>
 +
 +----
 +
 +====== Étape 26 — Vue Agent ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /omnichannel/inbox
 +</code>
 +
 +----
 +
 +===== Regroupe =====
 +
 +<code>
 +Email
 +
 +SMS
 +
 +WhatsApp
 +
 +Chat
 +</code>
 +
 +----
 +
 +====== Sprint 3-G.2-J ======
 +
 +===== Audit & Intelligence =====
 +
 +----
 +
 +====== Étape 27 — AuditLog ======
 +
 +===== Ajouter =====
 +
 +<code>
 +WHATSAPP_SENT
 +
 +CHAT_STARTED
 +
 +CHAT_ASSIGNED
 +
 +CAMPAIGN_CREATED
 +
 +CAMPAIGN_SENT
 +
 +SENTIMENT_ANALYZED
 +
 +AI_RESPONSE_GENERATED
 +</code>
 +
 +----
 +
 +====== Étape 28 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +communications.campaigns
 +
 +communications.templates
 +
 +communications.omnichannel
 +
 +communications.ai
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 9 ======
 +
 +Compatible avec :
 +
 +<code>
 +NotificationCenter
 +
 +RealtimeMessaging
 +
 +CampaignEngine
 +
 +CommunicationHub
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +AiConversation
 +
 +AiMessage
 +
 +Recommendation
 +
 +AutomationScenario
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise Analytics
 +
 +Communication Intelligence
 +
 +Customer Intelligence
 +
 +Revenue Intelligence
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-G.2 est terminé lorsque :
 +
 +<code>
 +✓ WhatsApp intégré
 +
 +✓ Messagerie instantanée
 +
 +✓ Templates
 +
 +✓ Campagnes CRM
 +
 +✓ Analyse de sentiment
 +
 +✓ IA conversationnelle
 +
 +✓ Centre omnicanal
 +
 +✓ Dashboard omnicanal
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +CommunicationTemplate
 +
 +OmnichannelConversation
 +
 +ConversationMessage
 +
 +WhatsAppService
 +
 +ChatService
 +
 +ConversationAIService
 +
 +SentimentAnalysisService
 +
 +Omnichannel Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1 — Gestion des Préférences Client ======
 +
 +===== Objectif =====
 +
 +Implémenter la gestion centralisée des préférences client permettant :
 +
 +<code>
 +Personnalisation
 +
 +Marketing
 +
 +Communication
 +
 +Fidélisation
 +
 +Consentements
 +
 +Expérience client
 +</code>
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Préférences marketing
 +
 +✓ Canaux préférés
 +
 +✓ Consentements
 +
 +✓ Préférences linguistiques
 +
 +✓ Préférences monétaires
 +
 +✓ Personnalisation CRM
 +
 +✓ Conformité RGPD
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Customer
 +
 +
 +
 +CustomerPreference
 +
 +├── Marketing
 +├── Communication
 +├── Language
 +├── Currency
 +├── Timezone
 +├── Loyalty
 +└── GDPR
 +
 +
 +
 +CRM
 +
 +
 +
 +Marketing Automation
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — Enrichissement CustomerPreference ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model CustomerPreference {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  customerId            String
 +                        @unique
 +
 +  preferredLanguage     String?
 +
 +  preferredCurrency     String?
 +
 +  preferredTimezone     String?
 +
 +  preferredChannel      PreferredChannel?
 +
 +  preferredContactTime  String?
 +
 +  prefersEmail          Boolean
 +                        @default(true)
 +
 +  prefersSms            Boolean
 +                        @default(false)
 +
 +  prefersPhone          Boolean
 +                        @default(false)
 +
 +  prefersWhatsApp       Boolean
 +                        @default(false)
 +
 +  acceptsMarketing      Boolean
 +                        @default(false)
 +
 +  acceptsNewsletter     Boolean
 +                        @default(false)
 +
 +  acceptsPromotions     Boolean
 +                        @default(false)
 +
 +  acceptsSurveys        Boolean
 +                        @default(false)
 +
 +  acceptsRecommendations Boolean
 +                         @default(false)
 +
 +  loyaltyEligible       Boolean
 +                        @default(true)
 +
 +  vipProgramEligible    Boolean
 +                        @default(false)
 +
 +  communicationFrequency CommunicationFrequency?
 +  
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PreferredChannel ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum PreferredChannel {
 +
 +  EMAIL
 +
 +  SMS
 +
 +  PHONE
 +
 +  WHATSAPP
 +
 +  PUSH
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — CommunicationFrequency ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum CommunicationFrequency {
 +
 +  IMMEDIATE
 +
 +  DAILY
 +
 +  WEEKLY
 +
 +  MONTHLY
 +
 +  NEVER
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Consentement RGPD ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +marketingConsentAt      DateTime?
 +
 +newsletterConsentAt     DateTime?
 +
 +privacyAcceptedAt       DateTime?
 +
 +consentVersion          String?
 +
 +consentIpAddress        String?
 +</code>
 +
 +----
 +
 +====== Étape 5 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name customer_preferences_enterprise
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma generate
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-B ======
 +
 +===== Module =====
 +
 +----
 +
 +====== Étape 6 — Création ======
 +
 +<code>
 +src/modules/customer-preferences
 +
 +├── application
 +
 +│   └── dto
 +
 +│       ├── update-customer-preference.dto.ts
 +
 +│       └── customer-preference-response.dto.ts
 +
 +├── domain
 +
 +│   └── services
 +
 +│       └── customer-preference.service.ts
 +
 +├── presentation
 +
 +│   └── controllers
 +
 +│       └── customer-preference.controller.ts
 +
 +└── customer-preference.module.ts
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-C ======
 +
 +===== DTOs =====
 +
 +----
 +
 +====== Étape 7 — Update DTO ======
 +
 +===== Créer =====
 +
 +<code>
 +update-customer-preference.dto.ts
 +</code>
 +
 +----
 +
 +===== Implémentation =====
 +
 +<code ts>
 +export class UpdateCustomerPreferenceDto {
 +
 +  preferredLanguage?: string;
 +
 +  preferredCurrency?: string;
 +
 +  preferredTimezone?: string;
 +
 +  preferredChannel?: string;
 +
 +  preferredContactTime?: string;
 +
 +  prefersEmail?: boolean;
 +
 +  prefersSms?: boolean;
 +
 +  prefersPhone?: boolean;
 +
 +  prefersWhatsApp?: boolean;
 +
 +  acceptsMarketing?: boolean;
 +
 +  acceptsNewsletter?: boolean;
 +
 +  acceptsPromotions?: boolean;
 +
 +  acceptsSurveys?: boolean;
 +
 +  acceptsRecommendations?: boolean;
 +
 +  communicationFrequency?: string;
 +}
 +</code>
 +
 +----
 +
 +====== Étape 8 — Response DTO ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-preference-response.dto.ts
 +</code>
 +
 +----
 +
 +===== Ajouter =====
 +
 +<code ts>
 +export class CustomerPreferenceResponseDto {
 +
 +  preferredLanguage: string;
 +
 +  preferredCurrency: string;
 +
 +  preferredChannel: string;
 +
 +  acceptsMarketing: boolean;
 +
 +  acceptsNewsletter: boolean;
 +
 +  communicationFrequency: string;
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-D ======
 +
 +===== CustomerPreferenceService =====
 +
 +----
 +
 +====== Étape 9 — Création ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-preference.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +findPreferences()
 +
 +updatePreferences()
 +
 +validatePreferences()
 +
 +recordConsent()
 +</code>
 +
 +----
 +
 +====== Étape 10 — Lecture ======
 +
 +===== Vérifier =====
 +
 +<code>
 +Customer
 +
 +Tenant
 +</code>
 +
 +avant toute lecture.
 +
 +----
 +
 +===== Retour =====
 +
 +<code ts>
 +CustomerPreference
 +</code>
 +
 +----
 +
 +====== Étape 11 — Mise à jour ======
 +
 +===== Exemple =====
 +
 +<code ts>
 +await prisma.customerPreference.update({
 +
 +  where: {
 +
 +    customerId
 +  },
 +
 +  data: {
 +
 +    ...dto
 +  }
 +});
 +</code>
 +
 +----
 +
 +====== Étape 12 — Consentements ======
 +
 +===== Si =====
 +
 +<code>
 +acceptsMarketing=true
 +</code>
 +
 +----
 +
 +===== Ajouter =====
 +
 +<code ts>
 +marketingConsentAt:
 +  new Date()
 +</code>
 +
 +----
 +
 +===== Si =====
 +
 +<code>
 +acceptsNewsletter=true
 +</code>
 +
 +----
 +
 +===== Ajouter =====
 +
 +<code ts>
 +newsletterConsentAt:
 +  new Date()
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-E ======
 +
 +===== Validation =====
 +
 +----
 +
 +====== Étape 13 — Langues ======
 +
 +===== Vérifier =====
 +
 +Contre :
 +
 +<code>
 +SupportedLanguages
 +</code>
 +
 +----
 +
 +====== Étape 14 — Devises ======
 +
 +===== Vérifier =====
 +
 +Contre :
 +
 +<code>
 +SupportedCurrencies
 +</code>
 +
 +----
 +
 +====== Étape 15 — Fuseaux horaires ======
 +
 +===== Vérifier =====
 +
 +Contre :
 +
 +<code>
 +IANA Timezones
 +</code>
 +
 +----
 +
 +====== Étape 16 — Cohérence ======
 +
 +===== Exemple =====
 +
 +<code>
 +PreferredChannel=SMS
 +
 +
 +
 +Téléphone requis
 +</code>
 +
 +----
 +
 +===== Sinon =====
 +
 +<code ts>
 +throw new BadRequestException()
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-F ======
 +
 +===== Personnalisation CRM =====
 +
 +----
 +
 +====== Étape 17 — Utilisation ======
 +
 +Les préférences alimentent :
 +
 +<code>
 +Marketing
 +
 +Communication
 +
 +Campagnes
 +
 +Recommandations
 +
 +Automatisation
 +</code>
 +
 +----
 +
 +====== Étape 18 — Exemples ======
 +
 +<code>
 +Langue = FR
 +
 +
 +
 +Templates FR
 +</code>
 +
 +----
 +
 +<code>
 +Canal = WhatsApp
 +
 +
 +
 +Communication WhatsApp
 +</code>
 +
 +----
 +
 +<code>
 +Fréquence = Weekly
 +
 +
 +
 +Digest hebdomadaire
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-G ======
 +
 +===== Contrôleur =====
 +
 +----
 +
 +====== Étape 19 — Création ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-preference.controller.ts
 +</code>
 +
 +----
 +
 +===== Déclaration =====
 +
 +<code ts>
 +@ApiTags(
 +  'Customer Preferences'
 +)
 +
 +@Controller(
 +  'customers/:id/preferences'
 +)
 +
 +@UseGuards(
 +  JwtAuthGuard
 +)
 +
 +@ApiBearerAuth()
 +</code>
 +
 +----
 +
 +====== Étape 20 — GET ======
 +
 +===== Route =====
 +
 +<code http>
 +GET /customers/{id}/preferences
 +</code>
 +
 +----
 +
 +====== Étape 21 — PUT ======
 +
 +===== Route =====
 +
 +<code http>
 +PUT /customers/{id}/preferences
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-H ======
 +
 +===== Historisation CRM =====
 +
 +----
 +
 +====== Étape 22 — CustomerHistory ======
 +
 +===== Journaliser =====
 +
 +<code>
 +PREFERENCES_UPDATED
 +
 +MARKETING_CONSENT_UPDATED
 +
 +COMMUNICATION_CHANNEL_CHANGED
 +</code>
 +
 +----
 +
 +====== Étape 23 — AuditLog ======
 +
 +===== Ajouter =====
 +
 +<code>
 +CUSTOMER_PREFERENCES_UPDATED
 +
 +CUSTOMER_CONSENT_GRANTED
 +
 +CUSTOMER_CONSENT_REVOKED
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-I ======
 +
 +===== Analytics =====
 +
 +----
 +
 +====== Étape 24 — Statistiques ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /customers/preferences/statistics
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "email":523,
 +  "sms":121,
 +  "whatsapp":84,
 +  "marketingOptIn":432
 +}
 +</code>
 +
 +----
 +
 +====== Étape 25 — Segmentation ======
 +
 +===== Exemple =====
 +
 +<code>
 +acceptsMarketing=true
 +
 +AND
 +
 +preferredChannel=EMAIL
 +</code>
 +
 +----
 +
 +===== Utilisation =====
 +
 +<code>
 +Campagnes CRM
 +
 +Marketing Automation
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.1-J ======
 +
 +===== Sécurité & RGPD =====
 +
 +----
 +
 +====== Étape 26 — Export ======
 +
 +===== Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +GDPR Export
 +
 +Data Portability
 +</code>
 +
 +----
 +
 +====== Étape 27 — Révocation ======
 +
 +===== Supporter =====
 +
 +<code>
 +Retrait consentement
 +
 +Opt-out
 +
 +Désinscription
 +</code>
 +
 +----
 +
 +====== Étape 28 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +customer.preferences.read
 +
 +customer.preferences.write
 +
 +customer.consent.manage
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 9 ======
 +
 +Compatible avec :
 +
 +<code>
 +Campaign
 +
 +MarketingSegment
 +
 +NotificationCenter
 +
 +CommunicationHub
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +Recommendation
 +
 +AiConversation
 +
 +AutomationScenario
 +
 +Customer Intelligence
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 19 ======
 +
 +Compatible avec :
 +
 +<code>
 +Consent
 +
 +ComplianceAudit
 +
 +RetentionPolicy
 +
 +DataClassification
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-H.1 est terminé lorsque :
 +
 +<code>
 +✓ CustomerPreference enrichi
 +
 +✓ CustomerPreferenceModule créé
 +
 +✓ CustomerPreferenceController créé
 +
 +✓ CustomerPreferenceService créé
 +
 +✓ Consentements RGPD
 +
 +✓ Personnalisation CRM
 +
 +✓ Historisation
 +
 +✓ AuditLog intégré
 +
 +✓ Swagger documenté
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +CustomerPreference Enterprise
 +
 +CustomerPreferenceModule
 +
 +CustomerPreferenceController
 +
 +CustomerPreferenceService
 +
 +Consent Management
 +
 +Preference Analytics
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2 — Centre de Préférences Enterprise & Consent Management ======
 +
 +===== Objectif =====
 +
 +Finaliser la couche CRM Enterprise de conformité et de gestion des consentements.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Consentements RGPD avancés
 +
 +✓ Historique complet
 +
 +✓ Double Opt-In
 +
 +✓ Centre omnicanal
 +
 +✓ Gestion abonnements
 +
 +✓ Portabilité des données
 +
 +✓ Droit à l'oubli
 +
 +✓ Audit de conformité
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +Customer
 +
 +
 +
 +Consent Center
 +
 +├── Marketing
 +├── Newsletter
 +├── SMS
 +├── WhatsApp
 +├── Push
 +├── Profilage
 +├── Analytics
 +└── Partage données
 +
 +
 +
 +Compliance
 +
 +
 +
 +GDPR
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-A ======
 +
 +===== Modèle RGPD =====
 +
 +----
 +
 +====== Étape 1 — Création Consent ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model Consent {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  customerId            String
 +
 +  consentType           ConsentType
 +
 +  status                ConsentStatus
 +
 +  source                ConsentSource
 +
 +  version               String
 +
 +  grantedAt             DateTime?
 +
 +  revokedAt             DateTime?
 +
 +  expiresAt             DateTime?
 +
 +  ipAddress             String?
 +
 +  userAgent             String?
 +
 +  proofReference        String?
 +
 +  metadata              Json?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  history               ConsentHistory[]
 +
 +  @@index([tenantId])
 +
 +  @@index([customerId])
 +
 +  @@index([consentType])
 +
 +  @@index([status])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — Historique ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model ConsentHistory {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  consentId             String
 +
 +  oldStatus             ConsentStatus?
 +
 +  newStatus             ConsentStatus
 +
 +  changedAt             DateTime
 +                        @default(now())
 +
 +  changedBy             String?
 +
 +  reason                String?
 +
 +  metadata              Json?
 +
 +  consent               Consent
 +                        @relation(
 +                          fields:[consentId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([consentId])
 +
 +  @@index([changedAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — Types ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum ConsentType {
 +
 +  MARKETING
 +
 +  NEWSLETTER
 +
 +  SMS
 +
 +  WHATSAPP
 +
 +  EMAIL
 +
 +  PROFILING
 +
 +  ANALYTICS
 +
 +  THIRD_PARTY_SHARING
 +
 +  PERSONALIZATION
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Status ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum ConsentStatus {
 +
 +  PENDING
 +
 +  GRANTED
 +
 +  REVOKED
 +
 +  EXPIRED
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Source ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum ConsentSource {
 +
 +  WEBSITE
 +
 +  CRM
 +
 +  API
 +
 +  IMPORT
 +
 +  MOBILE_APP
 +
 +  CUSTOMER_PORTAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 6 — Relation Customer ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +consents Consent[]
 +</code>
 +
 +dans :
 +
 +<code prisma>
 +model Customer
 +</code>
 +
 +----
 +
 +====== Étape 7 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name consent_management
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-B ======
 +
 +===== Double Opt-In =====
 +
 +----
 +
 +====== Étape 8 — Extension Consent ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +doubleOptInRequired    Boolean
 +                       @default(false)
 +
 +doubleOptInToken       String?
 +
 +doubleOptInSentAt      DateTime?
 +
 +doubleOptInConfirmedAt DateTime?
 +</code>
 +
 +----
 +
 +====== Étape 9 — Workflow ======
 +
 +<code>
 +Inscription
 +
 +
 +
 +Consentement
 +
 +
 +
 +Email confirmation
 +
 +
 +
 +Lien sécurisé
 +
 +
 +
 +Consentement actif
 +</code>
 +
 +----
 +
 +====== Étape 10 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +double-optin.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +generateToken()
 +
 +sendConfirmation()
 +
 +confirmConsent()
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-C ======
 +
 +===== Centre Omnicanal =====
 +
 +----
 +
 +====== Étape 11 — Subscription ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model CustomerSubscription {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  customerId            String
 +
 +  code                  String
 +
 +  name                  String
 +
 +  channel               PreferredChannel
 +
 +  subscribed            Boolean
 +                        @default(true)
 +
 +  subscribedAt          DateTime?
 +
 +  unsubscribedAt        DateTime?
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +
 +  @@index([customerId])
 +
 +  @@index([channel])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 12 — Types ======
 +
 +===== Exemples =====
 +
 +<code>
 +Newsletter
 +
 +Promotions
 +
 +Loyalty
 +
 +Product Updates
 +
 +Reservation Alerts
 +
 +Security Alerts
 +</code>
 +
 +----
 +
 +====== Étape 13 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /customers/{id}/subscriptions
 +
 +PUT /customers/{id}/subscriptions
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-D ======
 +
 +===== Consent Management Service =====
 +
 +----
 +
 +====== Étape 14 — Création ======
 +
 +<code>
 +consent-management.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +grantConsent()
 +
 +revokeConsent()
 +
 +expireConsent()
 +
 +recordProof()
 +
 +getConsentHistory()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Historisation ======
 +
 +===== Obligatoire =====
 +
 +Toute modification crée :
 +
 +<code>
 +ConsentHistory
 +</code>
 +
 +----
 +
 +====== Étape 16 — Vérification ======
 +
 +===== Avant envoi =====
 +
 +<code>
 +Email
 +
 +SMS
 +
 +WhatsApp
 +
 +Campagne
 +</code>
 +
 +----
 +
 +===== Vérifier =====
 +
 +<code>
 +Consent actif
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-E ======
 +
 +===== Portabilité des données =====
 +
 +----
 +
 +====== Étape 17 — Export GDPR ======
 +
 +===== Créer =====
 +
 +<code>
 +gdpr-export.service.ts
 +</code>
 +
 +----
 +
 +===== Agréger =====
 +
 +<code>
 +Customer
 +
 +Preferences
 +
 +Consents
 +
 +Communications
 +
 +Documents
 +
 +Notes
 +
 +Tags
 +
 +Reservations
 +</code>
 +
 +----
 +
 +====== Étape 18 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +POST /customers/{id}/gdpr/export
 +</code>
 +
 +----
 +
 +===== Formats =====
 +
 +<code>
 +JSON
 +
 +ZIP
 +
 +PDF
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-F ======
 +
 +===== Droit à l'oubli =====
 +
 +----
 +
 +====== Étape 19 — GDPR Erasure ======
 +
 +===== Créer =====
 +
 +<code>
 +gdpr-erasure.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +anonymizeCustomer()
 +
 +deletePersonalData()
 +
 +generateErasureReport()
 +</code>
 +
 +----
 +
 +====== Étape 20 — Workflow ======
 +
 +<code>
 +Demande
 +
 +
 +
 +Validation
 +
 +
 +
 +Anonymisation
 +
 +
 +
 +Rapport
 +
 +
 +
 +Audit
 +</code>
 +
 +----
 +
 +====== Étape 21 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +POST /customers/{id}/gdpr/erase
 +</code>
 +
 +----
 +
 +===== Anonymisation =====
 +
 +<code>
 +Email
 +
 +Téléphone
 +
 +Adresse
 +
 +Documents
 +
 +Métadonnées personnelles
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-G ======
 +
 +===== Centre de Préférences =====
 +
 +----
 +
 +====== Étape 22 — Endpoint public ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /preferences-center/{token}
 +
 +PUT /preferences-center/{token}
 +</code>
 +
 +----
 +
 +===== Permet =====
 +
 +<code>
 +Modifier préférences
 +
 +Modifier abonnements
 +
 +Retirer consentements
 +
 +Télécharger données
 +</code>
 +
 +----
 +
 +====== Étape 23 — Token sécurisé ======
 +
 +===== Ajouter =====
 +
 +<code>
 +JWT signé
 +
 +Expiration configurable
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-H ======
 +
 +===== Compliance Dashboard =====
 +
 +----
 +
 +====== Étape 24 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /compliance/consents/dashboard
 +</code>
 +
 +----
 +
 +===== KPI =====
 +
 +<code>
 +Total Consents
 +
 +Active Consents
 +
 +Revoked Consents
 +
 +Double Opt-In Pending
 +
 +Export Requests
 +
 +Erasure Requests
 +</code>
 +
 +----
 +
 +====== Étape 25 — Exemple ======
 +
 +<code json>
 +{
 +  "activeConsents":8421,
 +  "revokedConsents":213,
 +  "pendingDoubleOptIn":54
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-I ======
 +
 +===== Audit & Conformité =====
 +
 +----
 +
 +====== Étape 26 — AuditLog ======
 +
 +===== Ajouter =====
 +
 +<code>
 +CONSENT_GRANTED
 +
 +CONSENT_REVOKED
 +
 +DOUBLE_OPTIN_CONFIRMED
 +
 +GDPR_EXPORT_REQUESTED
 +
 +GDPR_ERASURE_REQUESTED
 +
 +GDPR_ERASURE_COMPLETED
 +</code>
 +
 +----
 +
 +====== Étape 27 — ComplianceAudit ======
 +
 +===== Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +Sprint 19
 +
 +ISO27001
 +
 +SOC2
 +
 +GDPR Audit
 +</code>
 +
 +----
 +
 +====== Étape 28 — RetentionPolicy ======
 +
 +===== Préparer =====
 +
 +Compatible avec :
 +
 +<code>
 +RetentionPolicy
 +
 +DataClassification
 +
 +SecurityIncident
 +</code>
 +
 +----
 +
 +====== Sprint 3-H.2-J ======
 +
 +===== Permissions =====
 +
 +----
 +
 +====== Étape 29 — Ajouter =====
 +
 +<code>
 +consents.read
 +
 +consents.write
 +
 +consents.manage
 +
 +gdpr.export
 +
 +gdpr.erase
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 9 ======
 +
 +Compatible avec :
 +
 +<code>
 +Campaign
 +
 +NotificationCenter
 +
 +CommunicationHub
 +
 +Marketing Automation
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 19 ======
 +
 +Compatible avec :
 +
 +<code>
 +Consent
 +
 +ComplianceAudit
 +
 +RetentionPolicy
 +
 +DataClassification
 +
 +SecurityPolicy
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise Governance
 +
 +Enterprise Compliance
 +
 +Privacy Center
 +
 +Customer Trust Dashboard
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-H.2 est terminé lorsque :
 +
 +<code>
 +✓ Consent créé
 +
 +✓ ConsentHistory créé
 +
 +✓ Double Opt-In
 +
 +✓ Centre omnicanal
 +
 +✓ Gestion abonnements
 +
 +✓ Portabilité données
 +
 +✓ Droit à l'oubli
 +
 +✓ Dashboard conformité
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +Consent
 +
 +ConsentHistory
 +
 +CustomerSubscription
 +
 +ConsentManagementService
 +
 +DoubleOptInService
 +
 +GdprExportService
 +
 +GdprErasureService
 +
 +Compliance Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1 — Recherche CRM Avancée ======
 +
 +===== Objectif =====
 +
 +Mettre en place un moteur de recherche CRM Enterprise capable de rechercher instantanément dans l'ensemble du domaine Client.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Recherche globale
 +
 +✓ Recherche plein texte
 +
 +✓ Recherche multicritères
 +
 +✓ Filtres avancés
 +
 +✓ Facettes
 +
 +✓ Recherches sauvegardées
 +
 +✓ CRM Search Engine
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +CRM Search API
 +
 +
 +
 +Search Engine
 +
 +├── Customers
 +├── Notes
 +├── Documents
 +├── Communications
 +├── Tags
 +├── Preferences
 +└── Reservations
 +
 +
 +
 +Filters Engine
 +
 +
 +
 +Facets Engine
 +
 +
 +
 +Saved Searches
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — SavedSearch ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model SavedSearch {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  name                  String
 +
 +  description           String?
 +
 +  entityType            SearchEntityType
 +
 +  query                 String?
 +
 +  filters               Json
 +
 +  isDefault             Boolean
 +                        @default(false)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  user                  User
 +                        @relation(
 +                          fields:[userId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([userId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — Search History ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model SearchHistory {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  query                 String
 +
 +  entityType            SearchEntityType?
 +
 +  resultCount           Int
 +                        @default(0)
 +
 +  executedAt            DateTime
 +                        @default(now())
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  user                  User
 +                        @relation(
 +                          fields:[userId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([userId])
 +
 +  @@index([executedAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — Enum ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum SearchEntityType {
 +
 +  CUSTOMER
 +
 +  NOTE
 +
 +  DOCUMENT
 +
 +  COMMUNICATION
 +
 +  TAG
 +
 +  RESERVATION
 +
 +  GLOBAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name crm_search_engine
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-B ======
 +
 +===== CRM Search Module =====
 +
 +----
 +
 +====== Étape 5 — Création ======
 +
 +<code>
 +src/modules/crm-search
 +
 +├── application
 +
 +│   └── dto
 +
 +│       ├── crm-search.dto.ts
 +
 +│       ├── facet-filter.dto.ts
 +
 +│       └── saved-search.dto.ts
 +
 +├── domain
 +
 +│   └── services
 +
 +│       ├── crm-search.service.ts
 +
 +│       ├── crm-facet.service.ts
 +
 +│       └── saved-search.service.ts
 +
 +├── presentation
 +
 +│   └── controllers
 +
 +│       └── crm-search.controller.ts
 +
 +└── crm-search.module.ts
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-C ======
 +
 +===== DTOs =====
 +
 +----
 +
 +====== Étape 6 — Recherche ======
 +
 +===== Créer =====
 +
 +<code>
 +crm-search.dto.ts
 +</code>
 +
 +----
 +
 +===== Ajouter =====
 +
 +<code ts>
 +export class CrmSearchDto {
 +
 +  q?: string;
 +
 +  entityType?: string;
 +
 +  page?: number = 1;
 +
 +  limit?: number = 25;
 +
 +  sortBy?: string;
 +
 +  sortOrder?: 'asc' | 'desc';
 +
 +  filters?: Record<
 +    string,
 +    unknown
 +  >;
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Filtres avancés ======
 +
 +===== Supporter =====
 +
 +<code>
 +Status
 +
 +Segment
 +
 +Tags
 +
 +Score
 +
 +Revenue
 +
 +Risk
 +
 +Country
 +
 +Language
 +
 +Consent
 +
 +Date
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-D ======
 +
 +===== Recherche Globale =====
 +
 +----
 +
 +====== Étape 8 — CrmSearchService ======
 +
 +===== Créer =====
 +
 +<code>
 +crm-search.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +globalSearch()
 +
 +searchCustomers()
 +
 +searchNotes()
 +
 +searchDocuments()
 +
 +searchCommunications()
 +</code>
 +
 +----
 +
 +====== Étape 9 — Recherche Clients ======
 +
 +===== Champs =====
 +
 +<code>
 +CustomerNumber
 +
 +FirstName
 +
 +LastName
 +
 +Email
 +
 +Phone
 +
 +CompanyName
 +</code>
 +
 +----
 +
 +===== Prisma =====
 +
 +<code ts>
 +OR: [
 +
 +  {
 +    firstName: {
 +      contains: q,
 +      mode: 'insensitive'
 +    }
 +  },
 +
 +  {
 +    lastName: {
 +      contains: q,
 +      mode: 'insensitive'
 +    }
 +  },
 +
 +  {
 +    email: {
 +      contains: q,
 +      mode: 'insensitive'
 +    }
 +  }
 +]
 +</code>
 +
 +----
 +
 +====== Étape 10 — Recherche Globale ======
 +
 +===== Agréger =====
 +
 +<code>
 +Customers
 +
 +Notes
 +
 +Documents
 +
 +Communications
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "customers": [],
 +  "notes": [],
 +  "documents": [],
 +  "communications": []
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-E ======
 +
 +===== Recherche Plein Texte =====
 +
 +----
 +
 +====== Étape 11 — PostgreSQL ======
 +
 +===== Ajouter =====
 +
 +Colonnes :
 +
 +<code>
 +title
 +
 +content
 +
 +subject
 +</code>
 +
 +----
 +
 +===== Utiliser =====
 +
 +<code sql>
 +tsvector
 +
 +tsquery
 +</code>
 +
 +----
 +
 +====== Étape 12 — Index ======
 +
 +===== Exemple =====
 +
 +<code sql>
 +CREATE INDEX idx_note_search
 +ON "CustomerNote"
 +USING GIN(
 +  to_tsvector(
 +    'simple',
 +    content
 +  )
 +);
 +</code>
 +
 +----
 +
 +====== Étape 13 — Recherche ======
 +
 +===== Exemple =====
 +
 +<code>
 +VIP facture
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +Notes
 +
 +Documents
 +
 +Emails concernés.
 +
 +----
 +
 +====== Sprint 3-I.1-F ======
 +
 +===== Recherche Multicritères =====
 +
 +----
 +
 +====== Étape 14 — Filtres combinés ======
 +
 +===== Exemple =====
 +
 +<code>
 +VIP
 +
 ++
 +
 +France
 +
 ++
 +
 +Revenue > 5000
 +
 ++
 +
 +Marketing = true
 +</code>
 +
 +----
 +
 +===== Prisma =====
 +
 +<code ts>
 +AND: [
 +  ...
 +]
 +</code>
 +
 +----
 +
 +====== Étape 15 — Support ======
 +
 +<code>
 +Equals
 +
 +Contains
 +
 +In
 +
 +Range
 +
 +Date
 +
 +Boolean
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-G ======
 +
 +===== Facettes CRM =====
 +
 +----
 +
 +====== Étape 16 — CrmFacetService ======
 +
 +===== Créer =====
 +
 +<code>
 +crm-facet.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +buildFacets()
 +
 +countSegments()
 +
 +countTags()
 +
 +countCountries()
 +</code>
 +
 +----
 +
 +====== Étape 17 — Facettes ======
 +
 +===== Exemple =====
 +
 +<code json>
 +{
 +  "segments": {
 +    "VIP": 41,
 +    "STANDARD": 381
 +  },
 +  "countries": {
 +    "FR": 250,
 +    "ES": 71
 +  }
 +}
 +</code>
 +
 +----
 +
 +====== Étape 18 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-search/facets
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-H ======
 +
 +===== Recherches Sauvegardées =====
 +
 +----
 +
 +====== Étape 19 — SavedSearchService ======
 +
 +===== Créer =====
 +
 +<code>
 +saved-search.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +createSearch()
 +
 +listSearches()
 +
 +deleteSearch()
 +
 +executeSavedSearch()
 +</code>
 +
 +----
 +
 +====== Étape 20 — Exemple ======
 +
 +===== Recherche =====
 +
 +<code>
 +VIP France
 +</code>
 +
 +----
 +
 +===== Sauvegarder =====
 +
 +<code>
 +Mes VIP France
 +</code>
 +
 +----
 +
 +====== Étape 21 — Endpoints ======
 +
 +<code http>
 +GET    /crm-search/saved
 +
 +POST   /crm-search/saved
 +
 +DELETE /crm-search/saved/{id}
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-I ======
 +
 +===== API Search =====
 +
 +----
 +
 +====== Étape 22 — Contrôleur ======
 +
 +===== Créer =====
 +
 +<code>
 +crm-search.controller.ts
 +</code>
 +
 +----
 +
 +====== Étape 23 — Endpoints ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-search
 +
 +GET /crm-search/global
 +
 +GET /crm-search/facets
 +
 +GET /crm-search/saved
 +
 +POST /crm-search/saved
 +
 +DELETE /crm-search/saved/{id}
 +</code>
 +
 +----
 +
 +====== Étape 24 — Exemple ======
 +
 +===== Requête =====
 +
 +<code http>
 +GET /crm-search/global?q=dupont
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "customers": 3,
 +  "notes": 5,
 +  "communications": 2
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.1-J ======
 +
 +===== Audit & Analytics =====
 +
 +----
 +
 +====== Étape 25 — Historique ======
 +
 +===== Créer =====
 +
 +<code>
 +SearchHistory
 +</code>
 +
 +automatiquement.
 +
 +----
 +
 +====== Étape 26 — AuditLog ======
 +
 +===== Journaliser =====
 +
 +<code>
 +CRM_SEARCH
 +
 +CRM_GLOBAL_SEARCH
 +
 +CRM_SAVED_SEARCH
 +
 +CRM_SEARCH_EXPORT
 +</code>
 +
 +----
 +
 +====== Étape 27 — KPI ======
 +
 +===== Endpoint =====
 +
 +<code http>
 +GET /crm-search/statistics
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "searchesToday":421,
 +  "savedSearches":82,
 +  "mostUsedFilter":"VIP"
 +}
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +Recommendation
 +
 +KnowledgeDocument
 +
 +AiConversation
 +
 +AutomationScenario
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 17 ======
 +
 +Compatible avec :
 +
 +<code>
 +RevenueForecast
 +
 +CustomerAnalytics
 +
 +Predictive Segmentation
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise Search
 +
 +Global Search
 +
 +Data Intelligence
 +
 +Enterprise Analytics
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-I.1 est terminé lorsque :
 +
 +<code>
 +✓ Recherche globale
 +
 +✓ Recherche plein texte
 +
 +✓ Recherche multicritères
 +
 +✓ Facettes CRM
 +
 +✓ Recherches sauvegardées
 +
 +✓ Historique recherches
 +
 +✓ Audit intégré
 +
 +✓ Swagger documenté
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +SavedSearch
 +
 +SearchHistory
 +
 +CrmSearchService
 +
 +CrmFacetService
 +
 +SavedSearchService
 +
 +CRM Search API
 +
 +Enterprise Search Engine
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2 — CRM Search Intelligence & Recommandations ======
 +
 +===== Objectif =====
 +
 +Faire évoluer le moteur CRM Search vers une plateforme de recherche intelligente assistée par IA.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Recherche sémantique
 +
 +✓ Suggestions intelligentes
 +
 +✓ Recherche IA
 +
 +✓ Résultats personnalisés
 +
 +✓ Recherche prédictive
 +
 +✓ Recommandations CRM
 +
 +✓ Search Intelligence Engine
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +User Query
 +
 +
 +
 +Search Intelligence Layer
 +
 +├── Full Text Search
 +├── Semantic Search
 +├── Predictive Search
 +├── Personalized Ranking
 +└── AI Recommendations
 +
 +
 +
 +CRM Knowledge Graph
 +
 +
 +
 +Results Engine
 +
 +
 +
 +Recommendations
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — SearchSuggestion ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model SearchSuggestion {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  query                 String
 +
 +  frequency             Int
 +                        @default(1)
 +
 +  lastUsedAt            DateTime
 +                        @default(now())
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  @@unique([
 +    tenantId,
 +    query
 +  ])
 +
 +  @@index([tenantId])
 +
 +  @@index([frequency])
 +
 +  @@index([lastUsedAt])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — SearchRecommendation ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model SearchRecommendation {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  userId                String
 +
 +  recommendationType    RecommendationType
 +
 +  entityType            SearchEntityType
 +
 +  entityId              String
 +
 +  score                 Float
 +
 +  reason                String?
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  expiresAt             DateTime?
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  user                  User
 +                        @relation(
 +                          fields:[userId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([userId])
 +
 +  @@index([score])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — RecommendationType ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum RecommendationType {
 +
 +  RECENT
 +
 +  FREQUENT
 +
 +  RELATED
 +
 +  PREDICTIVE
 +
 +  AI_GENERATED
 +
 +  BEHAVIOR_BASED
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name crm_search_ai
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-B ======
 +
 +===== Search Intelligence Module =====
 +
 +----
 +
 +====== Étape 5 — Création ======
 +
 +<code>
 +src/modules/search-intelligence
 +
 +├── semantic-search
 +
 +├── suggestions
 +
 +├── recommendations
 +
 +├── predictive-search
 +
 +├── ranking
 +
 +└── ai-search
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-C ======
 +
 +===== Recherche Sémantique =====
 +
 +----
 +
 +====== Étape 6 — SemanticSearchService ======
 +
 +===== Créer =====
 +
 +<code>
 +semantic-search.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +semanticSearch()
 +
 +findRelatedTerms()
 +
 +expandQuery()
 +</code>
 +
 +----
 +
 +====== Étape 7 — Synonymes CRM ======
 +
 +===== Exemples =====
 +
 +<code>
 +VIP
 +=
 +Premium
 +
 +Client
 +=
 +Customer
 +
 +Facture
 +=
 +Invoice
 +
 +Réservation
 +=
 +Booking
 +</code>
 +
 +----
 +
 +====== Étape 8 — Expansion ======
 +
 +===== Exemple =====
 +
 +<code>
 +Recherche :
 +"client premium"
 +</code>
 +
 +----
 +
 +===== Recherche réelle =====
 +
 +<code>
 +VIP
 +
 +Premium
 +
 +High Value
 +
 +Loyal Customer
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-D ======
 +
 +===== Suggestions Intelligentes =====
 +
 +----
 +
 +====== Étape 9 — SearchSuggestionService ======
 +
 +===== Créer =====
 +
 +<code>
 +search-suggestion.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +generateSuggestions()
 +
 +recordSearch()
 +
 +getPopularQueries()
 +</code>
 +
 +----
 +
 +====== Étape 10 — Suggestions ======
 +
 +===== Sources =====
 +
 +<code>
 +Historique utilisateur
 +
 +Historique tenant
 +
 +Popularité
 +
 +Fréquence
 +</code>
 +
 +----
 +
 +====== Étape 11 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-search/suggestions
 +</code>
 +
 +----
 +
 +===== Exemple =====
 +
 +<code>
 +vip
 +
 +vip france
 +
 +vip paris
 +
 +vip corporate
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-E ======
 +
 +===== Résultats Personnalisés =====
 +
 +----
 +
 +====== Étape 12 — PersonalizedRankingService ======
 +
 +===== Créer =====
 +
 +<code>
 +personalized-ranking.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +rankResults()
 +
 +applyUserPreferences()
 +
 +boostFrequentlyUsedEntities()
 +</code>
 +
 +----
 +
 +====== Étape 13 — Critères ======
 +
 +<code>
 +Historique utilisateur
 +
 +Segments favoris
 +
 +Clients récents
 +
 +Résultats utilisés
 +</code>
 +
 +----
 +
 +====== Étape 14 — Exemple ======
 +
 +===== Commercial =====
 +
 +<code>
 +VIP
 +
 +Leads
 +
 +Réservations
 +</code>
 +
 +plus visibles.
 +
 +----
 +
 +===== Finance =====
 +
 +<code>
 +Factures
 +
 +Paiements
 +
 +Contrats
 +</code>
 +
 +plus visibles.
 +
 +----
 +
 +====== Sprint 3-I.2-F ======
 +
 +===== Recherche Prédictive =====
 +
 +----
 +
 +====== Étape 15 — PredictiveSearchService ======
 +
 +===== Créer =====
 +
 +<code>
 +predictive-search.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +predictNextQueries()
 +
 +predictCustomerInterest()
 +
 +predictRelatedSearches()
 +</code>
 +
 +----
 +
 +====== Étape 16 — Exemples ======
 +
 +===== Recherche =====
 +
 +<code>
 +VIP France
 +</code>
 +
 +----
 +
 +===== Suggestions =====
 +
 +<code>
 +VIP Paris
 +
 +VIP Revenue > 10000
 +
 +VIP Loyalty
 +</code>
 +
 +----
 +
 +====== Étape 17 — Analyse ======
 +
 +===== Basée sur =====
 +
 +<code>
 +SearchHistory
 +
 +SavedSearch
 +
 +CustomerActivity
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-G ======
 +
 +===== Recommandations CRM =====
 +
 +----
 +
 +====== Étape 18 — SearchRecommendationService ======
 +
 +===== Créer =====
 +
 +<code>
 +search-recommendation.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +generateRecommendations()
 +
 +recommendCustomers()
 +
 +recommendSegments()
 +
 +recommendActions()
 +</code>
 +
 +----
 +
 +====== Étape 19 — Exemples ======
 +
 +===== Recommandation =====
 +
 +<code>
 +23 clients
 +
 +à risque
 +
 +non contactés
 +</code>
 +
 +----
 +
 +===== Recommandation =====
 +
 +<code>
 +12 VIP
 +
 +sans campagne active
 +</code>
 +
 +----
 +
 +====== Étape 20 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-search/recommendations
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-H ======
 +
 +===== Recherche IA =====
 +
 +----
 +
 +====== Étape 21 — AI Search Service ======
 +
 +===== Créer =====
 +
 +<code>
 +ai-search.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +naturalLanguageSearch()
 +
 +explainResults()
 +
 +generateInsights()
 +</code>
 +
 +----
 +
 +====== Étape 22 — Exemples ======
 +
 +===== Requête =====
 +
 +<code>
 +Montre-moi les clients VIP
 +qui n'ont pas été contactés
 +depuis 90 jours.
 +</code>
 +
 +----
 +
 +===== Traduction =====
 +
 +<code>
 +Segment=VIP
 +
 +AND
 +
 +LastCommunication < 90 jours
 +</code>
 +
 +----
 +
 +====== Étape 23 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +POST /crm-search/ai
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-I ======
 +
 +===== Dashboard Search Intelligence =====
 +
 +----
 +
 +====== Étape 24 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-search/intelligence/dashboard
 +</code>
 +
 +----
 +
 +===== KPI =====
 +
 +<code>
 +Top recherches
 +
 +Suggestions utilisées
 +
 +Recherche IA
 +
 +Taux de clic
 +
 +Recommandations générées
 +</code>
 +
 +----
 +
 +====== Étape 25 — Exemple ======
 +
 +<code json>
 +{
 +  "topSearch":"VIP",
 +  "aiSearches":128,
 +  "recommendations":342
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-I.2-J ======
 +
 +===== Audit & Gouvernance =====
 +
 +----
 +
 +====== Étape 26 — AuditLog ======
 +
 +===== Journaliser =====
 +
 +<code>
 +SEMANTIC_SEARCH
 +
 +AI_SEARCH
 +
 +SEARCH_RECOMMENDATION
 +
 +SEARCH_SUGGESTION_SELECTED
 +
 +PREDICTIVE_SEARCH
 +</code>
 +
 +----
 +
 +====== Étape 27 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +crm.search.ai
 +
 +crm.search.recommendations
 +
 +crm.search.analytics
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +AiConversation
 +
 +KnowledgeGraph
 +
 +RecommendationEngine
 +
 +AutomationScenario
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 17 ======
 +
 +Compatible avec :
 +
 +<code>
 +RevenueForecast
 +
 +CustomerAnalytics
 +
 +PredictiveCRM
 +
 +BusinessIntelligence
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise AI
 +
 +Search Intelligence
 +
 +Enterprise Knowledge
 +
 +Decision Support System
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-I.2 est terminé lorsque :
 +
 +<code>
 +✓ Recherche sémantique
 +
 +✓ Suggestions intelligentes
 +
 +✓ Recherche IA
 +
 +✓ Résultats personnalisés
 +
 +✓ Recherche prédictive
 +
 +✓ Recommandations CRM
 +
 +✓ Dashboard Search Intelligence
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +SearchSuggestion
 +
 +SearchRecommendation
 +
 +SemanticSearchService
 +
 +PredictiveSearchService
 +
 +AISearchService
 +
 +SearchRecommendationService
 +
 +Search Intelligence Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1 — CRM Analytics & Tableau de Bord ======
 +
 +===== Objectif =====
 +
 +Construire le premier cockpit CRM Enterprise centralisant l'ensemble des indicateurs stratégiques.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ KPI CRM
 +
 +✓ Customer Dashboard
 +
 +✓ Segmentation Analytics
 +
 +✓ Communication Analytics
 +
 +✓ Conversion Analytics
 +
 +✓ Revenue Analytics
 +
 +✓ Executive Dashboard
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +CRM Analytics
 +
 +
 +
 +Analytics Engine
 +
 +├── Customers
 +├── Segments
 +├── Communications
 +├── Revenue
 +├── Conversion
 +└── Loyalty
 +
 +
 +
 +Dashboard API
 +
 +
 +
 +Frontend Cockpit
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — Dashboard Snapshot ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model DashboardSnapshot {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  snapshotDate          DateTime
 +
 +  metrics               Json
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  @@unique([
 +    tenantId,
 +    snapshotDate
 +  ])
 +
 +  @@index([tenantId])
 +
 +  @@index([snapshotDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — KPI Definition ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model KpiDefinition {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  code                  String
 +
 +  name                  String
 +
 +  description           String?
 +
 +  category              String
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  updatedAt             DateTime
 +                        @updatedAt
 +
 +  @@unique([
 +    tenantId,
 +    code
 +  ])
 +
 +  @@index([tenantId])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name crm_analytics_dashboard
 +</code>
 +
 +----
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma generate
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-B ======
 +
 +===== CRM Analytics Module =====
 +
 +----
 +
 +====== Étape 4 — Création ======
 +
 +<code>
 +src/modules/crm-analytics
 +
 +├── application
 +
 +│   └── dto
 +
 +├── domain
 +
 +│   └── services
 +
 +│       ├── crm-dashboard.service.ts
 +
 +│       ├── customer-analytics.service.ts
 +
 +│       ├── communication-analytics.service.ts
 +
 +│       ├── segmentation-analytics.service.ts
 +
 +│       ├── conversion-analytics.service.ts
 +
 +│       └── revenue-analytics.service.ts
 +
 +├── presentation
 +
 +│   └── controllers
 +
 +│       └── crm-analytics.controller.ts
 +
 +└── crm-analytics.module.ts
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-C ======
 +
 +===== KPI CRM =====
 +
 +----
 +
 +====== Étape 5 — KPI Principaux ======
 +
 +===== Calculer =====
 +
 +<code>
 +Nombre clients
 +
 +Clients actifs
 +
 +Clients inactifs
 +
 +VIP
 +
 +Nouveaux clients
 +
 +Clients à risque
 +</code>
 +
 +----
 +
 +====== Étape 6 — Customer KPI ======
 +
 +===== Exemple =====
 +
 +<code json>
 +{
 +  "totalCustomers": 12584,
 +  "activeCustomers": 10874,
 +  "inactiveCustomers": 1710,
 +  "vipCustomers": 524
 +}
 +</code>
 +
 +----
 +
 +====== Étape 7 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +getCustomerKpis()
 +
 +getGrowthRate()
 +
 +getCustomerHealth()
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-D ======
 +
 +===== Customer Dashboard =====
 +
 +----
 +
 +====== Étape 8 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/dashboard
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "customers": {},
 +  "communications": {},
 +  "revenue": {},
 +  "segments": {}
 +}
 +</code>
 +
 +----
 +
 +====== Étape 9 — Widgets ======
 +
 +===== Ajouter =====
 +
 +<code>
 +Top clients
 +
 +Derniers clients
 +
 +Clients à risque
 +
 +Clients VIP
 +
 +Croissance
 +</code>
 +
 +----
 +
 +====== Étape 10 — Exemple ======
 +
 +<code json>
 +{
 +  "topCustomers": [],
 +  "vipCustomers": [],
 +  "riskCustomers": []
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-E ======
 +
 +===== Segmentation Analytics =====
 +
 +----
 +
 +====== Étape 11 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +segmentation-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +getSegmentDistribution()
 +
 +getSegmentGrowth()
 +
 +getSegmentRevenue()
 +</code>
 +
 +----
 +
 +====== Étape 12 — KPI ======
 +
 +===== Répartition =====
 +
 +<code>
 +VIP
 +
 +Corporate
 +
 +Loyal
 +
 +High Value
 +
 +Standard
 +
 +At Risk
 +</code>
 +
 +----
 +
 +====== Étape 13 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/segments
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "VIP": 412,
 +  "LOYAL": 1832,
 +  "CORPORATE": 94
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-F ======
 +
 +===== Communication Analytics =====
 +
 +----
 +
 +====== Étape 14 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +communication-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +getCommunicationStats()
 +
 +getOpenRate()
 +
 +getReplyRate()
 +
 +getChannelPerformance()
 +</code>
 +
 +----
 +
 +====== Étape 15 — KPI ======
 +
 +===== Calculer =====
 +
 +<code>
 +Emails envoyés
 +
 +Emails ouverts
 +
 +SMS envoyés
 +
 +SMS délivrés
 +
 +WhatsApp envoyés
 +
 +Réponses
 +</code>
 +
 +----
 +
 +====== Étape 16 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/communications
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "emailOpenRate": 68.4,
 +  "replyRate": 17.2,
 +  "smsDeliveryRate": 95.8
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-G ======
 +
 +===== Conversion Analytics =====
 +
 +----
 +
 +====== Étape 17 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +conversion-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +getConversionRate()
 +
 +getLeadConversion()
 +
 +getCampaignConversion()
 +</code>
 +
 +----
 +
 +====== Étape 18 — KPI ======
 +
 +===== Exemple =====
 +
 +<code>
 +Client créé
 +
 +
 +
 +Premier achat
 +
 +
 +
 +Client fidèle
 +</code>
 +
 +----
 +
 +====== Étape 19 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/conversions
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "leadConversion": 22.3,
 +  "repeatCustomerRate": 38.1
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-H ======
 +
 +===== Revenue Analytics =====
 +
 +----
 +
 +====== Étape 20 — Service ======
 +
 +===== Créer =====
 +
 +<code>
 +revenue-analytics.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +getRevenueMetrics()
 +
 +getLifetimeValue()
 +
 +getAverageBasket()
 +
 +getRevenueBySegment()
 +</code>
 +
 +----
 +
 +====== Étape 21 — KPI ======
 +
 +===== Calculer =====
 +
 +<code>
 +Revenue total
 +
 +MRR CRM
 +
 +Lifetime Value
 +
 +Average Basket
 +
 +Revenue Segment
 +</code>
 +
 +----
 +
 +====== Étape 22 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/revenue
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "revenue": 1542870,
 +  "averageBasket": 382,
 +  "averageLtv": 4120
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-I ======
 +
 +===== Dashboard Exécutif =====
 +
 +----
 +
 +====== Étape 23 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/executive
 +</code>
 +
 +----
 +
 +===== KPI Stratégiques =====
 +
 +<code>
 +Croissance clients
 +
 +Croissance revenu
 +
 +VIP
 +
 +Attrition
 +
 +Satisfaction
 +
 +Engagement
 +</code>
 +
 +----
 +
 +====== Étape 24 — Snapshot ======
 +
 +===== Générer =====
 +
 +Tous les jours :
 +
 +<code>
 +DashboardSnapshot
 +</code>
 +
 +----
 +
 +===== Utilisation =====
 +
 +<code>
 +Historique
 +
 +Tendances
 +
 +Comparaisons
 +</code>
 +
 +----
 +
 +====== Étape 25 — Comparaison ======
 +
 +===== Exemple =====
 +
 +<code json>
 +{
 +  "customersGrowth": 12.4,
 +  "revenueGrowth": 18.7
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.1-J ======
 +
 +===== Audit & Gouvernance =====
 +
 +----
 +
 +====== Étape 26 — AuditLog ======
 +
 +===== Journaliser =====
 +
 +<code>
 +CRM_DASHBOARD_VIEW
 +
 +CRM_ANALYTICS_VIEW
 +
 +CRM_REVENUE_ANALYTICS
 +
 +CRM_SEGMENT_ANALYTICS
 +
 +CRM_EXPORT_ANALYTICS
 +</code>
 +
 +----
 +
 +====== Étape 27 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +crm.analytics.read
 +
 +crm.analytics.export
 +
 +crm.analytics.executive
 +</code>
 +
 +----
 +
 +====== Étape 28 — Export ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-analytics/export
 +</code>
 +
 +----
 +
 +===== Formats =====
 +
 +<code>
 +CSV
 +
 +XLSX
 +
 +PDF
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 13 ======
 +
 +Compatible avec :
 +
 +<code>
 +RecommendationEngine
 +
 +AiInsights
 +
 +Forecasting
 +
 +Business Intelligence
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 17 ======
 +
 +Compatible avec :
 +
 +<code>
 +Revenue Forecast
 +
 +Customer Forecast
 +
 +Predictive Analytics
 +
 +Financial Analytics
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Executive Cockpit
 +
 +Enterprise BI
 +
 +Enterprise Analytics
 +
 +Data Warehouse
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-J.1 est terminé lorsque :
 +
 +<code>
 +✓ KPI CRM
 +
 +✓ Customer Dashboard
 +
 +✓ Segmentation Analytics
 +
 +✓ Communication Analytics
 +
 +✓ Conversion Analytics
 +
 +✓ Revenue Analytics
 +
 +✓ Dashboard exécutif
 +
 +✓ Export Analytics
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +DashboardSnapshot
 +
 +KpiDefinition
 +
 +CrmDashboardService
 +
 +CustomerAnalyticsService
 +
 +CommunicationAnalyticsService
 +
 +ConversionAnalyticsService
 +
 +RevenueAnalyticsService
 +
 +Executive Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2 — CRM Intelligence & Analytics Prédictifs ======
 +
 +===== Objectif =====
 +
 +Finaliser le CRM Enterprise en ajoutant une couche complète d'intelligence prédictive.
 +
 +À l'issue de cette étape :
 +
 +<code>
 +✓ Prévision revenus
 +
 +✓ Prévision churn
 +
 +✓ Prévision LTV
 +
 +✓ Détection opportunités
 +
 +✓ Détection anomalies
 +
 +✓ Insights IA
 +
 +✓ Score santé client
 +
 +✓ CRM Intelligence Platform
 +</code>
 +
 +----
 +
 +====== Architecture cible ======
 +
 +<code>
 +CRM Data
 +
 +
 +
 +Analytics Engine
 +
 +
 +
 +Prediction Engine
 +
 +├── Revenue Forecast
 +├── Churn Prediction
 +├── LTV Prediction
 +├── Opportunity Detection
 +├── Anomaly Detection
 +└── Customer Health
 +
 +
 +
 +AI Insights
 +
 +
 +
 +Executive Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-A ======
 +
 +===== Extension Prisma =====
 +
 +----
 +
 +====== Étape 1 — CustomerHealth ======
 +
 +===== Ajouter dans schema.prisma =====
 +
 +<code prisma>
 +model CustomerHealth {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  customerId            String
 +                        @unique
 +
 +  overallScore          Int
 +                        @default(0)
 +
 +  engagementScore       Int
 +                        @default(0)
 +
 +  loyaltyScore          Int
 +                        @default(0)
 +
 +  satisfactionScore     Int
 +                        @default(0)
 +
 +  communicationScore    Int
 +                        @default(0)
 +
 +  revenueScore          Int
 +                        @default(0)
 +
 +  churnRiskScore        Int
 +                        @default(0)
 +
 +  lastCalculatedAt      DateTime
 +                        @default(now())
 +
 +  customer              Customer
 +                        @relation(
 +                          fields:[customerId],
 +                          references:[id],
 +                          onDelete:Cascade
 +                        )
 +}
 +</code>
 +
 +----
 +
 +====== Étape 2 — PredictionSnapshot ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model PredictionSnapshot {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  predictionType        PredictionType
 +
 +  snapshotDate          DateTime
 +
 +  result                Json
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  tenant                Tenant
 +                        @relation(
 +                          fields:[tenantId],
 +                          references:[id]
 +                        )
 +
 +  @@index([tenantId])
 +
 +  @@index([predictionType])
 +
 +  @@index([snapshotDate])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 3 — AI Insight ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +model AiInsight {
 +
 +  id                    String
 +                        @id
 +                        @default(uuid())
 +
 +  tenantId              String
 +
 +  category              InsightCategory
 +
 +  severity              InsightSeverity
 +
 +  title                 String
 +
 +  description           String
 +
 +  recommendation        String?
 +
 +  entityType            String?
 +
 +  entityId              String?
 +
 +  active                Boolean
 +                        @default(true)
 +
 +  createdAt             DateTime
 +                        @default(now())
 +
 +  expiresAt             DateTime?
 +
 +  @@index([tenantId])
 +
 +  @@index([category])
 +
 +  @@index([severity])
 +
 +  @@index([active])
 +}
 +</code>
 +
 +----
 +
 +====== Étape 4 — Enums ======
 +
 +===== Ajouter =====
 +
 +<code prisma>
 +enum PredictionType {
 +
 +  REVENUE
 +
 +  CHURN
 +
 +  LTV
 +
 +  OPPORTUNITY
 +
 +  CUSTOMER_HEALTH
 +}
 +
 +enum InsightCategory {
 +
 +  REVENUE
 +
 +  CHURN
 +
 +  CUSTOMER
 +
 +  SEGMENT
 +
 +  COMMUNICATION
 +
 +  MARKETING
 +}
 +
 +enum InsightSeverity {
 +
 +  LOW
 +
 +  MEDIUM
 +
 +  HIGH
 +
 +  CRITICAL
 +}
 +</code>
 +
 +----
 +
 +====== Étape 5 — Migration ======
 +
 +===== Générer =====
 +
 +<code bash>
 +npx prisma migrate dev \
 +--name crm_predictive_intelligence
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-B ======
 +
 +===== CRM Intelligence Module =====
 +
 +----
 +
 +====== Étape 6 — Création ======
 +
 +<code>
 +src/modules/crm-intelligence
 +
 +├── revenue-forecast
 +
 +├── churn-prediction
 +
 +├── ltv-prediction
 +
 +├── opportunity-detection
 +
 +├── anomaly-detection
 +
 +├── ai-insights
 +
 +├── customer-health
 +
 +└── dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-C ======
 +
 +===== Prévision Revenus =====
 +
 +----
 +
 +====== Étape 7 — RevenueForecastService ======
 +
 +===== Créer =====
 +
 +<code>
 +revenue-forecast.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +forecastRevenue()
 +
 +forecastSegmentRevenue()
 +
 +forecastCustomerRevenue()
 +</code>
 +
 +----
 +
 +====== Étape 8 — Sources ======
 +
 +<code>
 +Invoices
 +
 +Reservations
 +
 +Customer LTV
 +
 +Customer Score
 +
 +Segments
 +</code>
 +
 +----
 +
 +====== Étape 9 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/revenue-forecast
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "nextMonth": 152000,
 +  "nextQuarter": 487000,
 +  "confidence": 0.84
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-D ======
 +
 +===== Prévision Churn =====
 +
 +----
 +
 +====== Étape 10 — ChurnPredictionService ======
 +
 +===== Créer =====
 +
 +<code>
 +churn-prediction.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +calculateChurnRisk()
 +
 +predictChurn()
 +
 +detectInactiveCustomers()
 +</code>
 +
 +----
 +
 +====== Étape 11 — Critères ======
 +
 +<code>
 +Dernière activité
 +
 +Dernière communication
 +
 +Baisse dépenses
 +
 +Baisse engagement
 +
 +Réclamations
 +</code>
 +
 +----
 +
 +====== Étape 12 — Classification ======
 +
 +<code>
 +LOW
 +
 +MEDIUM
 +
 +HIGH
 +
 +CRITICAL
 +</code>
 +
 +----
 +
 +====== Étape 13 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/churn
 +</code>
 +
 +----
 +
 +===== Exemple =====
 +
 +<code json>
 +{
 +  "highRiskCustomers": 42,
 +  "criticalCustomers": 8
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-E ======
 +
 +===== Prévision LTV =====
 +
 +----
 +
 +====== Étape 14 — LtvPredictionService ======
 +
 +===== Créer =====
 +
 +<code>
 +ltv-prediction.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +predictLifetimeValue()
 +
 +predictVipCustomers()
 +
 +estimateFutureRevenue()
 +</code>
 +
 +----
 +
 +====== Étape 15 — Facteurs ======
 +
 +<code>
 +Historique achats
 +
 +Segments
 +
 +Fidélité
 +
 +Engagement
 +
 +Communication
 +</code>
 +
 +----
 +
 +====== Étape 16 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/ltv
 +</code>
 +
 +----
 +
 +===== Retour =====
 +
 +<code json>
 +{
 +  "averagePredictedLtv": 5420,
 +  "futureVipCustomers": 73
 +}
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-F ======
 +
 +===== Détection Opportunités =====
 +
 +----
 +
 +====== Étape 17 — OpportunityDetectionService ======
 +
 +===== Créer =====
 +
 +<code>
 +opportunity-detection.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +findUpsellOpportunities()
 +
 +findCrossSellOpportunities()
 +
 +findRetentionActions()
 +</code>
 +
 +----
 +
 +====== Étape 18 — Exemples ======
 +
 +<code>
 +VIP
 +
 +sans offre premium
 +
 +
 +
 +Upsell
 +</code>
 +
 +----
 +
 +<code>
 +Corporate
 +
 +sans programme fidélité
 +
 +
 +
 +Cross-sell
 +</code>
 +
 +----
 +
 +====== Étape 19 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/opportunities
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-G ======
 +
 +===== Détection d'Anomalies =====
 +
 +----
 +
 +====== Étape 20 — AnomalyDetectionService ======
 +
 +===== Créer =====
 +
 +<code>
 +anomaly-detection.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +detectRevenueAnomalies()
 +
 +detectBehaviorAnomalies()
 +
 +detectCommunicationAnomalies()
 +</code>
 +
 +----
 +
 +====== Étape 21 — Exemples ======
 +
 +<code>
 +Baisse revenu
 +
 +-45%
 +
 +
 +
 +Anomalie
 +</code>
 +
 +----
 +
 +<code>
 +Ouvertures emails
 +
 +0%
 +
 +
 +
 +Alerte
 +</code>
 +
 +----
 +
 +====== Étape 22 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/anomalies
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-H ======
 +
 +===== Score Santé Client =====
 +
 +----
 +
 +====== Étape 23 — CustomerHealthService ======
 +
 +===== Créer =====
 +
 +<code>
 +customer-health.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +calculateHealthScore()
 +
 +updateHealthScores()
 +
 +getHealthDistribution()
 +</code>
 +
 +----
 +
 +====== Étape 24 — Calcul ======
 +
 +===== Pondérations =====
 +
 +<code>
 +Engagement       20%
 +
 +Communication   15%
 +
 +Loyalty         20%
 +
 +Revenue         20%
 +
 +Satisfaction    15%
 +
 +Churn Risk      10%
 +</code>
 +
 +----
 +
 +====== Étape 25 — Classification ======
 +
 +<code>
 +90-100 Excellent
 +
 +75-89 Healthy
 +
 +50-74 Attention
 +
 +0-49 Critical
 +</code>
 +
 +----
 +
 +====== Étape 26 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/health
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-I ======
 +
 +===== AI Insights =====
 +
 +----
 +
 +====== Étape 27 — AiInsightService ======
 +
 +===== Créer =====
 +
 +<code>
 +ai-insight.service.ts
 +</code>
 +
 +----
 +
 +===== Méthodes =====
 +
 +<code ts>
 +generateInsights()
 +
 +generateRecommendations()
 +
 +prioritizeActions()
 +</code>
 +
 +----
 +
 +====== Étape 28 — Exemples ======
 +
 +===== Insight =====
 +
 +<code>
 +23 VIP
 +
 +sans contact
 +
 +depuis 60 jours
 +</code>
 +
 +----
 +
 +===== Recommandation =====
 +
 +<code>
 +Créer campagne VIP
 +</code>
 +
 +----
 +
 +===== Insight =====
 +
 +<code>
 +Segment Corporate
 +
 ++18% revenu
 +
 +ce mois-ci
 +</code>
 +
 +----
 +
 +====== Étape 29 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/insights
 +</code>
 +
 +----
 +
 +====== Sprint 3-J.2-J ======
 +
 +===== Cockpit CRM Intelligence =====
 +
 +----
 +
 +====== Étape 30 — Endpoint ======
 +
 +===== Ajouter =====
 +
 +<code http>
 +GET /crm-intelligence/dashboard
 +</code>
 +
 +----
 +
 +===== Agrège =====
 +
 +<code>
 +Forecast Revenue
 +
 +Churn
 +
 +LTV
 +
 +Health
 +
 +Opportunities
 +
 +Insights
 +</code>
 +
 +----
 +
 +====== Étape 31 — Exemple ======
 +
 +<code json>
 +{
 +  "forecastRevenue": 487000,
 +  "highRiskCustomers": 42,
 +  "futureVipCustomers": 73,
 +  "opportunities": 118,
 +  "insights": 14
 +}
 +</code>
 +
 +----
 +
 +====== Étape 32 — AuditLog ======
 +
 +===== Journaliser =====
 +
 +<code>
 +CRM_FORECAST_GENERATED
 +
 +CRM_CHURN_ANALYSIS
 +
 +CRM_LTV_PREDICTION
 +
 +CRM_ANOMALY_DETECTED
 +
 +CRM_AI_INSIGHT_GENERATED
 +</code>
 +
 +----
 +
 +====== Étape 33 — Permissions ======
 +
 +===== Ajouter =====
 +
 +<code>
 +crm.intelligence.read
 +
 +crm.intelligence.forecast
 +
 +crm.intelligence.insights
 +
 +crm.intelligence.executive
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 17 ======
 +
 +Compatible avec :
 +
 +<code>
 +Forecast Engine
 +
 +Revenue Planning
 +
 +Financial Intelligence
 +
 +Business Intelligence
 +</code>
 +
 +----
 +
 +====== Préparation Sprint 20 ======
 +
 +Compatible avec :
 +
 +<code>
 +Enterprise AI
 +
 +Executive Intelligence
 +
 +Decision Support
 +
 +Predictive Analytics
 +
 +Enterprise BI
 +</code>
 +
 +----
 +
 +====== Définition de terminé ======
 +
 +Le Sprint 3-J.2 est terminé lorsque :
 +
 +<code>
 +✓ Revenue Forecast
 +
 +✓ Churn Prediction
 +
 +✓ LTV Prediction
 +
 +✓ Opportunity Detection
 +
 +✓ Anomaly Detection
 +
 +✓ Customer Health Score
 +
 +✓ AI Insights
 +
 +✓ CRM Intelligence Dashboard
 +
 +✓ Audit intégré
 +</code>
 +
 +----
 +
 +====== Livrables ======
 +
 +<code>
 +CustomerHealth
 +
 +PredictionSnapshot
 +
 +AiInsight
 +
 +RevenueForecastService
 +
 +ChurnPredictionService
 +
 +LtvPredictionService
 +
 +OpportunityDetectionService
 +
 +AnomalyDetectionService
 +
 +CustomerHealthService
 +
 +AiInsightService
 +
 +CRM Intelligence Dashboard
 +</code>
 +
 +----
 +
 +====== Sprint 3 — Gestion des Clients TERMINÉ ======
 +
 +===== Domaines CRM Livrés =====
 +
 +<code>
 +✓ Customer
 +
 +✓ CustomerAddress
 +
 +✓ CustomerDocument
 +
 +✓ CustomerTag
 +
 +✓ CustomerNote
 +
 +✓ CustomerCommunication
 +
 +✓ CustomerPreference
 +
 +✓ Consent Management
 +
 +✓ CRM Search
 +
 +✓ CRM Analytics
 +
 +✓ CRM Intelligence
 </code> </code>
  
ujusum/3-codage/2-sprints/3-sprint-3.1781050774.txt.gz · Dernière modification : 2026/06/10 02:19 de 83.202.252.200

DokuWiki Appliance - Powered by TurnKey Linux