Skip to main content

Database Schema Overview

The database uses PostgreSQL 16 with Prisma ORM 6. The schema contains 69+ models across approximately 1940 lines, located at Pulse/apps/api/prisma/schema.prisma.


Model Inventory by Domain

Core (Users & Workspaces) -- 5 Models

ModelPurposeKey Fields
UserPlatform usersid, email, name, passwordHash, isSuperAdmin
OtpCodeOne-time password codes for verificationuserId, code, type, expiresAt
WorkspaceMulti-tenant workspaceid, name, slug, ownerId
WorkspaceMemberUser-workspace membership with roleuserId, workspaceId, role (OWNER/ADMIN/EDITOR/VIEWER/CLIENT)
WorkspaceInvitationPending workspace invitationsemail, workspaceId, role, token

Billing & Plans -- 6 Models

ModelPurposeKey Fields
PlanSubscription plan definitionsid, name, price, interval
FeatureGatable platform featuresid, key, name
PlanFeatureFeature-to-plan mappingplanId, featureId, limit
SubscriptionActive workspace subscriptionsworkspaceId, planId, status, currentPeriodEnd
TransactionPayment transactionsworkspaceId, amount, provider, status
PaymentMethodStored payment methodsworkspaceId, provider, last4

Social Accounts -- 1 Model

ModelPurposeKey Fields
SocialAccountConnected social platform accountsworkspaceId, platform, accessToken (encrypted), refreshToken (encrypted)

Content & Publishing -- 5 Models

ModelPurposeKey Fields
PostSocial media postsworkspaceId, caption, status, scheduledAt
MediaFileUploaded media filesworkspaceId, url, type, size
PostMediaPost-to-media join tablepostId, mediaFileId, order
PostPublicationPer-platform publication recordpostId, platform, platformPostId, status
PostMetricPer-publication engagement metricspublicationId, likes, comments, shares, reach, date

Analytics & Predictions -- 10 Models

ModelPurposeKey Fields
ABTestA/B test definitionsworkspaceId, name, status, startDate, endDate
ScheduleScheduled post triggerspostId, scheduledAt, status
PostClassificationAI-classified post content typepostId, category, tags, confidence
PostEmbeddingVector embeddings for similaritypostId, embedding (vector), model
IndustryBenchmarkIndustry performance benchmarksindustry, metric, value, percentile
HashtagScoreHashtag performance scoringhashtag, workspaceId, score, uses
NicheBenchmarkNiche-specific benchmarksniche, metric, value
AlgorithmChangeDetectionDetected platform algorithm changesplatform, detectedAt, impact
EngagementPredictionAI engagement forecastspostId, predictedLikes, confidence
RevenuePredictionAI revenue forecastsworkspaceId, predictedRevenue, period
PredictionAccuracyPrediction accuracy trackingpredictionId, actualValue, accuracy

AI -- 5 Models

ModelPurposeKey Fields
AiPromptLogAI API call loggingworkspaceId, promptType, tokens, model
AiChatMessageAI chat conversation historyworkspaceId, role, content, threadId
AiSuggestionAI-generated content suggestionsworkspaceId, type, content, status
BrandVoiceBrand voice configurationworkspaceId, name, description, samples
ContentCalendarAI-generated content calendarsworkspaceId, name, startDate, endDate
CalendarEntryIndividual calendar post entriescalendarId, date, content, platform

Workflows -- 3 Models

ModelPurposeKey Fields
WorkflowWorkflow definitionsworkspaceId, name, nodes (JSON), edges (JSON), status
WorkflowRunWorkflow execution recordsworkflowId, status, startedAt, completedAt, logs
WorkflowOptimizationLogWorkflow performance optimizationworkflowId, suggestion, applied

Competitors -- 3 Models

ModelPurposeKey Fields
CompetitorTracked competitor profilesworkspaceId, name, platforms, socialUrls
CompetitorSnapshotPoint-in-time competitor metricscompetitorId, followers, engagement, date
CompetitorReportGenerated competitor comparison reportsworkspaceId, competitorIds, analysis

Ads -- 2 Models

ModelPurposeKey Fields
AdCampaignAd campaign recordsworkspaceId, platform, budget, status, metrics
AutoBoostRuleAutomatic post boosting rulesworkspaceId, conditions, budget, enabled

E-Commerce -- 4 Models

ModelPurposeKey Fields
EcommerceStoreConnected store (Shopify/WooCommerce/EasyOrders)workspaceId, provider, storeUrl, credentials
EcommerceProductSynced product catalogstoreId, name, price, externalId
ProductPostTemplateTemplates linking products to postsproductId, templateContent

Commerce & Revenue -- 5 Models

ModelPurposeKey Fields
CommerceCustomerCustomer records from storesworkspaceId, email, name, totalOrders
CommerceOrderOrder recordsworkspaceId, storeId, total, status
OrderLineItemIndividual order line itemsorderId, productId, quantity, price
RevenueAttributionPost-to-order revenue attributionpostId, orderId, amount, utmParams
PostRevenueAggregated revenue per postpostId, totalRevenue, orderCount
CouponGeneratedAI-generated discount couponsworkspaceId, code, discount, usageCount

Agency & Collaboration -- 3 Models

ModelPurposeKey Fields
ApprovalRequestContent approval workflowspostId, requesterId, status, reviewerId
ClientReportGenerated client reportsworkspaceId, dateRange, data, generatedAt
WorkspaceProfilePublic workspace profile/brandingworkspaceId, logo, colors, description

Audience & CRM -- 5 Models

ModelPurposeKey Fields
AudienceNodeAudience member profiles in the graphworkspaceId, name, platform, engagementScore
AudienceInteractionIndividual interactions with audiencenodeId, type, content, date
AudienceSegmentAudience segmentsworkspaceId, name, rules, memberCount
AudienceTagTags applied to audience membersnodeId, tag

Conversations (ICE) -- 7 Models

ModelPurposeKey Fields
ConversationThreadConversation threads from social platformsworkspaceId, platform, status, assignedTo
ConversationMessageIndividual messages in threadsthreadId, direction, content, sentAt
BotConfigurationAI bot settings per workspaceworkspaceId, enabled, autoReplyIntents, confidence
EscalationRuleRules for escalating to humansworkspaceId, conditions, assignTo, priority
EscalationEscalation recordsthreadId, ruleId, status, assignedTo
ConversationMemory3-tier memory for conversation contextaudienceNodeId, tier, data, expiresAt
ReplyExperimentA/B experiments on reply strategiesworkspaceId, variants, metrics, status

System -- 4 Models

ModelPurposeKey Fields
WebhookConversationIncoming webhook logsource, payload, processedAt
NotificationUser notificationsuserId, type, title, read
WorkspaceUsageMonthly usage tracking per workspaceworkspaceId, period, aiGenerations, postsPublished
AuditLogAudit trail for all actionsworkspaceId, userId, action, resource, details

Model Count Summary

DomainModel Count
Core (Users & Workspaces)5
Billing & Plans6
Social Accounts1
Content & Publishing5
Analytics & Predictions11
AI6
Workflows3
Competitors3
Ads2
E-Commerce4
Commerce & Revenue6
Agency & Collaboration3
Audience & CRM4
Conversations (ICE)7
System4
Total69+

Cross-Reference