cre-sync/prisma/schema.prisma
BusyBee3333 4e6467ffb0 Add CRESync CRM application with Setup page
- Build complete Next.js CRM for commercial real estate
- Add authentication with JWT sessions and role-based access
- Add GoHighLevel API integration for contacts, conversations, opportunities
- Add AI-powered Control Center with tool calling
- Add Setup page with onboarding checklist (/setup)
- Add sidebar navigation with Setup menu item
- Fix type errors in onboarding API, GHL services, and control center tools
- Add Prisma schema with SQLite for local development
- Add UI components with clay morphism design system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:30:55 -05:00

154 lines
4.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
}
// Users table
model User {
id String @id @default(cuid())
email String @unique
passwordHash String
role String @default("USER") // SUPER_ADMIN, ADMIN, USER
// Profile info (from onboarding)
firstName String?
lastName String?
brokerage String?
// GHL connection (each user gets their own sub-account)
ghlLocationId String? @unique
ghlAccessToken String? // Encrypted
ghlRefreshToken String? // Encrypted
// Relations
onboarding OnboardingData?
setupStatus SetupStatus?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// Onboarding responses
model OnboardingData {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
// Experience
yearsInBusiness String?
gciLast12Months String?
// CRM
usingOtherCrm Boolean?
currentCrmName String?
crmPainPoints String? @default("[]") // JSON array of pain points
// Goals
goalsSelected String? @default("[]") // JSON array of goals
// Leads
hasLeadSource Boolean?
leadSourceName String?
wantsMoreLeads Boolean?
leadTypesDesired String? @default("[]") // JSON array
leadsPerMonthTarget String?
// Channels
channelsSelected String? @default("[]") // JSON array
// Systems to connect
systemsToConnect String? @default("[]") // JSON array
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// Setup progress tracking
model SetupStatus {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
smsConfigured Boolean @default(false)
emailConfigured Boolean @default(false)
contactsImported Boolean @default(false)
campaignsSetup Boolean @default(false)
updatedAt DateTime @updatedAt
}
// Admin/System Settings (singleton-ish, one per setting key)
model SystemSettings {
id String @id @default(cuid())
key String @unique
value String // Encrypted for sensitive values
isEncrypted Boolean @default(false)
updatedAt DateTime @updatedAt
updatedBy String? // User ID who last updated
}
// Audit log for admin actions
model AuditLog {
id String @id @default(cuid())
userId String
action String
resource String
resourceId String?
details Json?
ipAddress String?
createdAt DateTime @default(now())
}
// DFY (Done For You) service requests
model DFYRequest {
id String @id @default(cuid())
userId String
serviceType String // SMS_SETUP, EMAIL_SETUP, CAMPAIGN_SETUP, FULL_SETUP
status String @default("PENDING") // PENDING, IN_PROGRESS, COMPLETED, CANCELLED
// Stripe
stripePaymentId String?
amountPaid Int? // In cents
// Task management
clickupTaskId String?
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
completedAt DateTime?
}
// Control Center Conversations for AI Chat
model ControlCenterConversation {
id String @id @default(cuid())
userId String
title String?
messages ControlCenterMessage[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
}
model ControlCenterMessage {
id String @id @default(cuid())
conversationId String
conversation ControlCenterConversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
role String // 'user' | 'assistant'
content String
toolCalls Json? // Array of tool call objects
toolResults Json? // Array of tool result objects
model String? // 'claude' | 'openai' | model version
inputTokens Int?
outputTokens Int?
createdAt DateTime @default(now())
@@index([conversationId, createdAt])
}