E5K7 commited on
Commit
8aba1e2
·
1 Parent(s): b5e8a53

feat: Weekly Report — Spotify Wrapped-style emotional summary with mood arc, AI narrative, emotion breakdown, and one-click image export

Browse files
backend/main.py CHANGED
@@ -15,6 +15,7 @@ from routes.trends import router as trends_router
15
  from routes.alerts import router as alerts_router
16
  from routes.chat import router as chat_router
17
  from routes.auth import router as auth_router
 
18
 
19
  app = FastAPI(
20
  title="InnerVoice API",
@@ -56,6 +57,7 @@ app.include_router(trends_router, prefix="/api")
56
  app.include_router(alerts_router, prefix="/api")
57
  app.include_router(chat_router, prefix="/api")
58
  app.include_router(auth_router, prefix="/api")
 
59
 
60
 
61
  @app.get("/api/health")
 
15
  from routes.alerts import router as alerts_router
16
  from routes.chat import router as chat_router
17
  from routes.auth import router as auth_router
18
+ from routes.weekly_report import router as weekly_report_router
19
 
20
  app = FastAPI(
21
  title="InnerVoice API",
 
57
  app.include_router(alerts_router, prefix="/api")
58
  app.include_router(chat_router, prefix="/api")
59
  app.include_router(auth_router, prefix="/api")
60
+ app.include_router(weekly_report_router, prefix="/api")
61
 
62
 
63
  @app.get("/api/health")
backend/routes/weekly_report.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ GET /api/weekly-report — generate a rich weekly emotional summary
3
+ """
4
+ from fastapi import APIRouter, Depends
5
+ from sqlalchemy.orm import Session
6
+ from models.database import get_db, VoiceEntry, User
7
+ from routes.auth import get_current_user
8
+ from services.gpt_service import generate_weekly_narrative
9
+ from datetime import datetime, timedelta
10
+ from statistics import mean
11
+ from collections import Counter, defaultdict
12
+
13
+ router = APIRouter()
14
+
15
+ EMOTION_EMOJI = {
16
+ "happy": "😊", "sad": "😢", "angry": "😤", "fearful": "😰",
17
+ "neutral": "😐", "disgust": "😒", "surprised": "😲", "calm": "😌",
18
+ }
19
+
20
+ EMOTION_COLOR = {
21
+ "happy": "#f59e0b", "sad": "#60a5fa", "angry": "#ef4444", "fearful": "#a78bfa",
22
+ "neutral": "#6b7280", "disgust": "#10b981", "surprised": "#f97316", "calm": "#34d399",
23
+ }
24
+
25
+ def safe_mean(values):
26
+ clean = [v for v in values if v is not None]
27
+ return round(mean(clean), 1) if clean else None
28
+
29
+
30
+ @router.get("/weekly-report")
31
+ def get_weekly_report(
32
+ current_user: User = Depends(get_current_user),
33
+ db: Session = Depends(get_db),
34
+ ):
35
+ now = datetime.utcnow()
36
+ week_start = now - timedelta(days=7)
37
+
38
+ week_entries = (
39
+ db.query(VoiceEntry)
40
+ .filter(
41
+ VoiceEntry.user_id == current_user.id,
42
+ VoiceEntry.created_at >= week_start,
43
+ )
44
+ .order_by(VoiceEntry.created_at.asc())
45
+ .all()
46
+ )
47
+
48
+ if not week_entries:
49
+ return {"has_data": False}
50
+
51
+ # ── Core stats ────────────────────────────────────────────────────────────
52
+ mood_scores = [e.mood_score for e in week_entries if e.mood_score is not None]
53
+ energy_scores = [e.energy_score for e in week_entries if e.energy_score is not None]
54
+ calm_scores = [e.calmness_score for e in week_entries if e.calmness_score is not None]
55
+ clarity_scores = [e.clarity_score for e in week_entries if e.clarity_score is not None]
56
+
57
+ avg_mood = safe_mean(mood_scores)
58
+ avg_energy = safe_mean(energy_scores)
59
+ avg_calm = safe_mean(calm_scores)
60
+ avg_clarity = safe_mean(clarity_scores)
61
+
62
+ # ── Best & worst day ─────────────────────────────────────────────────────
63
+ best_entry = max(week_entries, key=lambda e: e.mood_score or 0)
64
+ worst_entry = min(week_entries, key=lambda e: e.mood_score or 100)
65
+
66
+ # ── Dominant emotion ─────────────────────────────────────────────────────
67
+ emotion_counts = Counter(e.primary_emotion for e in week_entries if e.primary_emotion)
68
+ top_emotion = emotion_counts.most_common(1)[0][0] if emotion_counts else "neutral"
69
+ top_emotion_pct = round(emotion_counts[top_emotion] / len(week_entries) * 100) if emotion_counts else 0
70
+
71
+ # ── Mood arc for sparkline (daily avg) ────────────────────────────────────
72
+ day_buckets = defaultdict(list)
73
+ for e in week_entries:
74
+ day_key = e.created_at.strftime("%a")
75
+ if e.mood_score is not None:
76
+ day_buckets[day_key].append(e.mood_score)
77
+
78
+ # Build ordered 7-day array
79
+ days_ordered = []
80
+ for i in range(6, -1, -1):
81
+ d = now - timedelta(days=i)
82
+ key = d.strftime("%a")
83
+ days_ordered.append({
84
+ "day": key,
85
+ "date": d.strftime("%b %d"),
86
+ "avg_mood": round(mean(day_buckets[key]), 1) if day_buckets.get(key) else None,
87
+ })
88
+
89
+ # ── Mood delta vs previous week ───────────────────────────────────────────
90
+ prev_week_start = week_start - timedelta(days=7)
91
+ prev_entries = (
92
+ db.query(VoiceEntry)
93
+ .filter(
94
+ VoiceEntry.user_id == current_user.id,
95
+ VoiceEntry.created_at >= prev_week_start,
96
+ VoiceEntry.created_at < week_start,
97
+ )
98
+ .all()
99
+ )
100
+ prev_mood_avg = safe_mean([e.mood_score for e in prev_entries if e.mood_score is not None])
101
+ mood_delta = round(avg_mood - prev_mood_avg, 1) if avg_mood and prev_mood_avg else None
102
+
103
+ # ── Streak ────────────────────────────────────────────────────────────────
104
+ all_dates = {e.created_at.date() for e in db.query(VoiceEntry)
105
+ .filter(VoiceEntry.user_id == current_user.id).all()}
106
+ streak = 0
107
+ check = now.date()
108
+ while check in all_dates:
109
+ streak += 1
110
+ check -= timedelta(days=1)
111
+
112
+ # ── Most expressive moment ────────────────────────────────────���───────────
113
+ most_expressive = max(
114
+ (e for e in week_entries if e.transcription),
115
+ key=lambda e: len(e.transcription or ""),
116
+ default=None,
117
+ )
118
+
119
+ # ── LLM narrative ─────────────────────────────────────────────────────────
120
+ narrative = generate_weekly_narrative(
121
+ top_emotion=top_emotion,
122
+ avg_mood=avg_mood,
123
+ avg_energy=avg_energy,
124
+ avg_calm=avg_calm,
125
+ mood_delta=mood_delta,
126
+ entry_count=len(week_entries),
127
+ streak=streak,
128
+ best_day=best_entry.created_at.strftime("%A") if best_entry else None,
129
+ worst_day=worst_entry.created_at.strftime("%A") if worst_entry else None,
130
+ transcriptions=[e.transcription for e in week_entries if e.transcription][:5],
131
+ )
132
+
133
+ return {
134
+ "has_data": True,
135
+ "week_label": f"{week_start.strftime('%b %d')} – {now.strftime('%b %d, %Y')}",
136
+ "entry_count": len(week_entries),
137
+ "streak": streak,
138
+ "top_emotion": top_emotion,
139
+ "top_emotion_emoji": EMOTION_EMOJI.get(top_emotion, "💭"),
140
+ "top_emotion_color": EMOTION_COLOR.get(top_emotion, "#6b7280"),
141
+ "top_emotion_pct": top_emotion_pct,
142
+ "avg_mood": avg_mood,
143
+ "avg_energy": avg_energy,
144
+ "avg_calm": avg_calm,
145
+ "avg_clarity": avg_clarity,
146
+ "mood_delta": mood_delta,
147
+ "best_day": {
148
+ "date": best_entry.created_at.strftime("%A, %b %d"),
149
+ "mood": best_entry.mood_score,
150
+ "emotion": best_entry.primary_emotion,
151
+ } if best_entry else None,
152
+ "worst_day": {
153
+ "date": worst_entry.created_at.strftime("%A, %b %d"),
154
+ "mood": worst_entry.mood_score,
155
+ "emotion": worst_entry.primary_emotion,
156
+ } if worst_entry else None,
157
+ "mood_arc": days_ordered,
158
+ "most_expressive_moment": most_expressive.transcription[:200] if most_expressive else None,
159
+ "narrative": narrative,
160
+ "emotion_breakdown": [
161
+ {"emotion": k, "count": v, "pct": round(v / len(week_entries) * 100), "color": EMOTION_COLOR.get(k, "#6b7280")}
162
+ for k, v in emotion_counts.most_common()
163
+ ],
164
+ }
backend/services/gpt_service.py CHANGED
@@ -79,6 +79,60 @@ Write a warm 2-3 sentence insight about their emotional state right now. Be empa
79
  return _fallback_insight(emotion, mood_scores)
80
 
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  def chat_response(
83
  user_message: str,
84
  recent_entries: list,
 
79
  return _fallback_insight(emotion, mood_scores)
80
 
81
 
82
+ def generate_weekly_narrative(
83
+ top_emotion: str,
84
+ avg_mood: float,
85
+ avg_energy: float,
86
+ avg_calm: float,
87
+ mood_delta: Optional[float],
88
+ entry_count: int,
89
+ streak: int,
90
+ best_day: Optional[str],
91
+ worst_day: Optional[str],
92
+ transcriptions: list,
93
+ ) -> str:
94
+ """Generate a warm, personalised weekly summary narrative."""
95
+ client = _get_client()
96
+
97
+ delta_str = ""
98
+ if mood_delta is not None:
99
+ direction = "up" if mood_delta > 0 else "down"
100
+ delta_str = f"Your average mood is {direction} {abs(mood_delta)} points vs last week."
101
+
102
+ excerpts = " | ".join(f'"{t[:80]}"' for t in transcriptions if t) if transcriptions else ""
103
+
104
+ prompt = f"""Generate a warm, empathetic 3-sentence weekly emotional summary for a user.
105
+
106
+ Data:
107
+ - Check-ins: {entry_count}, Streak: {streak} days
108
+ - Top emotion: {top_emotion}, Avg mood: {avg_mood}/100, Energy: {avg_energy}/100, Calm: {avg_calm}/100
109
+ - {delta_str}
110
+ - Best day: {best_day or 'N/A'}, Lowest day: {worst_day or 'N/A'}
111
+ - Voice excerpts: {excerpts}
112
+
113
+ Write in second person. Be warm and specific. End with one gentle insight about the week. No clinical language. Don't start with "I"."""
114
+
115
+ try:
116
+ response = client.chat.completions.create(
117
+ model=OPENROUTER_MODEL,
118
+ messages=[
119
+ {"role": "system", "content": "You are a warm emotional wellness companion writing a personalised weekly summary."},
120
+ {"role": "user", "content": prompt},
121
+ ],
122
+ max_tokens=200,
123
+ temperature=0.85,
124
+ )
125
+ return response.choices[0].message.content.strip()
126
+ except Exception as e:
127
+ print(f"[GPTService] generate_weekly_narrative error: {e}")
128
+ direction = "higher" if (mood_delta or 0) > 0 else "lower"
129
+ return (
130
+ f"This week you showed up {entry_count} time{'s' if entry_count != 1 else ''} — and that consistency matters. "
131
+ f"Your dominant emotion was {top_emotion}, with an average mood of {avg_mood}/100. "
132
+ f"{'Your mood trended ' + direction + ' compared to last week.' if mood_delta else 'Keep building — every check-in is a small act of self-care.'}"
133
+ )
134
+
135
+
136
  def chat_response(
137
  user_message: str,
138
  recent_entries: list,
frontend/app/report/page.tsx ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+ import { useEffect, useState, useRef } from "react";
3
+ import { api } from "@/lib/api";
4
+ import { useDemoMode } from "@/hooks/useDemoMode";
5
+ import { motion } from "framer-motion";
6
+ import { Download, Share2, TrendingUp, TrendingDown, Flame, Calendar, Mic } from "lucide-react";
7
+
8
+ interface WeeklyReport {
9
+ has_data: boolean;
10
+ week_label: string;
11
+ entry_count: number;
12
+ streak: number;
13
+ top_emotion: string;
14
+ top_emotion_emoji: string;
15
+ top_emotion_color: string;
16
+ top_emotion_pct: number;
17
+ avg_mood: number;
18
+ avg_energy: number;
19
+ avg_calm: number;
20
+ avg_clarity: number;
21
+ mood_delta: number | null;
22
+ best_day: { date: string; mood: number; emotion: string } | null;
23
+ worst_day: { date: string; mood: number; emotion: string } | null;
24
+ mood_arc: Array<{ day: string; date: string; avg_mood: number | null }>;
25
+ most_expressive_moment: string | null;
26
+ narrative: string;
27
+ emotion_breakdown: Array<{ emotion: string; count: number; pct: number; color: string }>;
28
+ }
29
+
30
+ const DEMO_REPORT: WeeklyReport = {
31
+ has_data: true,
32
+ week_label: "Apr 4 – Apr 11, 2025",
33
+ entry_count: 6,
34
+ streak: 4,
35
+ top_emotion: "neutral",
36
+ top_emotion_emoji: "😐",
37
+ top_emotion_color: "#6b7280",
38
+ top_emotion_pct: 50,
39
+ avg_mood: 57,
40
+ avg_energy: 61,
41
+ avg_calm: 54,
42
+ avg_clarity: 60,
43
+ mood_delta: +4.2,
44
+ best_day: { date: "Tuesday, Apr 8", mood: 72, emotion: "happy" },
45
+ worst_day: { date: "Thursday, Apr 10", mood: 41, emotion: "sad" },
46
+ mood_arc: [
47
+ { day: "Fri", date: "Apr 5", avg_mood: 55 },
48
+ { day: "Sat", date: "Apr 6", avg_mood: null },
49
+ { day: "Sun", date: "Apr 7", avg_mood: 60 },
50
+ { day: "Mon", date: "Apr 8", avg_mood: 72 },
51
+ { day: "Tue", date: "Apr 9", avg_mood: 58 },
52
+ { day: "Wed", date: "Apr 10", avg_mood: 41 },
53
+ { day: "Thu", date: "Apr 11", avg_mood: 56 },
54
+ ],
55
+ most_expressive_moment: "I'm feeling really sad nowadays. I don't know what's up with me, to be honest, but there is something different.",
56
+ narrative: "This week you showed real resilience, checking in 6 times even through some emotionally heavy moments. Your mood peaked on Tuesday, and while Thursday brought a dip, you kept coming back — and that matters more than any single score. The steady rhythm you're building is quietly becoming your emotional anchor.",
57
+ emotion_breakdown: [
58
+ { emotion: "neutral", count: 3, pct: 50, color: "#6b7280" },
59
+ { emotion: "sad", count: 2, pct: 33, color: "#60a5fa" },
60
+ { emotion: "happy", count: 1, pct: 17, color: "#f59e0b" },
61
+ ],
62
+ };
63
+
64
+ function Sparkline({ arc }: { arc: WeeklyReport["mood_arc"] }) {
65
+ const w = 420, h = 80, pad = 10;
66
+ const values = arc.map(d => d.avg_mood);
67
+ const filled = values.filter(v => v !== null) as number[];
68
+ if (filled.length === 0) return null;
69
+
70
+ const min = Math.min(...filled) - 5;
71
+ const max = Math.max(...filled) + 5;
72
+ const xStep = (w - pad * 2) / (arc.length - 1);
73
+
74
+ const points = arc
75
+ .map((d, i) => d.avg_mood !== null
76
+ ? `${pad + i * xStep},${h - pad - ((d.avg_mood - min) / (max - min)) * (h - pad * 2)}`
77
+ : null)
78
+ .filter(Boolean) as string[];
79
+
80
+ const pathD = points.length > 1
81
+ ? `M ${points.join(" L ")}`
82
+ : "";
83
+
84
+ return (
85
+ <svg viewBox={`0 0 ${w} ${h}`} className="w-full h-16" preserveAspectRatio="none">
86
+ <defs>
87
+ <linearGradient id="sparkGrad" x1="0" y1="0" x2="1" y2="0">
88
+ <stop offset="0%" stopColor="#7c3aed" />
89
+ <stop offset="100%" stopColor="#06b6d4" />
90
+ </linearGradient>
91
+ </defs>
92
+ <path d={pathD} stroke="url(#sparkGrad)" strokeWidth="2.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />
93
+ {arc.map((d, i) => d.avg_mood !== null && (
94
+ <circle
95
+ key={i}
96
+ cx={pad + i * xStep}
97
+ cy={h - pad - ((d.avg_mood! - min) / (max - min)) * (h - pad * 2)}
98
+ r="3.5"
99
+ fill="url(#sparkGrad)"
100
+ />
101
+ ))}
102
+ </svg>
103
+ );
104
+ }
105
+
106
+ function ScorePill({ label, value, color }: { label: string; value: number; color: string }) {
107
+ return (
108
+ <div className="flex flex-col items-center gap-1">
109
+ <div className="text-2xl font-bold" style={{ color }}>{value}</div>
110
+ <div className="text-[10px] uppercase tracking-wider text-white/40">{label}</div>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ export default function WeeklyReportPage() {
116
+ const { isDemoMode, userId } = useDemoMode();
117
+ const [report, setReport] = useState<WeeklyReport | null>(null);
118
+ const [loading, setLoading] = useState(true);
119
+ const cardRef = useRef<HTMLDivElement>(null);
120
+
121
+ useEffect(() => {
122
+ async function load() {
123
+ if (!userId) return;
124
+ try {
125
+ if (isDemoMode) {
126
+ await new Promise(r => setTimeout(r, 800));
127
+ setReport(DEMO_REPORT);
128
+ } else {
129
+ const data = await api.getWeeklyReport() as WeeklyReport;
130
+ setReport(data);
131
+ }
132
+ } catch (e) {
133
+ console.error(e);
134
+ } finally {
135
+ setLoading(false);
136
+ }
137
+ }
138
+ load();
139
+ }, [userId, isDemoMode]);
140
+
141
+ const handleShare = async () => {
142
+ if (!cardRef.current) return;
143
+ try {
144
+ // Use html-to-image if available, otherwise fall back to clipboard
145
+ const { toPng } = await import("html-to-image");
146
+ const dataUrl = await toPng(cardRef.current, { quality: 0.95, pixelRatio: 2 });
147
+ const link = document.createElement("a");
148
+ link.download = "my-week-in-feelings.png";
149
+ link.href = dataUrl;
150
+ link.click();
151
+ } catch {
152
+ // Fallback: share via Web Share API
153
+ if (navigator.share) {
154
+ await navigator.share({ title: "My Week In Feelings — InnerVoice", text: report?.narrative ?? "" });
155
+ }
156
+ }
157
+ };
158
+
159
+ if (loading) {
160
+ return (
161
+ <div className="flex items-center justify-center min-h-screen">
162
+ <div className="text-center space-y-4">
163
+ <div className="w-12 h-12 rounded-full border-2 border-purple-500 border-t-transparent animate-spin mx-auto" />
164
+ <p className="text-white/40 text-sm">Generating your week in feelings...</p>
165
+ </div>
166
+ </div>
167
+ );
168
+ }
169
+
170
+ if (!report?.has_data) {
171
+ return (
172
+ <div className="flex items-center justify-center min-h-screen p-8">
173
+ <div className="text-center space-y-4 max-w-sm">
174
+ <div className="text-6xl">📭</div>
175
+ <h2 className="text-2xl font-bold">No data yet this week</h2>
176
+ <p className="text-white/40">Complete at least one voice check-in to generate your weekly report.</p>
177
+ </div>
178
+ </div>
179
+ );
180
+ }
181
+
182
+ const moodDeltaPositive = (report.mood_delta ?? 0) > 0;
183
+
184
+ return (
185
+ <div className="min-h-screen p-6 md:p-10 flex flex-col items-center gap-8">
186
+ {/* Page Header */}
187
+ <motion.div
188
+ initial={{ opacity: 0, y: -20 }}
189
+ animate={{ opacity: 1, y: 0 }}
190
+ className="text-center space-y-2 w-full max-w-2xl"
191
+ >
192
+ <h1 className="text-4xl font-bold bg-gradient-to-r from-purple-400 via-pink-400 to-cyan-400 bg-clip-text text-transparent">
193
+ Your Week In Feelings
194
+ </h1>
195
+ <p className="text-white/40">{report.week_label}</p>
196
+ </motion.div>
197
+
198
+ {/* Share / Download buttons */}
199
+ <div className="flex gap-3">
200
+ <button
201
+ onClick={handleShare}
202
+ className="flex items-center gap-2 px-5 py-2.5 rounded-xl bg-gradient-to-r from-purple-600 to-cyan-600 text-white text-sm font-semibold hover:opacity-90 transition-opacity shadow-lg shadow-purple-500/20"
203
+ >
204
+ <Download className="w-4 h-4" />
205
+ Save as Image
206
+ </button>
207
+ <button
208
+ onClick={() => navigator.share?.({ title: "My Week In Feelings", text: report.narrative })}
209
+ className="flex items-center gap-2 px-5 py-2.5 rounded-xl bg-white/5 border border-white/10 text-white/70 text-sm font-medium hover:bg-white/10 transition-colors"
210
+ >
211
+ <Share2 className="w-4 h-4" />
212
+ Share
213
+ </button>
214
+ </div>
215
+
216
+ {/* === THE SHAREABLE CARD === */}
217
+ <motion.div
218
+ ref={cardRef}
219
+ initial={{ opacity: 0, scale: 0.97 }}
220
+ animate={{ opacity: 1, scale: 1 }}
221
+ transition={{ delay: 0.1 }}
222
+ className="w-full max-w-2xl rounded-3xl overflow-hidden bg-[#0a0a0f] border border-white/10 shadow-2xl"
223
+ style={{ background: "linear-gradient(135deg, #0d0d1a 0%, #0a0a0f 50%, #0d101a 100%)" }}
224
+ >
225
+ {/* Header stripe */}
226
+ <div className="h-1.5 w-full" style={{ background: `linear-gradient(90deg, #7c3aed, ${report.top_emotion_color}, #06b6d4)` }} />
227
+
228
+ <div className="p-8 space-y-8">
229
+ {/* Top row: emotion hero + quick stats */}
230
+ <div className="flex items-center justify-between">
231
+ <div className="space-y-1">
232
+ <div className="text-xs uppercase tracking-widest text-white/30 font-semibold">Dominant Feeling</div>
233
+ <div className="flex items-center gap-3">
234
+ <span className="text-5xl">{report.top_emotion_emoji}</span>
235
+ <div>
236
+ <div className="text-2xl font-bold capitalize">{report.top_emotion}</div>
237
+ <div className="text-sm text-white/40">{report.top_emotion_pct}% of the week</div>
238
+ </div>
239
+ </div>
240
+ </div>
241
+
242
+ <div className="flex gap-6 text-right">
243
+ <div>
244
+ <div className="flex items-center gap-1 justify-end text-sm font-semibold">
245
+ <Flame className="w-4 h-4 text-orange-400" />
246
+ <span>{report.streak}</span>
247
+ </div>
248
+ <div className="text-[10px] text-white/30 uppercase tracking-wider">Day Streak</div>
249
+ </div>
250
+ <div>
251
+ <div className="flex items-center gap-1 justify-end text-sm font-semibold">
252
+ <Mic className="w-4 h-4 text-cyan-400" />
253
+ <span>{report.entry_count}</span>
254
+ </div>
255
+ <div className="text-[10px] text-white/30 uppercase tracking-wider">Check-ins</div>
256
+ </div>
257
+ </div>
258
+ </div>
259
+
260
+ {/* Mood Arc sparkline */}
261
+ <div>
262
+ <div className="flex justify-between items-center mb-3">
263
+ <div className="text-xs uppercase tracking-widest text-white/30 font-semibold">Mood Arc This Week</div>
264
+ {report.mood_delta !== null && (
265
+ <div className={`flex items-center gap-1 text-sm font-semibold ${moodDeltaPositive ? "text-emerald-400" : "text-red-400"}`}>
266
+ {moodDeltaPositive ? <TrendingUp className="w-4 h-4" /> : <TrendingDown className="w-4 h-4" />}
267
+ {moodDeltaPositive ? "+" : ""}{report.mood_delta} vs last week
268
+ </div>
269
+ )}
270
+ </div>
271
+ <Sparkline arc={report.mood_arc} />
272
+ <div className="flex justify-between mt-1">
273
+ {report.mood_arc.map(d => (
274
+ <span key={d.day} className="text-[10px] text-white/20">{d.day}</span>
275
+ ))}
276
+ </div>
277
+ </div>
278
+
279
+ {/* Avg Scores */}
280
+ <div>
281
+ <div className="text-xs uppercase tracking-widest text-white/30 font-semibold mb-4">Weekly Averages</div>
282
+ <div className="grid grid-cols-4 gap-4 bg-white/[0.03] rounded-2xl p-5 border border-white/5">
283
+ <ScorePill label="Mood" value={report.avg_mood} color="#a78bfa" />
284
+ <ScorePill label="Energy" value={report.avg_energy} color="#34d399" />
285
+ <ScorePill label="Calm" value={report.avg_calm} color="#60a5fa" />
286
+ <ScorePill label="Clarity" value={report.avg_clarity} color="#f59e0b" />
287
+ </div>
288
+ </div>
289
+
290
+ {/* Best & Worst Day */}
291
+ <div className="grid grid-cols-2 gap-4">
292
+ {report.best_day && (
293
+ <div className="bg-emerald-500/5 border border-emerald-500/20 rounded-2xl p-4">
294
+ <div className="text-[10px] uppercase tracking-wider text-emerald-400 font-semibold mb-1">✦ Best Moment</div>
295
+ <div className="font-semibold text-sm">{report.best_day.date}</div>
296
+ <div className="text-emerald-300 text-lg font-bold">{report.best_day.mood}<span className="text-xs font-normal text-white/30">/100</span></div>
297
+ </div>
298
+ )}
299
+ {report.worst_day && (
300
+ <div className="bg-blue-500/5 border border-blue-500/20 rounded-2xl p-4">
301
+ <div className="text-[10px] uppercase tracking-wider text-blue-400 font-semibold mb-1">↓ Lowest Point</div>
302
+ <div className="font-semibold text-sm">{report.worst_day.date}</div>
303
+ <div className="text-blue-300 text-lg font-bold">{report.worst_day.mood}<span className="text-xs font-normal text-white/30">/100</span></div>
304
+ </div>
305
+ )}
306
+ </div>
307
+
308
+ {/* Emotion Breakdown */}
309
+ <div>
310
+ <div className="text-xs uppercase tracking-widest text-white/30 font-semibold mb-3">Emotion Breakdown</div>
311
+ <div className="space-y-2">
312
+ {report.emotion_breakdown.map(e => (
313
+ <div key={e.emotion} className="flex items-center gap-3">
314
+ <div className="w-20 text-xs capitalize text-white/60">{e.emotion}</div>
315
+ <div className="flex-1 h-2 bg-white/5 rounded-full overflow-hidden">
316
+ <motion.div
317
+ initial={{ width: 0 }}
318
+ animate={{ width: `${e.pct}%` }}
319
+ transition={{ delay: 0.5, duration: 0.8, ease: "easeOut" }}
320
+ className="h-full rounded-full"
321
+ style={{ backgroundColor: e.color }}
322
+ />
323
+ </div>
324
+ <div className="text-xs text-white/30 w-8 text-right">{e.pct}%</div>
325
+ </div>
326
+ ))}
327
+ </div>
328
+ </div>
329
+
330
+ {/* AI Narrative */}
331
+ <div className="bg-gradient-to-br from-purple-500/10 to-cyan-500/10 border border-purple-500/20 rounded-2xl p-6">
332
+ <div className="text-xs uppercase tracking-widest text-purple-400 font-semibold mb-3">InnerVoice's Take</div>
333
+ <p className="text-white/80 text-sm leading-relaxed italic">"{report.narrative}"</p>
334
+ </div>
335
+
336
+ {/* Most expressive moment */}
337
+ {report.most_expressive_moment && (
338
+ <div className="border-l-2 border-cyan-500/40 pl-4">
339
+ <div className="text-[10px] uppercase tracking-wider text-white/30 font-semibold mb-1">Most Expressive Moment</div>
340
+ <p className="text-white/50 text-sm italic">"{report.most_expressive_moment}"</p>
341
+ </div>
342
+ )}
343
+
344
+ {/* Footer branding */}
345
+ <div className="flex items-center justify-between pt-2 border-t border-white/5">
346
+ <div className="text-xs text-white/20">InnerVoice — Emotional Wellness Tracker</div>
347
+ <div className="text-xs text-white/20">Not a medical tool</div>
348
+ </div>
349
+ </div>
350
+ </motion.div>
351
+ </div>
352
+ );
353
+ }
frontend/components/Navbar.tsx CHANGED
@@ -4,13 +4,14 @@ import { usePathname } from "next/navigation";
4
  import { useDemoMode } from "@/hooks/useDemoMode";
5
  import { useAuth } from "@/contexts/AuthContext";
6
  import { motion, AnimatePresence } from "framer-motion";
7
- import { Home, Mic, TrendingUp, MessageCircle, Settings, LogOut, Lock, Menu, X } from "lucide-react";
8
  import { useState } from "react";
9
 
10
  const navItems = [
11
  { href: "/dashboard", label: "Dashboard", icon: Home },
12
  { href: "/record", label: "Check-in", icon: Mic },
13
  { href: "/timeline", label: "Timeline", icon: TrendingUp },
 
14
  { href: "/chat", label: "Companion", icon: MessageCircle },
15
  { href: "/settings", label: "Settings", icon: Settings },
16
  ];
 
4
  import { useDemoMode } from "@/hooks/useDemoMode";
5
  import { useAuth } from "@/contexts/AuthContext";
6
  import { motion, AnimatePresence } from "framer-motion";
7
+ import { Home, Mic, TrendingUp, MessageCircle, Settings, LogOut, BarChart2, Menu, X } from "lucide-react";
8
  import { useState } from "react";
9
 
10
  const navItems = [
11
  { href: "/dashboard", label: "Dashboard", icon: Home },
12
  { href: "/record", label: "Check-in", icon: Mic },
13
  { href: "/timeline", label: "Timeline", icon: TrendingUp },
14
+ { href: "/report", label: "Weekly Report", icon: BarChart2 },
15
  { href: "/chat", label: "Companion", icon: MessageCircle },
16
  { href: "/settings", label: "Settings", icon: Settings },
17
  ];
frontend/lib/api.ts CHANGED
@@ -129,6 +129,9 @@ export const api = {
129
  headers: { ...getAuthHeader() },
130
  }).then(r => r.json()),
131
 
 
 
 
132
  analyzeAudio: async (audioBlob: Blob): Promise<AnalyzeResult> => {
133
  const formData = new FormData();
134
  formData.append("audio", audioBlob, "recording.webm");
 
129
  headers: { ...getAuthHeader() },
130
  }).then(r => r.json()),
131
 
132
+ getWeeklyReport: () =>
133
+ apiGet<Record<string, unknown>>("/api/weekly-report"),
134
+
135
  analyzeAudio: async (audioBlob: Blob): Promise<AnalyzeResult> => {
136
  const formData = new FormData();
137
  formData.append("audio", audioBlob, "recording.webm");
frontend/package-lock.json CHANGED
@@ -19,6 +19,7 @@
19
  "clsx": "^2.1.1",
20
  "date-fns": "^4.1.0",
21
  "framer-motion": "^12.38.0",
 
22
  "lucide-react": "^1.8.0",
23
  "next": "14.2.35",
24
  "next-auth": "^4.24.13",
@@ -1429,6 +1430,7 @@
1429
  "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-8.15.0.tgz",
1430
  "integrity": "sha512-rYefFqu6ki0iuPlIFhnfZsucJjY+4ZQNTdt+rvQgWo9f2T1Ia+1yotlNMs7jlnNG5nNBLQcq8zcz4pxbWg6rmw==",
1431
  "license": "MIT",
 
1432
  "dependencies": {
1433
  "@babel/runtime": "^7.17.8",
1434
  "@types/react-reconciler": "^0.26.7",
@@ -1679,6 +1681,7 @@
1679
  "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.28.tgz",
1680
  "integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
1681
  "license": "MIT",
 
1682
  "dependencies": {
1683
  "@types/prop-types": "*",
1684
  "csstype": "^3.2.2"
@@ -1688,8 +1691,9 @@
1688
  "version": "18.3.7",
1689
  "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz",
1690
  "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
1691
- "dev": true,
1692
  "license": "MIT",
 
1693
  "peerDependencies": {
1694
  "@types/react": "^18.0.0"
1695
  }
@@ -1714,6 +1718,7 @@
1714
  "resolved": "https://registry.npmjs.org/@types/three/-/three-0.183.1.tgz",
1715
  "integrity": "sha512-f2Pu5Hrepfgavttdye3PsH5RWyY/AvdZQwIVhrc4uNtvF7nOWJacQKcoVJn0S4f0yYbmAE6AR+ve7xDcuYtMGw==",
1716
  "license": "MIT",
 
1717
  "dependencies": {
1718
  "@dimforge/rapier3d-compat": "~0.12.0",
1719
  "@tweenjs/tween.js": "~23.1.3",
@@ -1781,6 +1786,7 @@
1781
  "integrity": "sha512-gGkiNMPqerb2cJSVcruigx9eHBlLG14fSdPdqMoOcBfh+vvn4iCq2C8MzUB89PrxOXk0y3GZ1yIWb9aOzL93bw==",
1782
  "dev": true,
1783
  "license": "MIT",
 
1784
  "dependencies": {
1785
  "@typescript-eslint/scope-manager": "8.58.1",
1786
  "@typescript-eslint/types": "8.58.1",
@@ -2324,6 +2330,7 @@
2324
  "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
2325
  "dev": true,
2326
  "license": "MIT",
 
2327
  "bin": {
2328
  "acorn": "bin/acorn"
2329
  },
@@ -3584,6 +3591,7 @@
3584
  "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
3585
  "dev": true,
3586
  "license": "MIT",
 
3587
  "dependencies": {
3588
  "@eslint-community/eslint-utils": "^4.2.0",
3589
  "@eslint-community/regexpp": "^4.6.1",
@@ -3753,6 +3761,7 @@
3753
  "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
3754
  "dev": true,
3755
  "license": "MIT",
 
3756
  "dependencies": {
3757
  "@rtsao/scc": "^1.1.0",
3758
  "array-includes": "^3.1.9",
@@ -4579,6 +4588,12 @@
4579
  "node": ">= 0.4"
4580
  }
4581
  },
 
 
 
 
 
 
4582
  "node_modules/ieee754": {
4583
  "version": "1.2.1",
4584
  "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@@ -5201,6 +5216,7 @@
5201
  "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==",
5202
  "dev": true,
5203
  "license": "MIT",
 
5204
  "bin": {
5205
  "jiti": "bin/jiti.js"
5206
  }
@@ -6129,6 +6145,7 @@
6129
  }
6130
  ],
6131
  "license": "MIT",
 
6132
  "dependencies": {
6133
  "nanoid": "^3.3.11",
6134
  "picocolors": "^1.1.1",
@@ -6304,6 +6321,7 @@
6304
  "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.1.tgz",
6305
  "integrity": "sha512-gQCLc/vWroE8lIpleXtdJhTFDogTdZG9AjMUpVkDf2iTCNwYNWA+u16dL41TqUDJO4gm2IgrcMv3uTpjd4Pwmg==",
6306
  "license": "MIT",
 
6307
  "funding": {
6308
  "type": "opencollective",
6309
  "url": "https://opencollective.com/preact"
@@ -6384,6 +6402,7 @@
6384
  "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
6385
  "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
6386
  "license": "MIT",
 
6387
  "dependencies": {
6388
  "loose-envify": "^1.1.0"
6389
  },
@@ -6408,6 +6427,7 @@
6408
  "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
6409
  "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
6410
  "license": "MIT",
 
6411
  "dependencies": {
6412
  "loose-envify": "^1.1.0",
6413
  "scheduler": "^0.23.2"
@@ -6420,7 +6440,8 @@
6420
  "version": "16.13.1",
6421
  "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
6422
  "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
6423
- "license": "MIT"
 
6424
  },
6425
  "node_modules/react-merge-refs": {
6426
  "version": "1.1.0",
@@ -6462,6 +6483,7 @@
6462
  "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
6463
  "integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
6464
  "license": "MIT",
 
6465
  "dependencies": {
6466
  "@types/use-sync-external-store": "^0.0.6",
6467
  "use-sync-external-store": "^1.4.0"
@@ -6621,7 +6643,8 @@
6621
  "version": "5.0.1",
6622
  "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
6623
  "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
6624
- "license": "MIT"
 
6625
  },
6626
  "node_modules/redux-thunk": {
6627
  "version": "3.1.0",
@@ -7526,7 +7549,8 @@
7526
  "version": "0.160.0",
7527
  "resolved": "https://registry.npmjs.org/three/-/three-0.160.0.tgz",
7528
  "integrity": "sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==",
7529
- "license": "MIT"
 
7530
  },
7531
  "node_modules/three-mesh-bvh": {
7532
  "version": "0.6.8",
@@ -7607,6 +7631,7 @@
7607
  "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
7608
  "dev": true,
7609
  "license": "MIT",
 
7610
  "engines": {
7611
  "node": ">=12"
7612
  },
@@ -7806,6 +7831,7 @@
7806
  "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
7807
  "dev": true,
7808
  "license": "Apache-2.0",
 
7809
  "bin": {
7810
  "tsc": "bin/tsc",
7811
  "tsserver": "bin/tsserver"
 
19
  "clsx": "^2.1.1",
20
  "date-fns": "^4.1.0",
21
  "framer-motion": "^12.38.0",
22
+ "html-to-image": "^1.11.13",
23
  "lucide-react": "^1.8.0",
24
  "next": "14.2.35",
25
  "next-auth": "^4.24.13",
 
1430
  "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-8.15.0.tgz",
1431
  "integrity": "sha512-rYefFqu6ki0iuPlIFhnfZsucJjY+4ZQNTdt+rvQgWo9f2T1Ia+1yotlNMs7jlnNG5nNBLQcq8zcz4pxbWg6rmw==",
1432
  "license": "MIT",
1433
+ "peer": true,
1434
  "dependencies": {
1435
  "@babel/runtime": "^7.17.8",
1436
  "@types/react-reconciler": "^0.26.7",
 
1681
  "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.28.tgz",
1682
  "integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
1683
  "license": "MIT",
1684
+ "peer": true,
1685
  "dependencies": {
1686
  "@types/prop-types": "*",
1687
  "csstype": "^3.2.2"
 
1691
  "version": "18.3.7",
1692
  "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz",
1693
  "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
1694
+ "devOptional": true,
1695
  "license": "MIT",
1696
+ "peer": true,
1697
  "peerDependencies": {
1698
  "@types/react": "^18.0.0"
1699
  }
 
1718
  "resolved": "https://registry.npmjs.org/@types/three/-/three-0.183.1.tgz",
1719
  "integrity": "sha512-f2Pu5Hrepfgavttdye3PsH5RWyY/AvdZQwIVhrc4uNtvF7nOWJacQKcoVJn0S4f0yYbmAE6AR+ve7xDcuYtMGw==",
1720
  "license": "MIT",
1721
+ "peer": true,
1722
  "dependencies": {
1723
  "@dimforge/rapier3d-compat": "~0.12.0",
1724
  "@tweenjs/tween.js": "~23.1.3",
 
1786
  "integrity": "sha512-gGkiNMPqerb2cJSVcruigx9eHBlLG14fSdPdqMoOcBfh+vvn4iCq2C8MzUB89PrxOXk0y3GZ1yIWb9aOzL93bw==",
1787
  "dev": true,
1788
  "license": "MIT",
1789
+ "peer": true,
1790
  "dependencies": {
1791
  "@typescript-eslint/scope-manager": "8.58.1",
1792
  "@typescript-eslint/types": "8.58.1",
 
2330
  "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
2331
  "dev": true,
2332
  "license": "MIT",
2333
+ "peer": true,
2334
  "bin": {
2335
  "acorn": "bin/acorn"
2336
  },
 
3591
  "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
3592
  "dev": true,
3593
  "license": "MIT",
3594
+ "peer": true,
3595
  "dependencies": {
3596
  "@eslint-community/eslint-utils": "^4.2.0",
3597
  "@eslint-community/regexpp": "^4.6.1",
 
3761
  "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
3762
  "dev": true,
3763
  "license": "MIT",
3764
+ "peer": true,
3765
  "dependencies": {
3766
  "@rtsao/scc": "^1.1.0",
3767
  "array-includes": "^3.1.9",
 
4588
  "node": ">= 0.4"
4589
  }
4590
  },
4591
+ "node_modules/html-to-image": {
4592
+ "version": "1.11.13",
4593
+ "resolved": "https://registry.npmjs.org/html-to-image/-/html-to-image-1.11.13.tgz",
4594
+ "integrity": "sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg==",
4595
+ "license": "MIT"
4596
+ },
4597
  "node_modules/ieee754": {
4598
  "version": "1.2.1",
4599
  "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
 
5216
  "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==",
5217
  "dev": true,
5218
  "license": "MIT",
5219
+ "peer": true,
5220
  "bin": {
5221
  "jiti": "bin/jiti.js"
5222
  }
 
6145
  }
6146
  ],
6147
  "license": "MIT",
6148
+ "peer": true,
6149
  "dependencies": {
6150
  "nanoid": "^3.3.11",
6151
  "picocolors": "^1.1.1",
 
6321
  "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.1.tgz",
6322
  "integrity": "sha512-gQCLc/vWroE8lIpleXtdJhTFDogTdZG9AjMUpVkDf2iTCNwYNWA+u16dL41TqUDJO4gm2IgrcMv3uTpjd4Pwmg==",
6323
  "license": "MIT",
6324
+ "peer": true,
6325
  "funding": {
6326
  "type": "opencollective",
6327
  "url": "https://opencollective.com/preact"
 
6402
  "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
6403
  "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
6404
  "license": "MIT",
6405
+ "peer": true,
6406
  "dependencies": {
6407
  "loose-envify": "^1.1.0"
6408
  },
 
6427
  "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
6428
  "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
6429
  "license": "MIT",
6430
+ "peer": true,
6431
  "dependencies": {
6432
  "loose-envify": "^1.1.0",
6433
  "scheduler": "^0.23.2"
 
6440
  "version": "16.13.1",
6441
  "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
6442
  "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
6443
+ "license": "MIT",
6444
+ "peer": true
6445
  },
6446
  "node_modules/react-merge-refs": {
6447
  "version": "1.1.0",
 
6483
  "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
6484
  "integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
6485
  "license": "MIT",
6486
+ "peer": true,
6487
  "dependencies": {
6488
  "@types/use-sync-external-store": "^0.0.6",
6489
  "use-sync-external-store": "^1.4.0"
 
6643
  "version": "5.0.1",
6644
  "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
6645
  "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
6646
+ "license": "MIT",
6647
+ "peer": true
6648
  },
6649
  "node_modules/redux-thunk": {
6650
  "version": "3.1.0",
 
7549
  "version": "0.160.0",
7550
  "resolved": "https://registry.npmjs.org/three/-/three-0.160.0.tgz",
7551
  "integrity": "sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==",
7552
+ "license": "MIT",
7553
+ "peer": true
7554
  },
7555
  "node_modules/three-mesh-bvh": {
7556
  "version": "0.6.8",
 
7631
  "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
7632
  "dev": true,
7633
  "license": "MIT",
7634
+ "peer": true,
7635
  "engines": {
7636
  "node": ">=12"
7637
  },
 
7831
  "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
7832
  "dev": true,
7833
  "license": "Apache-2.0",
7834
+ "peer": true,
7835
  "bin": {
7836
  "tsc": "bin/tsc",
7837
  "tsserver": "bin/tsserver"
frontend/package.json CHANGED
@@ -20,6 +20,7 @@
20
  "clsx": "^2.1.1",
21
  "date-fns": "^4.1.0",
22
  "framer-motion": "^12.38.0",
 
23
  "lucide-react": "^1.8.0",
24
  "next": "14.2.35",
25
  "next-auth": "^4.24.13",
 
20
  "clsx": "^2.1.1",
21
  "date-fns": "^4.1.0",
22
  "framer-motion": "^12.38.0",
23
+ "html-to-image": "^1.11.13",
24
  "lucide-react": "^1.8.0",
25
  "next": "14.2.35",
26
  "next-auth": "^4.24.13",
prisma/schema.prisma CHANGED
@@ -69,16 +69,31 @@ model MoodAlert {
69
  @@map("mood_alerts")
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  model ChatMessage {
73
  id String @id @default(uuid())
74
  userId String @map("user_id")
 
75
  createdAt DateTime @default(now()) @map("created_at")
76
  role String
77
  content String
78
  voiceEntryId String? @map("voice_entry_id")
79
 
80
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
81
- voiceEntry VoiceEntry? @relation(fields: [voiceEntryId], references: [id])
 
82
 
83
  @@map("chat_messages")
84
  }
 
69
  @@map("mood_alerts")
70
  }
71
 
72
+ model ChatChannel {
73
+ id String @id @default(uuid())
74
+ userId String @map("user_id")
75
+ title String @default("New Chat")
76
+ createdAt DateTime @default(now()) @map("created_at")
77
+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
78
+
79
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
80
+ messages ChatMessage[]
81
+
82
+ @@map("chat_channels")
83
+ }
84
+
85
  model ChatMessage {
86
  id String @id @default(uuid())
87
  userId String @map("user_id")
88
+ channelId String? @map("channel_id")
89
  createdAt DateTime @default(now()) @map("created_at")
90
  role String
91
  content String
92
  voiceEntryId String? @map("voice_entry_id")
93
 
94
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
95
+ channel ChatChannel? @relation(fields: [channelId], references: [id], onDelete: Cascade)
96
+ voiceEntry VoiceEntry? @relation(fields: [voiceEntryId], references: [id])
97
 
98
  @@map("chat_messages")
99
  }