File size: 3,348 Bytes
bf04727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8aba1e2
 
 
 
 
 
 
 
 
 
 
 
 
bf04727
 
 
8aba1e2
bf04727
 
 
 
 
8aba1e2
 
 
bf04727
 
 
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
// Prisma schema reference (PostgreSQL target)
// For production use: npx prisma db push

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id                  String   @id @default(uuid())
  email               String   @unique
  name                String
  createdAt           DateTime @default(now()) @map("created_at")
  baselinePitch       Float?   @map("baseline_pitch")
  baselineEnergy      Float?   @map("baseline_energy")
  baselineSpeechRate  Float?   @map("baseline_speech_rate")

  voiceEntries  VoiceEntry[]
  moodAlerts    MoodAlert[]
  chatMessages  ChatMessage[]

  @@map("users")
}

model VoiceEntry {
  id                String   @id @default(uuid())
  userId            String   @map("user_id")
  createdAt         DateTime @default(now()) @map("created_at")
  audioUrl          String?  @map("audio_url")
  durationSeconds   Float?   @map("duration_seconds")
  transcription     String?
  primaryEmotion    String?  @map("primary_emotion")
  emotionConfidence Float?   @map("emotion_confidence")
  energyScore       Int?     @map("energy_score")
  calmnessScore     Int?     @map("calmness_score")
  moodScore         Int?     @map("mood_score")
  clarityScore      Int?     @map("clarity_score")
  pitchMean         Float?   @map("pitch_mean")
  pitchStd          Float?   @map("pitch_std")
  energyRaw         Float?   @map("energy_raw")
  speechRate        Float?   @map("speech_rate")
  pauseCount        Int?     @map("pause_count")
  avgPauseDuration  Float?   @map("avg_pause_duration")
  fillerRate        Float?   @map("filler_rate")
  mfccFeatures      Json?    @map("mfcc_features")

  user         User          @relation(fields: [userId], references: [id], onDelete: Cascade)
  chatMessages ChatMessage[]

  @@map("voice_entries")
}

model MoodAlert {
  id              String   @id @default(uuid())
  userId          String   @map("user_id")
  createdAt       DateTime @default(now()) @map("created_at")
  alertType       String   @map("alert_type")
  severity        String
  message         String
  isRead          Boolean  @default(false) @map("is_read")
  suggestedAction String?  @map("suggested_action")

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@map("mood_alerts")
}

model ChatChannel {
  id        String   @id @default(uuid())
  userId    String   @map("user_id")
  title     String   @default("New Chat")
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt @map("updated_at")

  user     User          @relation(fields: [userId], references: [id], onDelete: Cascade)
  messages ChatMessage[]

  @@map("chat_channels")
}

model ChatMessage {
  id           String   @id @default(uuid())
  userId       String   @map("user_id")
  channelId    String?  @map("channel_id")
  createdAt    DateTime @default(now()) @map("created_at")
  role         String
  content      String
  voiceEntryId String?  @map("voice_entry_id")

  user       User         @relation(fields: [userId], references: [id], onDelete: Cascade)
  channel    ChatChannel? @relation(fields: [channelId], references: [id], onDelete: Cascade)
  voiceEntry VoiceEntry?  @relation(fields: [voiceEntryId], references: [id])

  @@map("chat_messages")
}