====== Sprint 8-A.1 — Marketing Core & Campaign Management ======
===== Objectif =====
Construire la plateforme marketing omnicanale Enterprise.
Cette couche permet :
Campagnes
Segmentation
Templates
Automatisation
Exécution
Tracking
afin d'orchestrer les communications clients à grande échelle.
À l'issue de cette étape :
✓ Campaign
✓ CampaignAudience
✓ CampaignTemplate
✓ CampaignExecution
✓ CampaignTracking
✓ MarketingDashboard
✓ Marketing Platform Core
----
====== Architecture cible ======
CRM
↓
Marketing Platform
├── Campaign Management
├── Audience Engine
├── Template Engine
├── Campaign Execution
├── Tracking & Attribution
└── Marketing Dashboard
↓
Email
SMS
WhatsApp
Push
In-App
----
====== Sprint 8-A.1-A ======
===== Extension Prisma =====
----
====== Étape 1 — Campaign ======
===== Ajouter dans schema.prisma =====
model Campaign {
id String
@id
@default(uuid())
tenantId String
name String
description String?
type CampaignType
status CampaignStatus
startDate DateTime?
endDate DateTime?
budget Decimal?
@db.Decimal(14,2)
createdBy String
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
audiences CampaignAudience[]
executions CampaignExecution[]
@@index([tenantId])
@@index([status])
@@index([type])
}
----
====== Étape 2 — CampaignAudience ======
===== Ajouter =====
model CampaignAudience {
id String
@id
@default(uuid())
campaignId String
name String
audienceType AudienceType
segmentQuery Json?
estimatedSize Int?
createdAt DateTime
@default(now())
campaign Campaign
@relation(
fields:[campaignId],
references:[id],
onDelete:Cascade
)
@@index([campaignId])
}
----
====== Étape 3 — CampaignTemplate ======
===== Ajouter =====
model CampaignTemplate {
id String
@id
@default(uuid())
tenantId String
name String
channel MarketingChannel
subject String?
content Json
active Boolean
@default(true)
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
@@index([tenantId])
@@index([channel])
}
----
====== Étape 4 — CampaignExecution ======
===== Ajouter =====
model CampaignExecution {
id String
@id
@default(uuid())
campaignId String
channel MarketingChannel
executionStatus ExecutionStatus
scheduledAt DateTime?
startedAt DateTime?
completedAt DateTime?
targetedRecipients Int
@default(0)
deliveredRecipients Int
@default(0)
failedRecipients Int
@default(0)
campaign Campaign
@relation(
fields:[campaignId],
references:[id],
onDelete:Cascade
)
@@index([campaignId])
@@index([executionStatus])
}
----
====== Étape 5 — CampaignTracking ======
===== Ajouter =====
model CampaignTracking {
id String
@id
@default(uuid())
campaignId String
customerId String?
channel MarketingChannel
eventType CampaignEventType
eventDate DateTime
@default(now())
metadata Json?
@@index([campaignId])
@@index([customerId])
@@index([eventType])
}
----
====== Étape 6 — MarketingDashboardSnapshot ======
===== Ajouter =====
model MarketingDashboardSnapshot {
id String
@id
@default(uuid())
tenantId String
snapshotDate DateTime
campaignsCount Int
deliveredCount Int
openedCount Int
clickedCount Int
conversionCount Int
revenueAttributed Decimal?
@db.Decimal(14,2)
createdAt DateTime
@default(now())
@@index([tenantId])
@@index([snapshotDate])
}
----
====== Étape 7 — Enums ======
===== Ajouter =====
enum CampaignType {
PROMOTIONAL
TRANSACTIONAL
LOYALTY
RETENTION
REACTIVATION
NEWSLETTER
}
enum CampaignStatus {
DRAFT
SCHEDULED
RUNNING
COMPLETED
CANCELLED
}
enum AudienceType {
STATIC
DYNAMIC
SMART_SEGMENT
}
enum MarketingChannel {
EMAIL
SMS
WHATSAPP
PUSH
IN_APP
}
enum ExecutionStatus {
PENDING
RUNNING
COMPLETED
FAILED
CANCELLED
}
enum CampaignEventType {
SENT
DELIVERED
OPENED
CLICKED
CONVERTED
UNSUBSCRIBED
}
----
====== Étape 8 — Migration ======
npx prisma migrate dev \
--name marketing_core
----
====== Sprint 8-A.1-B ======
===== Marketing Module =====
----
====== Étape 9 — Structure ======
src/modules/marketing
├── campaigns
├── audiences
├── templates
├── execution
├── tracking
├── dashboard
└── marketing.module.ts
----
====== Étape 10 — Services ======
CampaignService
CampaignAudienceService
CampaignTemplateService
CampaignExecutionService
CampaignTrackingService
MarketingDashboardService
----
====== Sprint 8-A.1-C ======
===== Gestion des Campagnes =====
----
====== Étape 11 — CampaignService ======
===== Créer =====
campaign.service.ts
----
===== Méthodes =====
createCampaign()
updateCampaign()
scheduleCampaign()
cancelCampaign()
duplicateCampaign()
----
====== Étape 12 — Types ======
===== Supporter =====
Promotion
Newsletter
Loyalty
Retention
Reactivation
----
====== Sprint 8-A.1-D ======
===== Gestion des Audiences =====
----
====== Étape 13 — CampaignAudienceService ======
===== Créer =====
campaign-audience.service.ts
----
===== Sources =====
CRM Segments
Customer Tags
Customer Scores
Behavior Analytics
Smart Segments
----
====== Étape 14 — Méthodes ======
createAudience()
estimateAudienceSize()
refreshAudience()
previewAudience()
----
====== Sprint 8-A.1-E ======
===== Gestion des Templates =====
----
====== Étape 15 — CampaignTemplateService ======
===== Créer =====
campaign-template.service.ts
----
===== Supporter =====
Email HTML
SMS
WhatsApp
Push
In-App
----
====== Étape 16 — Variables ======
===== Autoriser =====
{{customer.firstName}}
{{property.name}}
{{reservation.checkIn}}
{{loyalty.points}}
----
====== Sprint 8-A.1-F ======
===== Moteur d'Exécution =====
----
====== Étape 17 — CampaignExecutionService ======
===== Créer =====
campaign-execution.service.ts
----
===== Workflow =====
Schedule
↓
Audience Build
↓
Send
↓
Track
↓
Analytics
----
====== Étape 18 — Méthodes ======
executeCampaign()
pauseExecution()
resumeExecution()
retryFailedMessages()
----
====== Étape 19 — Intégrations ======
===== Connecter =====
Email Provider
SMS Provider
WhatsApp Provider
Push Provider
----
====== Sprint 8-A.1-G ======
===== Tracking Marketing =====
----
====== Étape 20 — CampaignTrackingService ======
===== Créer =====
campaign-tracking.service.ts
----
===== Mesurer =====
Delivery
Open
Click
Conversion
Unsubscribe
----
====== Étape 21 — Attribution ======
===== Associer =====
Campaign
↓
Customer
↓
Reservation
↓
Revenue
----
====== Sprint 8-A.1-H ======
===== Marketing Dashboard =====
----
====== Étape 22 — MarketingDashboardService ======
===== Créer =====
marketing-dashboard.service.ts
----
===== Afficher =====
Campaigns
Audience Reach
Open Rate
Click Rate
Conversions
Revenue Attribution
----
====== Étape 23 — KPIs ======
CTR
Conversion Rate
Revenue Per Campaign
Cost Per Conversion
Marketing ROI
----
====== Sprint 8-A.1-I ======
===== API Marketing =====
----
====== Étape 24 — Endpoints ======
GET /marketing/campaigns
POST /marketing/campaigns
PUT /marketing/campaigns/{id}
GET /marketing/audiences
POST /marketing/audiences
GET /marketing/templates
POST /marketing/templates
POST /marketing/executions
GET /marketing/dashboard
----
====== Étape 25 — Exemple ======
{
"campaign":"Summer Promotion",
"audienceSize":12500,
"deliveryRate":98.2,
"openRate":42.7,
"conversionRate":6.4
}
----
====== Sprint 8-A.1-J ======
===== Gouvernance =====
----
====== Étape 26 — Permissions ======
marketing.read
marketing.create
marketing.execute
marketing.analytics
marketing.templates
marketing.admin
----
====== Étape 27 — Audit ======
CAMPAIGN_CREATED
CAMPAIGN_SCHEDULED
CAMPAIGN_EXECUTED
AUDIENCE_GENERATED
TEMPLATE_CREATED
MARKETING_REPORT_VIEWED
----
====== Étape 28 — Jobs ======
Toutes les minutes
Campaign Scheduler
Toutes les 5 minutes
Execution Queue
Toutes les nuits
Audience Refresh
Dashboard Snapshot
----
====== Préparation Sprint 8-A.2 ======
Compatible avec :
Marketing Automation
Journey Builder
Trigger Campaigns
Behavior Campaigns
AI Marketing
----
====== Définition de terminé ======
Le Sprint 8-A.1 est terminé lorsque :
✓ Campaign créé
✓ CampaignAudience créé
✓ CampaignTemplate créé
✓ CampaignExecution créé
✓ CampaignTracking créé
✓ MarketingDashboard créé
✓ Marketing Core opérationnel
----
====== Livrables ======
Campaign
CampaignAudience
CampaignTemplate
CampaignExecution
CampaignTracking
MarketingDashboardSnapshot
CampaignService
CampaignAudienceService
CampaignTemplateService
CampaignExecutionService
CampaignTrackingService
MarketingDashboardService
Marketing Platform Core
----
====== Sprint 8-A.2 — Marketing Automation & Customer Journeys ======
===== Objectif =====
Transformer la plateforme marketing en moteur d'automatisation omnicanal Enterprise.
Cette couche permet :
Customer Journeys
Automation Rules
Behavior Triggers
Lifecycle Marketing
Real-Time Engagement
Journey Analytics
afin d'automatiser l'ensemble du cycle de vie client.
À l'issue de cette étape :
✓ Journey
✓ Automation Rule
✓ Trigger Engine
✓ Behavior Campaigns
✓ Lifecycle Marketing
✓ Journey Analytics
✓ Marketing Automation Platform
----
====== Architecture cible ======
CRM
↓
Behavior Engine
↓
Journey Automation Platform
├── Journeys
├── Triggers
├── Rules Engine
├── Lifecycle Campaigns
├── Real-Time Automation
└── Journey Analytics
↓
Email
SMS
WhatsApp
Push
In-App
----
====== Sprint 8-A.2-A ======
===== Extension Prisma =====
----
====== Étape 1 — Journey ======
===== Ajouter dans schema.prisma =====
model Journey {
id String
@id
@default(uuid())
tenantId String
name String
description String?
status JourneyStatus
triggerType JourneyTriggerType
active Boolean
@default(true)
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
steps JourneyStep[]
@@index([tenantId])
@@index([status])
}
----
====== Étape 2 — JourneyStep ======
===== Ajouter =====
model JourneyStep {
id String
@id
@default(uuid())
journeyId String
stepOrder Int
stepType JourneyStepType
configuration Json
createdAt DateTime
@default(now())
journey Journey
@relation(
fields:[journeyId],
references:[id],
onDelete:Cascade
)
@@index([journeyId])
}
----
====== Étape 3 — AutomationRule ======
===== Ajouter =====
model AutomationRule {
id String
@id
@default(uuid())
tenantId String
name String
triggerEvent String
conditions Json
actions Json
enabled Boolean
@default(true)
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
@@index([tenantId])
@@index([enabled])
}
----
====== Étape 4 — JourneyExecution ======
===== Ajouter =====
model JourneyExecution {
id String
@id
@default(uuid())
journeyId String
customerId String
status JourneyExecutionStatus
currentStep Int
@default(0)
startedAt DateTime
@default(now())
completedAt DateTime?
@@index([journeyId])
@@index([customerId])
@@index([status])
}
----
====== Étape 5 — JourneyAnalytics ======
===== Ajouter =====
model JourneyAnalytics {
journeyId String
@id
enrolledCustomers Int
@default(0)
completedCustomers Int
@default(0)
conversionRate Float?
revenueAttributed Decimal?
@db.Decimal(14,2)
updatedAt DateTime
@updatedAt
}
----
====== Étape 6 — Enums ======
===== Ajouter =====
enum JourneyStatus {
DRAFT
ACTIVE
PAUSED
ARCHIVED
}
enum JourneyTriggerType {
CUSTOMER_CREATED
RESERVATION_CREATED
CHECKIN_COMPLETED
CHECKOUT_COMPLETED
TAG_ASSIGNED
BEHAVIOR_EVENT
}
enum JourneyStepType {
WAIT
EMAIL
SMS
WHATSAPP
PUSH
CONDITION
TAG
WEBHOOK
}
enum JourneyExecutionStatus {
ACTIVE
COMPLETED
FAILED
CANCELLED
}
----
====== Étape 7 — Migration ======
npx prisma migrate dev \
--name marketing_automation
----
====== Sprint 8-A.2-B ======
===== Marketing Automation Module =====
----
====== Étape 8 — Structure ======
src/modules/marketing-automation
├── journeys
├── rules
├── triggers
├── lifecycle
├── analytics
└── marketing-automation.module.ts
----
====== Étape 9 — Services ======
JourneyService
AutomationRuleService
TriggerEngineService
BehaviorCampaignService
LifecycleMarketingService
JourneyAnalyticsService
----
====== Sprint 8-A.2-C ======
===== Customer Journeys =====
----
====== Étape 10 — JourneyService ======
===== Créer =====
journey.service.ts
----
===== Méthodes =====
createJourney()
publishJourney()
pauseJourney()
duplicateJourney()
archiveJourney()
----
====== Étape 11 — Journey Builder ======
===== Supporter =====
Drag & Drop
Conditions
Delays
Actions
Branches
----
====== Étape 12 — Parcours standards ======
Welcome Journey
Booking Journey
Check-In Journey
Post-Stay Journey
Reactivation Journey
----
====== Sprint 8-A.2-D ======
===== Automation Rules =====
----
====== Étape 13 — AutomationRuleService ======
===== Créer =====
automation-rule.service.ts
----
===== Supporter =====
Triggers
Conditions
Actions
Schedules
----
====== Étape 14 — Exemples ======
Tag VIP ajouté
↓
Envoyer email premium
----
Aucune réservation 180 jours
↓
Campagne réactivation
----
====== Sprint 8-A.2-E ======
===== Trigger Engine =====
----
====== Étape 15 — TriggerEngineService ======
===== Créer =====
trigger-engine.service.ts
----
===== Événements =====
Customer
Reservation
Payment
Property
Marketing
Behavior
----
====== Étape 16 — Méthodes ======
processEvent()
evaluateTriggers()
executeActions()
scheduleExecution()
----
====== Étape 17 — Temps réel ======
===== Utiliser =====
Event Bus
Queue
Worker
pour le traitement asynchrone.
----
====== Sprint 8-A.2-F ======
===== Behavior Campaigns =====
----
====== Étape 18 — BehaviorCampaignService ======
===== Créer =====
behavior-campaign.service.ts
----
===== Déclencher =====
Navigation
Recherche
Abandon réservation
Ouverture email
Clic campagne
----
====== Étape 19 — Exemples ======
Abandon réservation
↓
Relance 1h
↓
Relance 24h
↓
Offre promotionnelle
----
====== Sprint 8-A.2-G ======
===== Lifecycle Marketing =====
----
====== Étape 20 — LifecycleMarketingService ======
===== Créer =====
lifecycle-marketing.service.ts
----
===== Cycles =====
Prospect
Client
Voyageur
VIP
Inactif
Perdu
----
====== Étape 21 — Automatisations ======
Onboarding
Loyalty
Upsell
Cross-Sell
Retention
Win-Back
----
====== Étape 22 — Smart Segments ======
===== Réutiliser =====
CRM Scores
Customer Segments
Behavior Analytics
Communication History
----
====== Sprint 8-A.2-H ======
===== Journey Analytics =====
----
====== Étape 23 — JourneyAnalyticsService ======
===== Créer =====
journey-analytics.service.ts
----
===== Mesurer =====
Enrollments
Completion Rate
Drop-Off Rate
Conversion Rate
Revenue Attribution
----
====== Étape 24 — KPIs ======
Journey ROI
Automation Efficiency
Customer Engagement
Revenue Per Journey
----
====== Sprint 8-A.2-I ======
===== API Marketing Automation =====
----
====== Étape 25 — Endpoints ======
GET /marketing/journeys
POST /marketing/journeys
PUT /marketing/journeys/{id}
POST /marketing/journeys/{id}/publish
GET /marketing/automation-rules
POST /marketing/automation-rules
GET /marketing/journeys/analytics
----
====== Étape 26 — Exemple ======
{
"journey":"Welcome Journey",
"enrolled":12000,
"completed":10150,
"conversionRate":12.7,
"revenueAttributed":85000
}
----
====== Sprint 8-A.2-J ======
===== Gouvernance =====
----
====== Étape 27 — Permissions ======
marketing.journey.read
marketing.journey.manage
marketing.automation.manage
marketing.behavior.manage
marketing.analytics.read
marketing.admin
----
====== Étape 28 — Audit ======
JOURNEY_CREATED
JOURNEY_PUBLISHED
AUTOMATION_RULE_CREATED
TRIGGER_EXECUTED
BEHAVIOR_CAMPAIGN_STARTED
JOURNEY_ANALYTICS_VIEWED
----
====== Étape 29 — Jobs ======
Toutes les minutes
Trigger Processing
Journey Scheduler
Toutes les 5 minutes
Behavior Evaluation
Toutes les nuits
Journey Analytics Refresh
----
====== Préparation Sprint 8-B.1 ======
Compatible avec :
Loyalty Program
Rewards
Points Engine
Membership Tiers
Customer Retention
----
====== Définition de terminé ======
Le Sprint 8-A.2 est terminé lorsque :
✓ Journey créé
✓ Automation Rule créée
✓ Trigger Engine créé
✓ Behavior Campaigns créées
✓ Lifecycle Marketing créé
✓ Journey Analytics créé
✓ Marketing Automation opérationnel
----
====== Livrables ======
Journey
JourneyStep
AutomationRule
JourneyExecution
JourneyAnalytics
JourneyService
AutomationRuleService
TriggerEngineService
BehaviorCampaignService
LifecycleMarketingService
JourneyAnalyticsService
Marketing Automation Platform
----
====== Sprint 8-B.1 — Loyalty Program Core ======
===== Objectif =====
Construire le moteur de fidélisation client Enterprise.
Cette couche permet :
Comptes fidélité
Points
Récompenses
Niveaux d'adhésion
Transactions fidélité
Tableaux de bord
afin d'augmenter :
Rétention
Réachat
Valeur vie client (LTV)
Engagement
Revenus récurrents
À l'issue de cette étape :
✓ LoyaltyAccount
✓ PointsLedger
✓ Reward
✓ MembershipTier
✓ LoyaltyTransaction
✓ LoyaltyDashboard
✓ Loyalty Platform Core
----
====== Architecture cible ======
Customer
↓
Loyalty Platform
├── Loyalty Accounts
├── Points Engine
├── Rewards Catalog
├── Membership Tiers
├── Loyalty Transactions
└── Loyalty Dashboard
↓
Marketing Automation
↓
Reservations
↓
Revenue Growth
----
====== Sprint 8-B.1-A ======
===== Extension Prisma =====
----
====== Étape 1 — LoyaltyAccount ======
===== Ajouter dans schema.prisma ======
model LoyaltyAccount {
id String
@id
@default(uuid())
tenantId String
customerId String
@unique
membershipTierId String?
loyaltyNumber String
active Boolean
@default(true)
currentPoints Int
@default(0)
lifetimePoints Int
@default(0)
joinedAt DateTime
@default(now())
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
transactions LoyaltyTransaction[]
@@unique([tenantId, loyaltyNumber])
@@index([tenantId])
@@index([customerId])
}
----
====== Étape 2 — PointsLedger ======
===== Ajouter =====
model PointsLedger {
id String
@id
@default(uuid())
loyaltyAccountId String
transactionType PointsTransactionType
points Int
balanceAfter Int
sourceType LoyaltySourceType
sourceId String?
expiresAt DateTime?
createdAt DateTime
@default(now())
@@index([loyaltyAccountId])
@@index([transactionType])
@@index([expiresAt])
}
----
====== Étape 3 — Reward ======
===== Ajouter =====
model Reward {
id String
@id
@default(uuid())
tenantId String
code String
name String
description String?
rewardType RewardType
pointsRequired Int
quantityAvailable Int?
active Boolean
@default(true)
validFrom DateTime?
validUntil DateTime?
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
@@unique([tenantId, code])
@@index([tenantId])
@@index([rewardType])
@@index([active])
}
----
====== Étape 4 — MembershipTier ======
===== Ajouter =====
model MembershipTier {
id String
@id
@default(uuid())
tenantId String
code String
name String
level Int
pointsThreshold Int
benefits Json?
active Boolean
@default(true)
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
@@unique([tenantId, code])
@@index([tenantId])
@@index([level])
}
----
====== Étape 5 — LoyaltyTransaction ======
===== Ajouter =====
model LoyaltyTransaction {
id String
@id
@default(uuid())
loyaltyAccountId String
rewardId String?
transactionType LoyaltyTransactionType
points Int
monetaryValue Decimal?
@db.Decimal(14,2)
status LoyaltyTransactionStatus
createdAt DateTime
@default(now())
completedAt DateTime?
@@index([loyaltyAccountId])
@@index([transactionType])
@@index([status])
}
----
====== Étape 6 — LoyaltyDashboardSnapshot ======
===== Ajouter =====
model LoyaltyDashboardSnapshot {
id String
@id
@default(uuid())
tenantId String
snapshotDate DateTime
activeMembers Int
totalPointsIssued Int
totalPointsRedeemed Int
rewardsRedeemed Int
loyaltyRevenue Decimal?
@db.Decimal(14,2)
createdAt DateTime
@default(now())
@@index([tenantId])
@@index([snapshotDate])
}
----
====== Étape 7 — Enums ======
===== Ajouter =====
enum PointsTransactionType {
EARN
REDEEM
EXPIRE
ADJUSTMENT
BONUS
}
enum LoyaltySourceType {
RESERVATION
CAMPAIGN
REFERRAL
MANUAL
REWARD
}
enum RewardType {
DISCOUNT
FREE_NIGHT
UPGRADE
GIFT
VOUCHER
}
enum LoyaltyTransactionType {
EARN
REDEEM
TRANSFER
ADJUSTMENT
}
enum LoyaltyTransactionStatus {
PENDING
COMPLETED
CANCELLED
FAILED
}
----
====== Étape 8 — Migration ======
npx prisma migrate dev \
--name loyalty_program_core
----
====== Sprint 8-B.1-B ======
===== Loyalty Module =====
----
====== Étape 9 — Structure ======
src/modules/loyalty
├── accounts
├── points
├── rewards
├── tiers
├── transactions
├── dashboard
└── loyalty.module.ts
----
====== Étape 10 — Services ======
LoyaltyAccountService
PointsLedgerService
RewardService
MembershipTierService
LoyaltyTransactionService
LoyaltyDashboardService
----
====== Sprint 8-B.1-C ======
===== Comptes Fidélité =====
----
====== Étape 11 — LoyaltyAccountService ======
===== Créer =====
loyalty-account.service.ts
----
===== Méthodes =====
createAccount()
getAccount()
suspendAccount()
reactivateAccount()
calculateTier()
----
====== Étape 12 — Attribution ======
===== Créer automatiquement =====
lors de :
Création client
Première réservation
Programme invitation
----
====== Sprint 8-B.1-D ======
===== Moteur de Points =====
----
====== Étape 13 — PointsLedgerService ======
===== Créer =====
points-ledger.service.ts
----
===== Supporter =====
Earn
Redeem
Expire
Bonus
Adjustment
----
====== Étape 14 — Règles ======
===== Exemple =====
1 € dépensé
↓
10 points
----
Séjour > 5 nuits
↓
Bonus 500 points
----
====== Étape 15 — Méthodes ======
earnPoints()
redeemPoints()
expirePoints()
adjustPoints()
calculateBalance()
----
====== Sprint 8-B.1-E ======
===== Catalogue Récompenses =====
----
====== Étape 16 — RewardService ======
===== Créer =====
reward.service.ts
----
===== Supporter =====
Réduction
Nuit offerte
Upgrade
Cadeaux
Coupons
----
====== Étape 17 — Méthodes ======
createReward()
redeemReward()
reserveRewardStock()
expireReward()
----
====== Sprint 8-B.1-F ======
===== Membership Tiers =====
----
====== Étape 18 — MembershipTierService ======
===== Créer =====
membership-tier.service.ts
----
===== Niveaux =====
Bronze
Silver
Gold
Platinum
----
====== Étape 19 — Avantages ======
Bonus Points
Priority Support
Late Checkout
Free Upgrade
Exclusive Offers
----
====== Étape 20 — Méthodes ======
assignTier()
upgradeTier()
downgradeTier()
evaluateEligibility()
----
====== Sprint 8-B.1-G ======
===== Transactions Fidélité =====
----
====== Étape 21 — LoyaltyTransactionService ======
===== Créer =====
loyalty-transaction.service.ts
----
===== Historiser =====
Points Earned
Points Redeemed
Transfers
Adjustments
----
====== Étape 22 — Méthodes ======
createTransaction()
completeTransaction()
cancelTransaction()
getTransactionHistory()
----
====== Sprint 8-B.1-H ======
===== Loyalty Dashboard =====
----
====== Étape 23 — LoyaltyDashboardService ======
===== Créer =====
loyalty-dashboard.service.ts
----
===== Afficher =====
Members
Points Issued
Points Redeemed
Rewards
Tier Distribution
----
====== Étape 24 — KPIs ======
Retention Rate
Redemption Rate
Points Liability
Loyalty Revenue
Average Tier
----
====== Sprint 8-B.1-I ======
===== API Loyalty =====
----
====== Étape 25 — Endpoints ======
GET /loyalty/accounts
GET /loyalty/accounts/{id}
POST /loyalty/accounts
GET /loyalty/rewards
POST /loyalty/rewards
GET /loyalty/tiers
POST /loyalty/transactions
GET /loyalty/dashboard
----
====== Étape 26 — Exemple ======
{
"customer":"John Doe",
"tier":"Gold",
"points":18500,
"lifetimePoints":42300,
"availableRewards":17
}
----
====== Sprint 8-B.1-J ======
===== Gouvernance =====
----
====== Étape 27 — Permissions ======
loyalty.read
loyalty.manage
loyalty.points
loyalty.rewards
loyalty.analytics
loyalty.admin
----
====== Étape 28 — Audit ======
LOYALTY_ACCOUNT_CREATED
POINTS_EARNED
POINTS_REDEEMED
REWARD_REDEEMED
TIER_UPGRADED
LOYALTY_DASHBOARD_VIEWED
----
====== Étape 29 — Jobs ======
Toutes les nuits
Points Expiration
Tier Evaluation
Dashboard Snapshot
Reward Availability Refresh
----
====== Préparation Sprint 8-B.2 ======
Compatible avec :
Loyalty Intelligence
Reward Optimization
Customer Lifetime Value
Retention Prediction
VIP Programs
----
====== Définition de terminé ======
Le Sprint 8-B.1 est terminé lorsque :
✓ LoyaltyAccount créé
✓ PointsLedger créé
✓ Reward créé
✓ MembershipTier créé
✓ LoyaltyTransaction créé
✓ LoyaltyDashboard créé
✓ Loyalty Program opérationnel
----
====== Livrables ======
LoyaltyAccount
PointsLedger
Reward
MembershipTier
LoyaltyTransaction
LoyaltyDashboardSnapshot
LoyaltyAccountService
PointsLedgerService
RewardService
MembershipTierService
LoyaltyTransactionService
LoyaltyDashboardService
Loyalty Platform Core
----
====== Sprint 8-B.2 — Loyalty Intelligence & Retention Platform ======
===== Objectif =====
Transformer le programme de fidélité en plateforme d'intelligence client Enterprise.
Cette couche permet :
Customer Lifetime Value
Prévision de rétention
Optimisation des récompenses
Gestion VIP
Analyse engagement
Scoring fidélité
afin d'améliorer :
LTV
Rétention
Engagement
Revenus récurrents
Rentabilité client
À l'issue de cette étape :
✓ Customer Lifetime Value
✓ Retention Prediction
✓ Reward Optimization
✓ VIP Intelligence
✓ Loyalty Health Score
✓ Engagement Analytics
✓ Loyalty Intelligence Platform
----
====== Architecture cible ======
Loyalty Platform
↓
Loyalty Intelligence Engine
├── CLV Engine
├── Retention Engine
├── Reward Optimization
├── VIP Intelligence
├── Engagement Analytics
├── Loyalty Health Scoring
└── AI Recommendations
↓
Marketing Automation
↓
CRM
↓
Revenue Growth
----
====== Sprint 8-B.2-A ======
===== Extension Prisma =====
----
====== Étape 1 — CustomerLifetimeValue ======
===== Ajouter dans schema.prisma =====
model CustomerLifetimeValue {
customerId String
@id
predictedLtv Decimal
@db.Decimal(14,2)
historicalRevenue Decimal
@db.Decimal(14,2)
projectedRevenue Decimal
@db.Decimal(14,2)
profitabilityScore Float?
calculatedAt DateTime
@updatedAt
}
----
====== Étape 2 — RetentionPrediction ======
===== Ajouter =====
model RetentionPrediction {
customerId String
@id
retentionProbability Float
churnProbability Float
riskLevel RetentionRiskLevel
nextReviewDate DateTime?
calculatedAt DateTime
@updatedAt
}
----
====== Étape 3 — LoyaltyInsight ======
===== Ajouter =====
model LoyaltyInsight {
id String
@id
@default(uuid())
customerId String
category LoyaltyInsightCategory
severity InsightSeverity
title String
description String
recommendation String?
impactScore Float?
createdAt DateTime
@default(now())
@@index([customerId])
@@index([category])
}
----
====== Étape 4 — RewardOptimization ======
===== Ajouter =====
model RewardOptimization {
id String
@id
@default(uuid())
rewardId String
currentCost Decimal
@db.Decimal(14,2)
suggestedCost Decimal
@db.Decimal(14,2)
expectedRedemption Float?
expectedRevenueImpact Decimal?
@db.Decimal(14,2)
implemented Boolean
@default(false)
createdAt DateTime
@default(now())
@@index([rewardId])
}
----
====== Étape 5 — LoyaltyHealthScore ======
===== Ajouter =====
model LoyaltyHealthScore {
customerId String
@id
overallScore Float
engagementScore Float
retentionScore Float
activityScore Float
valueScore Float
loyaltyScore Float
calculatedAt DateTime
@updatedAt
}
----
====== Étape 6 — Enums ======
===== Ajouter =====
enum RetentionRiskLevel {
LOW
MEDIUM
HIGH
CRITICAL
}
enum LoyaltyInsightCategory {
ENGAGEMENT
RETENTION
REWARD
VIP
REVENUE
}
----
====== Étape 7 — Migration ======
npx prisma migrate dev \
--name loyalty_intelligence
----
====== Sprint 8-B.2-B ======
===== Loyalty Intelligence Module =====
----
====== Étape 8 — Structure ======
src/modules/loyalty-intelligence
├── clv
├── retention
├── rewards
├── vip
├── analytics
├── health
└── loyalty-intelligence.module.ts
----
====== Étape 9 — Services ======
CustomerLifetimeValueService
RetentionPredictionService
RewardOptimizationService
VipIntelligenceService
EngagementAnalyticsService
LoyaltyHealthScoreService
LoyaltyInsightService
----
====== Sprint 8-B.2-C ======
===== Customer Lifetime Value =====
----
====== Étape 10 — CustomerLifetimeValueService ======
===== Créer =====
customer-lifetime-value.service.ts
----
===== Calculer =====
Historical Revenue
Reservation Frequency
Average Basket
Retention Rate
Future Revenue
----
====== Étape 11 — Méthodes ======
calculateLtv()
forecastLtv()
segmentByLtv()
rankCustomers()
----
====== Étape 12 — Segments ======
VIP
High Value
Standard
Low Value
----
====== Sprint 8-B.2-D ======
===== Retention Prediction =====
----
====== Étape 13 — RetentionPredictionService ======
===== Créer =====
retention-prediction.service.ts
----
===== Évaluer =====
Recency
Frequency
Monetary Value
Engagement
Support History
----
====== Étape 14 — Méthodes ======
predictRetention()
predictChurn()
calculateRisk()
generateRetentionActions()
----
====== Étape 15 — Exemple ======
Customer
Risque churn
82%
↓
Campagne Win-Back
----
====== Sprint 8-B.2-E ======
===== Reward Optimization =====
----
====== Étape 16 — RewardOptimizationService ======
===== Créer =====
reward-optimization.service.ts
----
===== Optimiser =====
Reward Cost
Redemption Rate
Revenue Impact
Customer Satisfaction
----
====== Étape 17 — Méthodes ======
analyzeRewards()
optimizeRewardCost()
forecastRedemption()
recommendRewards()
----
====== Étape 18 — Exemple ======
Reward
5000 points
↓
6500 points
↓
+18% marge
----
====== Sprint 8-B.2-F ======
===== VIP Intelligence =====
----
====== Étape 19 — VipIntelligenceService ======
===== Créer =====
vip-intelligence.service.ts
----
===== Identifier =====
Top Revenue
Top LTV
Top Loyalty
Brand Advocates
High Referral
----
====== Étape 20 — Programmes ======
VIP Gold
VIP Platinum
VIP Elite
----
====== Étape 21 — Méthodes ======
identifyVipCustomers()
assignVipLevel()
trackVipBenefits()
generateVipInsights()
----
====== Sprint 8-B.2-G ======
===== Engagement Analytics =====
----
====== Étape 22 — EngagementAnalyticsService ======
===== Créer =====
engagement-analytics.service.ts
----
===== Mesurer =====
Campaign Activity
Loyalty Activity
Reservation Activity
Reward Usage
Portal Usage
----
====== Étape 23 — KPIs ======
Engagement Rate
Active Members
Reward Usage Rate
Referral Rate
Program Participation
----
====== Sprint 8-B.2-H ======
===== Loyalty Health Score =====
----
====== Étape 24 — LoyaltyHealthScoreService ======
===== Créer =====
loyalty-health-score.service.ts
----
===== Pondération =====
Engagement 25%
Retention 25%
Activity 20%
LTV 20%
Loyalty Usage 10%
----
====== Étape 25 — Classification ======
90-100 Excellent
75-89 Healthy
50-74 Warning
0-49 At Risk
----
====== Étape 26 — Exemple ======
Customer Health
91
Excellent
----
====== Sprint 8-B.2-I ======
===== Intelligence Executive =====
----
====== Étape 27 — LoyaltyInsightService ======
===== Créer =====
loyalty-insight.service.ts
----
===== Générer =====
Retention Alerts
VIP Opportunities
Reward Optimization
Engagement Opportunities
Revenue Growth Actions
----
====== Étape 28 — Exemples ======
Client Gold
LTV prévu
12 500 €
↓
Passage VIP recommandé
----
Segment Standard
Baisse engagement
↓
Campagne fidélisation recommandée
----
====== Sprint 8-B.2-J ======
===== Dashboard Intelligence =====
----
====== Étape 29 — Endpoints ======
GET /loyalty/intelligence
GET /loyalty/ltv
GET /loyalty/retention
GET /loyalty/rewards/optimization
GET /loyalty/vip
GET /loyalty/health
----
====== Étape 30 — Exemple ======
{
"customerLtv":12500,
"retentionProbability":0.87,
"healthScore":91,
"vipEligible":true,
"recommendations":4
}
----
====== Étape 31 — Analytics ======
===== Mesurer =====
LTV Accuracy
Retention Accuracy
Reward ROI
VIP Revenue Share
Loyalty Health Trend
----
====== Gouvernance ======
----
====== Étape 32 — Permissions ======
loyalty.intelligence.read
loyalty.retention.manage
loyalty.vip.manage
loyalty.analytics.read
loyalty.executive
----
====== Étape 33 — Audit ======
LTV_CALCULATED
RETENTION_PREDICTED
VIP_ASSIGNED
REWARD_OPTIMIZATION_CREATED
LOYALTY_HEALTH_UPDATED
LOYALTY_INSIGHT_GENERATED
----
====== Étape 34 — Jobs ======
Toutes les nuits
LTV Refresh
Retention Prediction
VIP Evaluation
Health Score Refresh
Insight Generation
----
====== Clôture Domaine Loyalty ======
À la fin du Sprint 8-B.2 :
✓ Loyalty Program
✓ Loyalty Intelligence
✓ Retention Prediction
✓ VIP Intelligence
✓ Reward Optimization
✓ Engagement Analytics
✓ Customer Lifetime Value
sont entièrement opérationnels.
----
====== Préparation Sprint 8-C.1 ======
Compatible avec :
Referral Program
Advocacy
Influencers
Ambassadors
Growth Engine
----
====== Définition de terminé ======
Le Sprint 8-B.2 est terminé lorsque :
✓ Customer Lifetime Value créé
✓ Retention Prediction créée
✓ Reward Optimization créée
✓ VIP Intelligence créée
✓ Loyalty Health Score créé
✓ Engagement Analytics créée
✓ Loyalty Intelligence finalisée
----
====== Livrables ======
CustomerLifetimeValue
RetentionPrediction
LoyaltyInsight
RewardOptimization
LoyaltyHealthScore
CustomerLifetimeValueService
RetentionPredictionService
RewardOptimizationService
VipIntelligenceService
EngagementAnalyticsService
LoyaltyHealthScoreService
LoyaltyInsightService
Loyalty Intelligence Platform
----
====== Sprint 8-C.1 — Referral Program & Advocacy Core ======
===== Objectif =====
Construire le moteur de croissance virale Enterprise.
Cette couche permet :
Parrainage
Récompenses
Ambassadeurs
Advocacy Marketing
Tracking viral
Attribution
afin d'accélérer :
Acquisition clients
Croissance organique
Recommandations
Rétention
Revenus
À l'issue de cette étape :
✓ ReferralProgram
✓ ReferralCode
✓ ReferralReward
✓ ReferralTracking
✓ AdvocateProfile
✓ ReferralDashboard
✓ Referral Growth Platform
----
====== Architecture cible ======
Customer
↓
Referral Platform
├── Referral Programs
├── Referral Codes
├── Referral Rewards
├── Tracking Engine
├── Advocate Profiles
└── Referral Dashboard
↓
Marketing Automation
↓
Loyalty Program
↓
Growth Engine
----
====== Sprint 8-C.1-A ======
===== Extension Prisma =====
----
====== Étape 1 — ReferralProgram ======
===== Ajouter dans schema.prisma =====
model ReferralProgram {
id String
@id
@default(uuid())
tenantId String
code String
name String
description String?
status ReferralProgramStatus
rewardType ReferralRewardType
rewardValue Decimal
@db.Decimal(14,2)
active Boolean
@default(true)
startDate DateTime?
endDate DateTime?
createdAt DateTime
@default(now())
updatedAt DateTime
@updatedAt
@@unique([tenantId, code])
@@index([tenantId])
@@index([status])
}
----
====== Étape 2 — ReferralCode ======
===== Ajouter =====
model ReferralCode {
id String
@id
@default(uuid())
tenantId String
customerId String
referralProgramId String
code String
usageCount Int
@default(0)
maxUsage Int?
active Boolean
@default(true)
expiresAt DateTime?
createdAt DateTime
@default(now())
@@unique([tenantId, code])
@@index([customerId])
@@index([referralProgramId])
}
----
====== Étape 3 — ReferralReward ======
===== Ajouter =====
model ReferralReward {
id String
@id
@default(uuid())
referralTrackingId String
customerId String
rewardType ReferralRewardType
rewardValue Decimal
@db.Decimal(14,2)
status ReferralRewardStatus
grantedAt DateTime?
createdAt DateTime
@default(now())
@@index([customerId])
@@index([status])
}
----
====== Étape 4 — ReferralTracking ======
===== Ajouter =====
model ReferralTracking {
id String
@id
@default(uuid())
tenantId String
referralCodeId String
referrerCustomerId String
referredCustomerId String?
status ReferralStatus
source ReferralSource?
firstVisitAt DateTime?
signupAt DateTime?
firstBookingAt DateTime?
conversionValue Decimal?
@db.Decimal(14,2)
createdAt DateTime
@default(now())
@@index([tenantId])
@@index([referrerCustomerId])
@@index([status])
}
----
====== Étape 5 — AdvocateProfile ======
===== Ajouter =====
model AdvocateProfile {
customerId String
@id
advocateScore Float
referralsCount Int
@default(0)
conversionsCount Int
@default(0)
generatedRevenue Decimal
@db.Decimal(14,2)
socialInfluenceScore Float?
advocateLevel AdvocateLevel
updatedAt DateTime
@updatedAt
}
----
====== Étape 6 — ReferralDashboardSnapshot ======
===== Ajouter =====
model ReferralDashboardSnapshot {
id String
@id
@default(uuid())
tenantId String
snapshotDate DateTime
referralsGenerated Int
conversions Int
rewardsGranted Int
revenueGenerated Decimal
@db.Decimal(14,2)
activeAdvocates Int
createdAt DateTime
@default(now())
@@index([tenantId])
@@index([snapshotDate])
}
----
====== Étape 7 — Enums ======
===== Ajouter =====
enum ReferralProgramStatus {
DRAFT
ACTIVE
PAUSED
ARCHIVED
}
enum ReferralRewardType {
POINTS
CREDIT
DISCOUNT
CASHBACK
FREE_NIGHT
}
enum ReferralRewardStatus {
PENDING
GRANTED
CANCELLED
EXPIRED
}
enum ReferralStatus {
INVITED
REGISTERED
CONVERTED
REWARDED
REJECTED
}
enum ReferralSource {
EMAIL
SMS
WHATSAPP
SOCIAL
DIRECT_LINK
}
enum AdvocateLevel {
BRONZE
SILVER
GOLD
PLATINUM
ELITE
}
----
====== Étape 8 — Migration ======
npx prisma migrate dev \
--name referral_program_core
----
====== Sprint 8-C.1-B ======
===== Referral Module =====
----
====== Étape 9 — Structure ======
src/modules/referrals
├── programs
├── codes
├── rewards
├── tracking
├── advocates
├── dashboard
└── referrals.module.ts
----
====== Étape 10 — Services ======
ReferralProgramService
ReferralCodeService
ReferralRewardService
ReferralTrackingService
AdvocateProfileService
ReferralDashboardService
----
====== Sprint 8-C.1-C ======
===== Programmes de Parrainage =====
----
====== Étape 11 — ReferralProgramService ======
===== Créer =====
referral-program.service.ts
----
===== Méthodes =====
createProgram()
activateProgram()
pauseProgram()
archiveProgram()
duplicateProgram()
----
====== Étape 12 — Types ======
===== Supporter =====
Double récompense
Récompense unique
Multi-niveaux
Saisonnier
VIP
----
====== Sprint 8-C.1-D ======
===== Codes de Parrainage =====
----
====== Étape 13 — ReferralCodeService ======
===== Créer =====
referral-code.service.ts
----
===== Générer =====
Code unique
Lien court
QR Code
Deep Link
----
====== Étape 14 — Méthodes ======
generateCode()
validateCode()
expireCode()
trackUsage()
----
====== Étape 15 — Exemple ======
JOHN-8X4P2
↓
https://app/ref/JOHN-8X4P2
----
====== Sprint 8-C.1-E ======
===== Récompenses =====
----
====== Étape 16 — ReferralRewardService ======
===== Créer =====
referral-reward.service.ts
----
===== Supporter =====
Points fidélité
Crédit portefeuille
Réduction
Cashback
Nuit offerte
----
====== Étape 17 — Méthodes ======
grantReward()
cancelReward()
expireReward()
synchronizeLoyaltyReward()
----
====== Sprint 8-C.1-F ======
===== Tracking =====
----
====== Étape 18 — ReferralTrackingService ======
===== Créer =====
referral-tracking.service.ts
----
===== Pipeline =====
Invitation
↓
Visite
↓
Inscription
↓
Réservation
↓
Récompense
----
====== Étape 19 — Méthodes ======
trackVisit()
trackSignup()
trackConversion()
calculateAttribution()
----
====== Étape 20 — Attribution ======
===== Associer =====
Referral
↓
Customer
↓
Reservation
↓
Revenue
----
====== Sprint 8-C.1-G ======
===== Ambassadeurs =====
----
====== Étape 21 — AdvocateProfileService ======
===== Créer =====
advocate-profile.service.ts
----
===== Calculer =====
Referrals
Conversions
Revenue
Influence
Engagement
----
====== Étape 22 — Niveaux ======
Bronze
Silver
Gold
Platinum
Elite
----
====== Étape 23 — Méthodes ======
calculateAdvocateScore()
assignAdvocateLevel()
rankAdvocates()
generateAdvocateInsights()
----
====== Sprint 8-C.1-H ======
===== Referral Dashboard =====
----
====== Étape 24 — ReferralDashboardService ======
===== Créer =====
referral-dashboard.service.ts
----
===== Afficher =====
Invitations
Conversions
Revenue
Rewards
Top Advocates
----
====== Étape 25 — KPIs ======
Referral Conversion Rate
Cost Per Referral
Revenue Per Advocate
Referral ROI
Advocate Growth
----
====== Sprint 8-C.1-I ======
===== API Referral =====
----
====== Étape 26 — Endpoints ======
GET /referrals/programs
POST /referrals/programs
GET /referrals/codes
POST /referrals/codes
GET /referrals/tracking
GET /referrals/advocates
GET /referrals/dashboard
----
====== Étape 27 — Exemple ======
{
"program":"Refer & Earn",
"referrals":1240,
"conversions":318,
"conversionRate":25.6,
"revenueGenerated":84200
}
----
====== Sprint 8-C.1-J ======
===== Gouvernance =====
----
====== Étape 28 — Permissions ======
referral.read
referral.manage
referral.rewards
referral.analytics
referral.advocates
referral.admin
----
====== Étape 29 — Audit ======
REFERRAL_PROGRAM_CREATED
REFERRAL_CODE_GENERATED
REFERRAL_CONVERTED
REWARD_GRANTED
ADVOCATE_LEVEL_UPDATED
REFERRAL_DASHBOARD_VIEWED
----
====== Étape 30 — Jobs ======
Toutes les heures
Referral Attribution
Toutes les nuits
Reward Distribution
Advocate Ranking Refresh
Dashboard Snapshot
----
====== Préparation Sprint 8-C.2 ======
Compatible avec :
Advocacy Intelligence
Influencer Programs
Ambassador Platform
Referral Optimization
Growth Intelligence
----
====== Définition de terminé ======
Le Sprint 8-C.1 est terminé lorsque :
✓ ReferralProgram créé
✓ ReferralCode créé
✓ ReferralReward créé
✓ ReferralTracking créé
✓ AdvocateProfile créé
✓ ReferralDashboard créé
✓ Referral Platform opérationnelle
----
====== Livrables ======
ReferralProgram
ReferralCode
ReferralReward
ReferralTracking
AdvocateProfile
ReferralDashboardSnapshot
ReferralProgramService
ReferralCodeService
ReferralRewardService
ReferralTrackingService
AdvocateProfileService
ReferralDashboardService
Referral Growth Platform
----
====== Sprint 8-C.2 — Advocacy Intelligence & Growth Engine ======
===== Objectif =====
Transformer la plateforme de parrainage en moteur de croissance prédictif Enterprise.
Cette couche permet :
Scoring ambassadeurs
Prévision referrals
Détection influenceurs
Optimisation croissance
Recommandations IA
Pilotage acquisition organique
afin de maximiser :
Referral Revenue
Acquisition organique
Influence client
Croissance virale
ROI marketing
À l'issue de cette étape :
✓ Advocate Score
✓ Referral Forecasting
✓ Influencer Detection
✓ Growth Intelligence
✓ Referral Optimization
✓ Growth Health Score
✓ Growth Intelligence Platform
----
====== Architecture cible ======
Referral Platform
↓
Growth Intelligence Engine
├── Advocate Scoring
├── Referral Forecasting
├── Influencer Detection
├── Growth Analytics
├── Referral Optimization
├── Growth Health Scoring
└── AI Recommendations
↓
Marketing Automation
↓
Loyalty Platform
↓
Revenue Growth
----
====== Sprint 8-C.2-A ======
===== Extension Prisma =====
----
====== Étape 1 — AdvocateScore ======
===== Ajouter dans schema.prisma =====
model AdvocateScore {
customerId String
@id
overallScore Float
referralScore Float
conversionScore Float
influenceScore Float
engagementScore Float
revenueScore Float
calculatedAt DateTime
@updatedAt
}
----
====== Étape 2 — ReferralForecast ======
===== Ajouter =====
model ReferralForecast {
id String
@id
@default(uuid())
customerId String?
forecastType ReferralForecastType
forecastDate DateTime
predictedValue Float
confidenceScore Float?
generatedAt DateTime
@default(now())
@@index([customerId])
@@index([forecastType])
@@index([forecastDate])
}
----
====== Étape 3 — InfluencerProfile ======
===== Ajouter =====
model InfluencerProfile {
customerId String
@id
influenceScore Float
audienceScore Float?
engagementScore Float?
referralReach Int
@default(0)
influencerTier InfluencerTier
updatedAt DateTime
@updatedAt
}
----
====== Étape 4 — GrowthInsight ======
===== Ajouter =====
model GrowthInsight {
id String
@id
@default(uuid())
tenantId String
category GrowthInsightCategory
severity InsightSeverity
title String
description String
recommendation String?
impactScore Float?
createdAt DateTime
@default(now())
@@index([tenantId])
@@index([category])
}
----
====== Étape 5 — GrowthHealthScore ======
===== Ajouter =====
model GrowthHealthScore {
tenantId String
@id
overallScore Float
acquisitionScore Float
referralScore Float
advocacyScore Float
conversionScore Float
retentionScore Float
calculatedAt DateTime
@updatedAt
}
----
====== Étape 6 — ReferralOptimization ======
===== Ajouter =====
model ReferralOptimization {
id String
@id
@default(uuid())
referralProgramId String
currentRewardValue Decimal
@db.Decimal(14,2)
suggestedRewardValue Decimal
@db.Decimal(14,2)
expectedConversionGain Float?
expectedRevenueGain Decimal?
@db.Decimal(14,2)
implemented Boolean
@default(false)
createdAt DateTime
@default(now())
@@index([referralProgramId])
}
----
====== Étape 7 — Enums ======
===== Ajouter =====
enum ReferralForecastType {
REFERRALS
CONVERSIONS
REVENUE
ADVOCATES
}
enum InfluencerTier {
MICRO
RISING
MACRO
ELITE
}
enum GrowthInsightCategory {
REFERRAL
ADVOCACY
ACQUISITION
CONVERSION
REVENUE
}
----
====== Étape 8 — Migration ======
npx prisma migrate dev \
--name advocacy_intelligence
----
====== Sprint 8-C.2-B ======
===== Growth Intelligence Module =====
----
====== Étape 9 — Structure ======
src/modules/growth-intelligence
├── advocates
├── forecasting
├── influencers
├── analytics
├── optimization
├── health
└── growth-intelligence.module.ts
----
====== Étape 10 — Services ======
AdvocateScoreService
ReferralForecastService
InfluencerDetectionService
GrowthAnalyticsService
ReferralOptimizationService
GrowthHealthScoreService
GrowthInsightService
----
====== Sprint 8-C.2-C ======
===== Advocate Score =====
----
====== Étape 11 — AdvocateScoreService ======
===== Créer =====
advocate-score.service.ts
----
===== Calculer =====
Referrals
Conversions
Revenue
Engagement
Influence
----
====== Étape 12 — Pondération ======
Referrals 30%
Conversions 25%
Revenue 20%
Influence 15%
Engagement 10%
----
====== Étape 13 — Classification ======
90-100 Elite Advocate
75-89 Premium Advocate
50-74 Active Advocate
0-49 Emerging Advocate
----
====== Sprint 8-C.2-D ======
===== Referral Forecasting =====
----
====== Étape 14 — ReferralForecastService ======
===== Créer =====
referral-forecast.service.ts
----
===== Prévoir =====
Referrals
Conversions
Revenue
Growth
----
====== Étape 15 — Horizons ======
30 jours
90 jours
12 mois
----
====== Étape 16 — Méthodes ======
forecastReferrals()
forecastConversions()
forecastRevenue()
forecastAdvocateGrowth()
----
====== Sprint 8-C.2-E ======
===== Influencer Detection =====
----
====== Étape 17 — InfluencerDetectionService ======
===== Créer =====
influencer-detection.service.ts
----
===== Identifier =====
Top Advocates
Brand Ambassadors
High Reach Customers
Community Leaders
VIP Influencers
----
====== Étape 18 — Méthodes ======
detectInfluencers()
calculateInfluenceScore()
assignInfluencerTier()
generateInfluencerInsights()
----
====== Étape 19 — Tiers ======
Micro
Rising
Macro
Elite
----
====== Sprint 8-C.2-F ======
===== Growth Intelligence =====
----
====== Étape 20 — GrowthAnalyticsService ======
===== Créer =====
growth-analytics.service.ts
----
===== Mesurer =====
Referral Funnel
Acquisition Funnel
Conversion Funnel
Advocate Funnel
Revenue Funnel
----
====== Étape 21 — KPIs ======
Referral Conversion Rate
Advocate Activation Rate
Revenue Per Referral
Customer Acquisition Cost
Viral Coefficient
----
====== Étape 22 — Classements ======
===== Produire =====
Top Advocates
Top Influencers
Top Revenue Contributors
Fastest Growing Segments
----
====== Sprint 8-C.2-G ======
===== Referral Optimization =====
----
====== Étape 23 — ReferralOptimizationService ======
===== Créer =====
referral-optimization.service.ts
----
===== Optimiser =====
Reward Value
Referral Funnel
Conversion Rate
Program Profitability
----
====== Étape 24 — Méthodes ======
analyzeProgram()
optimizeRewardValue()
forecastRewardImpact()
recommendReferralChanges()
----
====== Étape 25 — Exemple ======
Reward
20€
↓
25€
↓
+18% conversions
↓
+11% revenu net
----
====== Sprint 8-C.2-H ======
===== Growth Health Score =====
----
====== Étape 26 — GrowthHealthScoreService ======
===== Créer =====
growth-health-score.service.ts
----
===== Pondération =====
Referral Growth 25%
Conversion 25%
Advocacy 20%
Revenue 20%
Retention 10%
----
====== Étape 27 — Classification ======
90-100 Excellent
75-89 Healthy
50-74 Warning
0-49 Critical
----
====== Étape 28 — Exemple ======
Growth Health
94
Excellent
----
====== Sprint 8-C.2-I ======
===== Executive Growth Intelligence =====
----
====== Étape 29 — GrowthInsightService ======
===== Créer =====
growth-insight.service.ts
----
===== Générer =====
Advocate Opportunities
Influencer Opportunities
Referral Optimization
Acquisition Improvements
Growth Risks
----
====== Étape 30 — Exemples ======
Top 5 advocates
↓
34% du revenu referral
↓
Programme ambassadeur recommandé
----
Programme A
Conversion 7%
↓
Sous moyenne
↓
Récompense à optimiser
----
====== Sprint 8-C.2-J ======
===== Dashboard Intelligence =====
----
====== Étape 31 — Endpoints ======
GET /referrals/intelligence
GET /referrals/forecasting
GET /referrals/influencers
GET /referrals/optimization
GET /referrals/health
GET /referrals/leaderboard
----
====== Étape 32 — Exemple ======
{
"advocateScore":96,
"influencerTier":"ELITE",
"forecastRevenue":125000,
"growthHealth":94,
"recommendations":6
}
----
====== Étape 33 — Analytics ======
===== Mesurer =====
Forecast Accuracy
Influencer Impact
Referral ROI
Viral Coefficient
Growth Health Trend
----
====== Gouvernance ======
----
====== Étape 34 — Permissions ======
growth.read
growth.analytics
growth.forecasting
growth.optimization
growth.executive
----
====== Étape 35 — Audit ======
ADVOCATE_SCORE_UPDATED
FORECAST_GENERATED
INFLUENCER_DETECTED
REFERRAL_OPTIMIZATION_CREATED
GROWTH_HEALTH_UPDATED
GROWTH_INSIGHT_CREATED
----
====== Étape 36 — Jobs ======
Toutes les nuits
Advocate Score Refresh
Forecast Generation
Influencer Detection
Optimization Analysis
Growth Health Refresh
----
====== Clôture Domaine Growth ======
À la fin du Sprint 8-C.2 :
✓ Referral Platform
✓ Advocacy Intelligence
✓ Influencer Detection
✓ Growth Analytics
✓ Referral Optimization
✓ Growth Health Score
✓ Growth Engine
sont entièrement opérationnels.
----
====== Préparation Sprint 9 ======
Compatible avec :
Business Intelligence
Data Warehouse
KPIs
Reporting
Executive Cockpit
Enterprise Analytics
----
====== Définition de terminé ======
Le Sprint 8-C.2 est terminé lorsque :
✓ Advocate Score créé
✓ Referral Forecasting créé
✓ Influencer Detection créé
✓ Growth Intelligence créée
✓ Referral Optimization créée
✓ Growth Health Score créé
✓ Growth Engine finalisé
----
====== Livrables ======
AdvocateScore
ReferralForecast
InfluencerProfile
GrowthInsight
GrowthHealthScore
ReferralOptimization
AdvocateScoreService
ReferralForecastService
InfluencerDetectionService
GrowthAnalyticsService
ReferralOptimizationService
GrowthHealthScoreService
GrowthInsightService
Growth Intelligence Platform