File size: 5,086 Bytes
9580dce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | 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])
}
|