Transforme XIP en réseau social satirique complet : monnaie fictive, marketplace, cosmétiques visibles de tous, messages riches sandboxés, pubs pilotées par les données, et tous les compteurs mock rendus réels. Backend (Bun + Hono + Prisma + Redis) - Économie par IP : modèles Wallet/Purchase/Entitlement, lib/wallet.ts avec spend() atomique (point unique du paywall) + recharge gratuite. - isLocalhost() → mode gratuit (README « si localhost: pas de paywall »). - Marketplace : lib/catalog.ts (achat transactionnel, stock limité, limites par IP) + routes/shop.ts ; 10 produits seedés (idempotent). - Perks : lib/perks.ts (cache Redis busté à l'achat) ; authorPerks injecté dans les payloads messages + endpoint batch /api/perks ; frame WS « perks » global pour MAJ live des messages déjà affichés. - Messages riches : Message.richMode/richContent, gating par entitlement. - Pubs réelles : modèle Ad seedé avec les 4 pubs (ex-hardcodées), rotation par API, comptage d'impressions réel + réconciliation. - WebSocket : IP capturée par connexion → broadcastToIp / broadcast ; frames wallet/perks/ads/alert. - Pièces jointes : lib/storage.ts (UUID, jamais exécuté) + routes/uploads.ts (limite 1 Mo sauf déblocage/localhost, Content-Disposition: attachment). - Alerte audio : routes/alert.ts (cooldown serveur Redis NX, clamp durée). - Compteur « argent extorqué » réel : impressions×CPM + crédits dépensés. Frontend (Vue 3 + Vite) - /shop : ShopPage + ProductCard fidèles aux maquettes ; composables useWallet/useShop/usePerks/useAds/useAttachments/useAlert. - UI de réponse (bannière + sous-threads), solde + lien Shop dans le header. - Perks rendus : Style Doré (or), Pets autour de l'IP, NoAds masque les pubs. - RichContent.vue : iframe sandbox verrouillée (htmlcss sans script ; js allow-scripts seul, jamais allow-same-origin) + CSP. - AdBand/InlineCasinoAd pilotés par l'API ; barre de saisie avec 📎, compteur de caractères, composer riche et bouton alerte. Infra - Migration economy_ads_attachments_rich ; seed idempotent (produits+pubs). - vite.config : usePolling (HMR fiable sur /mnt/c via WSL). - backend/.gitignore : uploads/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
131 lines
4.1 KiB
Plaintext
131 lines
4.1 KiB
Plaintext
// This is your Prisma schema file
|
|
// Learn more: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Message {
|
|
id String @id @default(uuid())
|
|
content String @db.VarChar(267)
|
|
authorIp String
|
|
createdAt DateTime @default(now())
|
|
parentId String?
|
|
// Rich-message tiers (paid): "none" | "htmlcss" | "js". richContent holds the raw
|
|
// markup/script, rendered ONLY inside a sandboxed iframe on the client.
|
|
richMode String @default("none")
|
|
richContent String? @db.Text
|
|
|
|
parent Message? @relation("ThreadReplies", fields: [parentId], references: [id])
|
|
replies Message[] @relation("ThreadReplies")
|
|
attachments Attachment[]
|
|
|
|
@@map("messages")
|
|
}
|
|
|
|
// ── Economy: fictional "crédits XIP", keyed on IP (no accounts) ──────────────
|
|
|
|
model Wallet {
|
|
ip String @id
|
|
balance Int @default(0) // centi-credits (9.99 "€" => 999)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("wallets")
|
|
}
|
|
|
|
// Seeded catalogue of purchasable features (faithful to the shop mockups).
|
|
model Product {
|
|
id String @id // slug: "cadre-pub","noads","style-dore","pet","bundle-cosmetic","rich-htmlcss","rich-js","no-file-limit","audio-alert"
|
|
category String // "publicite" | "abonnements" | "cosmetiques" | "promotions" | "premium"
|
|
name String
|
|
subtitle String?
|
|
kind String // "ad-frame" | "subscription" | "ip-skin" | "pet" | "bundle" | "rich" | "unlock" | "consumable"
|
|
basePrice Int // centi-credits
|
|
promoPrice Int?
|
|
badge String?
|
|
stockLimit Int? // e.g. 50 for style-dore; null = unlimited
|
|
stockSold Int @default(0)
|
|
active Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
metaJson String? @db.Text // options config (durations, formats, pet designs, plans…)
|
|
|
|
@@map("products")
|
|
}
|
|
|
|
// Append-only ledger: every credit movement (top-up, purchase, grant).
|
|
model Purchase {
|
|
id String @id @default(uuid())
|
|
ip String
|
|
productId String?
|
|
type String // "topup" | "purchase" | "grant"
|
|
amount Int // signed centi-credits: negative = spend, positive = grant
|
|
metaJson String? @db.Text
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([ip])
|
|
@@map("purchases")
|
|
}
|
|
|
|
// What an IP owns. Drives perks (skin/pets/noads), rich unlocks, ad frames, etc.
|
|
model Entitlement {
|
|
id String @id @default(uuid())
|
|
ip String
|
|
kind String // "noads" | "style-dore" | "pet" | "rich-htmlcss" | "rich-js" | "no-file-limit" | "ad-frame" | "audio-alert" | "element-skin"
|
|
active Boolean @default(true)
|
|
expiresAt DateTime? // subscriptions / ad-frame duration; null = permanent
|
|
metaJson String? @db.Text // pet: {design,position}; ad-frame: {format,url,days}; etc.
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([ip])
|
|
@@index([ip, kind])
|
|
@@map("entitlements")
|
|
}
|
|
|
|
// ── Real ad inventory (replaces the hardcoded AdBand / InlineCasinoAd) ───────
|
|
|
|
model Ad {
|
|
id String @id @default(uuid())
|
|
brand String
|
|
subtitle String?
|
|
url String?
|
|
cta String?
|
|
icon String?
|
|
tone String // "blue" | "green" | "purple" | "casino" | "user"
|
|
kind String // "band" | "casino"
|
|
weight Int @default(1)
|
|
active Boolean @default(true)
|
|
ownerIp String? // set when bought via "Cadre de Pub"
|
|
format String? // "static" | "gif"
|
|
imageUrl String?
|
|
expiresAt DateTime?
|
|
impressions Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([kind, active])
|
|
@@map("ads")
|
|
}
|
|
|
|
// ── File attachments (free <=1 Mo; paid "no-file-limit" lifts the cap) ───────
|
|
|
|
model Attachment {
|
|
id String @id @default(uuid())
|
|
messageId String?
|
|
ip String
|
|
filename String
|
|
mimeType String
|
|
size Int
|
|
storagePath String
|
|
createdAt DateTime @default(now())
|
|
|
|
message Message? @relation(fields: [messageId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([messageId])
|
|
@@map("attachments")
|
|
}
|