Skip to content

50+ open-source generative AI apps you can clone, deploy, and monetize — image generators, video tools, virtual try-ons, AI SaaS templates, and platform integrations. One-click Vercel deploy on every template.

2.7 KB
Raw Blame
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-3.0.x"]
}

datasource db {
  provider = "postgresql"
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String? @db.Text
  access_token      String? @db.Text
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String? @db.Text
  session_state     String?
  user              User    @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id             String          @id @default(cuid())
  name           String?
  email          String?         @unique
  emailVerified  DateTime?
  image          String?
  credits        Int             @default(10)
  accounts       Account[]
  sessions       Session[]
  knowledgeBases KnowledgeBase[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

model KnowledgeBase {
  id          String   @id @default(cuid())
  name        String
  description String?  @db.Text
  userId      String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  user        User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  sources     Source[]
  chats       KBChat[]
}

model Source {
  id              String        @id @default(cuid())
  knowledgeBaseId String
  type            String        // file | url | qa
  name            String
  content         String        @db.Text
  createdAt       DateTime      @default(now())
  knowledgeBase   KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id], onDelete: Cascade)
}

model KBChat {
  id              String        @id @default(cuid())
  knowledgeBaseId String
  userId          String
  title           String
  createdAt       DateTime      @default(now())
  knowledgeBase   KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id], onDelete: Cascade)
  messages        KBMessage[]
}

model KBMessage {
  id        String   @id @default(cuid())
  chatId    String
  role      String   // user | assistant
  content   String   @db.Text
  citations String?  @db.Text
  createdAt DateTime @default(now())
  chat      KBChat   @relation(fields: [chatId], references: [id], onDelete: Cascade)
}