2026-03-25 13:52:45 +01:00
|
|
|
generator client {
|
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
|
provider = "postgresql"
|
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model User {
|
2026-04-12 19:24:24 +01:00
|
|
|
id String @id @default(cuid())
|
|
|
|
|
clerkId String @unique
|
|
|
|
|
email String @unique
|
2026-03-25 13:52:45 +01:00
|
|
|
firstName String?
|
|
|
|
|
lastName String?
|
|
|
|
|
imageUrl String?
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-04-22 11:04:59 +01:00
|
|
|
contracts Contract[]
|
|
|
|
|
notifications Notification[]
|
|
|
|
|
blockchainTransactions BlockchainTransaction[]
|
2026-04-12 19:24:24 +01:00
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
@@index([clerkId])
|
|
|
|
|
@@index([email])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Contract {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// File info (user uploads)
|
2026-04-12 19:24:24 +01:00
|
|
|
fileName String
|
|
|
|
|
fileUrl String
|
|
|
|
|
fileSize Int
|
|
|
|
|
mimeType String
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// AI-determined fields (filled automatically)
|
2026-04-12 19:24:24 +01:00
|
|
|
title String?
|
|
|
|
|
type ContractType?
|
|
|
|
|
provider String?
|
|
|
|
|
policyNumber String?
|
|
|
|
|
startDate DateTime?
|
|
|
|
|
endDate DateTime?
|
|
|
|
|
premium Decimal? @db.Decimal(10, 2)
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// Processing pipeline
|
2026-04-12 19:24:24 +01:00
|
|
|
status ContractStatus @default(UPLOADED)
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// AI results
|
2026-04-12 19:24:24 +01:00
|
|
|
extractedText String? @db.Text
|
|
|
|
|
summary String? @db.Text
|
|
|
|
|
keyPoints Json?
|
|
|
|
|
|
2026-04-22 11:04:59 +01:00
|
|
|
// Blockchain proof-of-deposit
|
|
|
|
|
documentHash String? // SHA-256 hash of the document
|
|
|
|
|
txHash String? // Ethereum transaction hash
|
|
|
|
|
blockNumber Int? // Block number where tx was mined
|
|
|
|
|
blockTimestamp DateTime? // Timestamp of the block
|
|
|
|
|
blockchainNetwork String? // 'hardhat' | 'sepolia'
|
|
|
|
|
contractAddress String? // Smart contract address used
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-04-22 11:04:59 +01:00
|
|
|
// Relations
|
|
|
|
|
notifications Notification[]
|
|
|
|
|
ragChunks ContractRagChunk[]
|
|
|
|
|
blockchainTransactions BlockchainTransaction[]
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
@@index([userId])
|
|
|
|
|
@@index([status])
|
|
|
|
|
@@index([type])
|
|
|
|
|
@@index([endDate])
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 19:24:24 +01:00
|
|
|
model ContractRagChunk {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
contractId String
|
|
|
|
|
contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
chunkIndex Int
|
|
|
|
|
content String
|
|
|
|
|
contentHash String
|
|
|
|
|
embedding Float[]
|
|
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
@@unique([contractId, chunkIndex])
|
|
|
|
|
@@index([contractId])
|
|
|
|
|
@@index([contentHash])
|
|
|
|
|
@@index([chunkIndex])
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
model Notification {
|
2026-04-12 19:24:24 +01:00
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
contractId String?
|
|
|
|
|
contract Contract? @relation(fields: [contractId], references: [id], onDelete: SetNull)
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// Notification metadata
|
2026-04-12 19:24:24 +01:00
|
|
|
type NotificationType
|
|
|
|
|
title String
|
|
|
|
|
message String
|
|
|
|
|
icon String? // Icon type for UI
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// Action metadata
|
2026-04-12 19:24:24 +01:00
|
|
|
actionType String? // e.g., "RENEWAL_REMINDER", "UPLOAD_SUCCESS", "ANALYSIS_COMPLETE"
|
|
|
|
|
actionData Json? // Additional data for the action
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
// Status tracking
|
2026-04-12 19:24:24 +01:00
|
|
|
read Boolean @default(false)
|
|
|
|
|
createdAt DateTime @default(now())
|
2026-03-25 13:52:45 +01:00
|
|
|
expiresAt DateTime? // Notification expiration time
|
2026-04-12 19:24:24 +01:00
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
@@index([userId])
|
|
|
|
|
@@index([contractId])
|
|
|
|
|
@@index([type])
|
|
|
|
|
@@index([read])
|
|
|
|
|
@@index([createdAt])
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:04:59 +01:00
|
|
|
model BlockchainTransaction {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
contractId String
|
|
|
|
|
contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
documentHash String // SHA-256 hash of the document
|
|
|
|
|
txHash String @unique // Ethereum transaction hash
|
|
|
|
|
blockNumber Int // Block number where tx was mined
|
|
|
|
|
blockTimestamp DateTime // Block timestamp = proof date
|
|
|
|
|
network String // 'hardhat' | 'sepolia'
|
|
|
|
|
contractAddress String // Smart contract address used
|
|
|
|
|
status String @default("CONFIRMED") // PENDING, CONFIRMED, FAILED
|
|
|
|
|
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
@@index([userId])
|
|
|
|
|
@@index([contractId])
|
|
|
|
|
@@index([txHash])
|
|
|
|
|
@@index([network])
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 13:52:45 +01:00
|
|
|
enum NotificationType {
|
2026-04-12 19:24:24 +01:00
|
|
|
SUCCESS // Successful action
|
|
|
|
|
WARNING // Warning/Alert
|
|
|
|
|
ERROR // Error
|
|
|
|
|
INFO // Informational
|
|
|
|
|
DEADLINE // Deadline approaching
|
2026-03-25 13:52:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum ContractType {
|
|
|
|
|
INSURANCE_AUTO
|
|
|
|
|
INSURANCE_HOME
|
|
|
|
|
INSURANCE_HEALTH
|
|
|
|
|
INSURANCE_LIFE
|
|
|
|
|
LOAN
|
|
|
|
|
CREDIT_CARD
|
|
|
|
|
INVESTMENT
|
|
|
|
|
OTHER
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum ContractStatus {
|
2026-04-12 19:24:24 +01:00
|
|
|
UPLOADED // Just uploaded, waiting for processing
|
|
|
|
|
PROCESSING // AI is analyzing
|
|
|
|
|
COMPLETED // Everything done
|
|
|
|
|
FAILED // Processing failed
|
2026-03-25 13:52:45 +01:00
|
|
|
}
|