Files
auto_rfp/prisma/schema.prisma
T

156 lines
4.1 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
model User {
id String @id
email String @unique
name String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relationships
organizationUsers OrganizationUser[]
@@map("users")
}
model Organization {
id String @id @default(cuid())
name String
slug String @unique
description String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// LlamaCloud Project integration (project-specific connection)
llamaCloudProjectId String?
llamaCloudProjectName String?
llamaCloudOrgName String?
llamaCloudConnectedAt DateTime?
// Relationships
projects Project[]
organizationUsers OrganizationUser[]
@@map("organizations")
}
model OrganizationUser {
id String @id @default(cuid())
role String @default("member") // "owner", "admin", "member"
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Foreign keys
userId String
organizationId String
// Relationships
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
@@unique([userId, organizationId])
@@index([organizationId])
@@map("organization_users")
}
model Project {
id String @id @default(cuid())
name String
description String?
summary String? // RFP summary generated from uploaded documents
eligibility String[] // Vendor eligibility requirements as bullet points
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
questions Question[]
// Foreign key
organizationId String
// Relationships
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
projectIndexes ProjectIndex[]
@@index([organizationId])
@@map("projects")
}
model ProjectIndex {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// LlamaCloud index information (mapped from pipeline API)
indexId String // LlamaCloud pipeline ID (stored as indexId for clarity)
indexName String // LlamaCloud pipeline name (stored as indexName for clarity)
// Foreign key
projectId String
// Relationships
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
@@unique([projectId, indexId])
@@index([projectId])
@@map("project_indexes")
}
model Question {
id String @id @default(cuid())
referenceId String? // AI-generated ID like "question_1.10.1" for document structure reference
text String
topic String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
answer Answer?
projectId String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
@@index([projectId])
@@index([projectId, referenceId]) // Composite index for efficient lookups
@@map("questions")
}
model Answer {
id String @id @default(cuid())
text String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sources Source[]
questionId String @unique
question Question @relation(fields: [questionId], references: [id], onDelete: Cascade)
@@map("answers")
}
model Source {
id String @id @default(cuid())
fileName String
filePath String?
pageNumber String?
documentId String?
relevance Int?
textContent String? @db.Text
createdAt DateTime @default(now())
answerId String
answer Answer @relation(fields: [answerId], references: [id], onDelete: Cascade)
@@index([answerId])
@@map("sources")
}