RotNot / prisma /schema.prisma
deploy
Deploy RotNot
9580dce
Raw History Blame Contribute Delete
5.09 kB
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
}
model User {
id Int @id @default(autoincrement())
name String
level Int @default(1)
totalXp Int @default(0)
currentXp Int @default(0)
xpToNextLevel Int @default(100)
title String @default("Smooth Brain")
dailyGoalXp Int @default(100)
streak Int @default(0)
longestStreak Int @default(0)
streakFreezes Int @default(0)
lichessUsername String?
chesscomUsername String?
createdAt DateTime @default(now())
activities Activity[]
dailyLogs DailyLog[]
categorySkills CategorySkill[]
unlocks Unlock[]
spacedRepetitionItems SpacedRepetitionItem[]
}
model CategorySkill {
id Int @id @default(autoincrement())
userId Int
category String
level Int @default(1)
totalXp Int @default(0)
currentXp Int @default(0)
xpToNext Int @default(100)
user User @relation(fields: [userId], references: [id])
@@unique([userId, category])
}
model Activity {
id Int @id @default(autoincrement())
userId Int
category String
exerciseType String
description String
baseXp Int
qualityBonus Int @default(0)
isCriticalHit Boolean @default(false)
totalXp Int
score Float?
durationSecs Int?
metadata String?
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
}
model DailyLog {
id Int @id @default(autoincrement())
userId Int
date DateTime
xpEarned Int @default(0)
activityCount Int @default(0)
goalMet Boolean @default(false)
streakFreezeUsed Boolean @default(false)
user User @relation(fields: [userId], references: [id])
@@unique([userId, date])
}
model SkillTreeNode {
id Int @id @default(autoincrement())
category String
name String
description String
levelRequired Int
parentNodeId Int?
nodeType String
parent SkillTreeNode? @relation("NodeTree", fields: [parentNodeId], references: [id])
children SkillTreeNode[] @relation("NodeTree")
unlocks Unlock[]
@@unique([category, name])
}
model Unlock {
id Int @id @default(autoincrement())
userId Int
nodeId Int
unlockedAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
node SkillTreeNode @relation(fields: [nodeId], references: [id])
@@unique([userId, nodeId])
}
model ContentItem {
id Int @id @default(autoincrement())
category String
title String
content String
difficulty String
domain String
source String
metadata String?
createdAt DateTime @default(now())
}
model TopicSource {
id Int @id @default(autoincrement())
topicId String // matches Topic.id from feynman/topics.ts
url String // source URL
title String // source page/article title
excerpt String // relevant excerpt from the source
domain String // e.g., "wikipedia", "openstax", "arxiv"
license String // e.g., "CC BY-SA 4.0", "CC0", "public-domain"
confidence String @default("moderate") // "high", "moderate", "low"
verifiedAt DateTime? // when URL was last verified as live
createdAt DateTime @default(now())
@@index([topicId])
}
model TeachingCache {
id Int @id @default(autoincrement())
topicId String @unique // one cached teaching per topic
content String // the grounded teaching explanation (markdown)
sourcesJson String // JSON array of { url, title, domain, license } used
confidenceScore String @default("moderate") // "high" (2+ corroborating), "moderate" (1), "low" (extrapolated)
generatedAt DateTime @default(now())
verifiedAt DateTime? // when content was last verified against sources
@@index([topicId])
}
model SpacedRepetitionItem {
id Int @id @default(autoincrement())
userId Int
category String @default("feynman")
topicId String // matches Topic.id from feynman/topics.ts
topic String // human-readable topic name
domain String
difficulty String // beginner | intermediate | expert
stage Int @default(0) // 0=new, 1-5 = review stages
nextReviewAt DateTime // when the next review is due
lastReviewAt DateTime? // when last reviewed (null = never reviewed yet)
lastScore Float? // score from most recent review (0-1)
totalReviews Int @default(0)
successCount Int @default(0) // reviews scoring >= 0.6
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
@@unique([userId, topicId])
@@index([userId, nextReviewAt])
@@index([userId, category])
}