Full-stack inner development operating system built on Next.js 16 + Prisma 7 + PostgreSQL + OpenAI + Clerk. Generates personalized daily mental training tasks, collects reflection, updates user state, and provides internal reward feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
3.5 KiB
Plaintext
127 lines
3.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum TaskType {
|
|
attention_training
|
|
emotion_awareness
|
|
stress_regulation
|
|
cognitive_clarity
|
|
integration
|
|
}
|
|
|
|
enum TaskStatus {
|
|
pending
|
|
completed
|
|
expired
|
|
}
|
|
|
|
enum RewardEventType {
|
|
daily_completion
|
|
streak_3
|
|
streak_7
|
|
streak_14
|
|
streak_30
|
|
stage_up
|
|
first_session
|
|
}
|
|
|
|
model User {
|
|
id String @id // Clerk user ID
|
|
email String @unique
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
state UserState? @relation("UserState")
|
|
sessions Session[]
|
|
tasks Task[]
|
|
rewardEvents RewardEvent[]
|
|
weeklySummary WeeklySummary?
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model UserState {
|
|
id String @id @default(uuid())
|
|
userId String @unique @map("user_id")
|
|
attentionLevel Int @default(50) @map("attention_level")
|
|
emotionStability Int @default(50) @map("emotion_stability")
|
|
stressLevel Int @default(50) @map("stress_level")
|
|
practiceStage Int @default(0) @map("practice_stage")
|
|
consistencyScore Int @default(0) @map("consistency_score")
|
|
streakDays Int @default(0) @map("streak_days")
|
|
totalSessionsCompleted Int @default(0) @map("total_sessions_completed")
|
|
onboardingCompleted Boolean @default(false) @map("onboarding_completed")
|
|
lastSessionDate DateTime? @map("last_session_date")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
user User @relation("UserState", fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("user_states")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(uuid())
|
|
userId String @map("user_id")
|
|
taskType TaskType @map("task_type")
|
|
taskDescription String @map("task_description")
|
|
durationSeconds Int @default(300) @map("duration_seconds")
|
|
completed Boolean @default(false)
|
|
focusScore Int? @map("focus_score")
|
|
emotionScore Int? @map("emotion_score")
|
|
notes String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId, createdAt])
|
|
@@map("sessions")
|
|
}
|
|
|
|
model Task {
|
|
id String @id @default(uuid())
|
|
userId String @map("user_id")
|
|
type TaskType
|
|
difficulty Int @default(1)
|
|
duration Int @default(5)
|
|
description String
|
|
reasonJson String @default("{}") @map("reason_json")
|
|
status TaskStatus @default(pending)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId, createdAt])
|
|
@@index([userId, status])
|
|
@@map("tasks")
|
|
}
|
|
|
|
model RewardEvent {
|
|
id String @id @default(uuid())
|
|
userId String @map("user_id")
|
|
type RewardEventType
|
|
message String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId, createdAt])
|
|
@@map("reward_events")
|
|
}
|
|
|
|
model WeeklySummary {
|
|
id String @id @default(uuid())
|
|
userId String @unique @map("user_id")
|
|
summary String?
|
|
weekStart DateTime @map("week_start")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("weekly_summaries")
|
|
}
|