Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm test
- run: npm run build
env:
NEXT_PUBLIC_SUPABASE_URL: https://example.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY: ci-placeholder
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

70 changes: 65 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
Features: 1] Task Manager:user can add , edit , delete ,complete task;
2] Notes Section : Use Case: Add quick notes or class summaries.;
3] Pomodoro Timer Use Case: 25 min work / 5 min break timer to boost focus ;
4] GPA Calculator : Use Case: Input subjects, grades → calculate GPA ;
5] Motivational Quote of the Day : Use Case: Keep the user motivated
# StudyVerse

A study companion for students: dashboard, tasks, notes, pomodoro timer, weekly planner, CGPA calculator and a daily quote.
Built with Next.js 16 (App Router), React 19, Tailwind CSS 4 and Supabase (auth + Postgres).

Live: https://study-verse-ten.vercel.app

## Setup

1. `npm install`
2. Copy `.env.example` to `.env.local` and fill in your Supabase project URL and anon key
(Supabase Dashboard → Project Settings → API).
3. In the Supabase Dashboard → SQL Editor, run the migrations in order:
- `supabase/migrations/0001_schema_and_rls.sql` — tables, row-level security, seeded quotes
- `supabase/migrations/0002_v2.sql` — pomodoro sessions, planner blocks, saved CGPA, note tags
Both are idempotent (safe to re-run).
4. Optional, for "Continue with Google": Supabase Dashboard → Authentication → Providers → Google
(needs a Google Cloud OAuth client ID and secret), then add `https://<your-domain>/auth/callback`
and `http://localhost:3000/auth/callback` under Authentication → URL Configuration → Redirect URLs.
5. `npm run dev`

## Scripts

| Command | What it does |
| ------------------- | ---------------------------------------------- |
| `npm run dev` | Dev server |
| `npm run build` | Production build |
| `npm run lint` | ESLint (Next core-web-vitals + TypeScript) |
| `npm run typecheck` | `tsc --noEmit` |
| `npm test` | Node's built-in test runner (`lib/*.test.mjs`) |

CI runs all of the above on every pull request (`.github/workflows/ci.yml`).

## Layout

```
app/
layout.tsx fonts, theme bootstrap script, global CSS
globals.css "Paper bento" tokens (light-dark()), component classes (.btn, .card, .tile, .chip …)
(public)/ home, login, register, forgot-password, reset-password — top nav
(app)/ signed-in shell: sidebar on desktop, tab bar on mobile
dashboard/ stats, up-next tasks, week chart, today's plan, mini timer, quote, recent notes
task/ Server Component + Server Actions; ?filter=soon|overdue|done
note/ search (?q=), tags (?tag=), markdown preview
pomodoro/ timer hook in lib/use-pomodoro.ts; settings in localStorage; sessions saved to Supabase
planner/ weekly timetable (Mon–Sun, 06:00–23:00)
gpa/ 10-point or 4.0 scale, saved per user
quotes/ random quote, server-rendered
auth/callback/ OAuth + email-link code exchange
components/ Sidebar, TopNav, ThemeToggle, SubmitButton, GoogleButton
lib/ gpa.mjs, streak.mjs (with tests), time.ts, use-pomodoro.ts
proxy.ts redirects signed-out visitors away from every (app) route
utils/supabase/ browser + server Supabase clients
supabase/migrations/ SQL to run in the Supabase dashboard
```

## Theme

Light and dark share one token set via CSS `light-dark()`. The toggle writes `theme` to `localStorage`
and sets `data-theme` on `<html>`; with no saved choice the system preference applies.

## Deploy

Vercel auto-detects Next.js. Set `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY`
in Project → Settings → Environment Variables.
24 changes: 24 additions & 0 deletions app/(app)/dashboard/greeting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client'

import { useSyncExternalStore } from 'react'
import { localHour, localDateLabel } from '@/lib/time'

const noop = () => () => {}
const hourWord = () => {
const h = localHour()
return h < 5 ? 'Up late' : h < 12 ? 'Good morning' : h < 17 ? 'Good afternoon' : 'Good evening'
}

// Time-of-day text comes from the viewer's clock, not the server's.
export default function Greeting({ name }: { name: string }) {
const word = useSyncExternalStore(noop, hourWord, () => 'Hello')
const date = useSyncExternalStore(noop, localDateLabel, () => '')
return (
<div>
<p className="hand text-2xl -rotate-2 origin-left" suppressHydrationWarning>{date}</p>
<h1 className="page-title mt-1">
{word}, <span className="hl">{name}</span> <span className="wiggle origin-[70%_70%]" aria-hidden="true">👋</span>
</h1>
</div>
)
}
39 changes: 39 additions & 0 deletions app/(app)/dashboard/mini-pomodoro.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client'

import Link from 'next/link'
import { PlayIcon, PauseIcon, ArrowUpRightIcon } from '@phosphor-icons/react/dist/ssr'
import { Rings } from '@/app/components/motion'
import { usePomodoro, formatTime, PHASE_LABEL } from '@/lib/use-pomodoro'
import { logSession } from '@/app/(app)/pomodoro/actions'
import { celebrate } from '@/lib/celebrate'

export default function MiniPomodoro() {
const t = usePomodoro((phase, minutes) => {
if (phase !== 'work') return
logSession(minutes, 'work')
celebrate(undefined, true)
})
return (
<section className={`card h-full flex flex-col ${t.phase === 'work' ? 'bg-pink' : 'bg-mint'}`} aria-labelledby="mini-focus">
<div className="flex items-center justify-between">
<h2 id="mini-focus" className="section-title">Focus timer</h2>
<Link href="/pomodoro" className="btn btn-sm">Open<ArrowUpRightIcon size={14} weight="bold" aria-hidden="true" /></Link>
</div>
<div className="flex-1 flex items-center gap-6 mt-4">
<div className="rounded-full bg-surface border-2 border-ink">
<Rings size={120} stroke={11} instant rings={[{ value: t.secondsLeft / t.total, className: 'stroke-accent', label: 'Time left' }]}>
<span className="font-mono text-xl font-bold tabular-nums">{formatTime(t.secondsLeft)}</span>
</Rings>
</div>
<div className="flex flex-col gap-3">
<p className="font-bold">{PHASE_LABEL[t.phase]}{t.running ? ', running' : ''}</p>
{t.running ? (
<button type="button" className="btn" onClick={t.pause}><PauseIcon size={18} weight="fill" aria-hidden="true" />Pause</button>
) : (
<button type="button" className="btn btn-primary" onClick={t.start}><PlayIcon size={18} weight="fill" aria-hidden="true" />Start</button>
)}
</div>
</div>
</section>
)
}
56 changes: 56 additions & 0 deletions app/(app)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { redirect } from 'next/navigation'
import { createClient } from '@/utils/supabase/server'
import type { Task, Quote, Note, PomodoroSession, PlannerBlock, GpaProfile } from '@/types/db'
import { nowIso, dayNumber, daysAgoIso, utcWeekday, startOfUtcDayIso, endOfUtcDayIso, startOfUtcWeekIso } from '@/lib/time'
import { streakDays } from '@/lib/streak.mjs'
import { gpa } from '@/lib/gpa.mjs'
import DashboardView from './view'

export const metadata = { title: 'Today' }

// Tolerates tables that don't exist yet (before 0002_v2.sql runs): an error just means "no rows".
const rows = async <T,>(q: PromiseLike<{ data: unknown }>) => ((await q).data ?? []) as T[]

export default async function DashboardPage() {
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) redirect('/login?next=/dashboard')
const uid = user.id
const meta = user.user_metadata ?? {}
const name = meta.username || meta.full_name?.split(' ')[0] || meta.name?.split(' ')[0] || user.email?.split('@')[0] || 'there'
const today = utcWeekday()

const [open, overdue, dueToday, quotes, sessions, blocks, notes, profile] = await Promise.all([
rows<Task>(supabase.from('tasks').select('*').eq('user_id', uid).eq('completed', false).order('due_date', { ascending: true, nullsFirst: false }).limit(6)),
supabase.from('tasks').select('id', { count: 'exact', head: true }).eq('user_id', uid).eq('completed', false).lt('due_date', nowIso()),
rows<Pick<Task, 'completed'>>(supabase.from('tasks').select('completed').eq('user_id', uid).gte('due_date', startOfUtcDayIso()).lt('due_date', endOfUtcDayIso())),
rows<Quote>(supabase.from('quotes').select('*').eq('category', 'study').order('text')),
rows<PomodoroSession>(supabase.from('pomodoro_sessions').select('*').eq('user_id', uid).eq('kind', 'work').gte('started_at', daysAgoIso(60))),
rows<PlannerBlock>(supabase.from('planner_blocks').select('*').eq('user_id', uid).eq('weekday', today).order('start_min')),
rows<Note>(supabase.from('notes').select('*').eq('user_id', uid).order('updated_at', { ascending: false }).limit(3)),
supabase.from('gpa_profiles').select('*').eq('user_id', uid).maybeSingle(),
])

const dayStart = startOfUtcDayIso()
const weekStart = startOfUtcWeekIso()
const week = Array<number>(7).fill(0)
for (const s of sessions) if (s.started_at >= weekStart) week[utcWeekday(new Date(s.started_at))] += s.minutes
const gp = (profile.data ?? null) as GpaProfile | null

return (
<DashboardView
name={name}
focusToday={sessions.filter((s) => s.started_at >= dayStart).reduce((sum, s) => sum + s.minutes, 0)}
dueToday={dueToday}
open={open}
streak={streakDays(sessions.map((s) => s.started_at))}
overdueCount={overdue.count ?? 0}
cgpa={gp ? gpa(gp.semesters.flat(), gp.scale) : null}
week={week}
today={today}
blocks={blocks}
quote={quotes.length ? quotes[dayNumber() % quotes.length] : null}
notes={notes}
/>
)
}
41 changes: 41 additions & 0 deletions app/(app)/dashboard/today-rings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use client'

import { CountUp, Rings } from '@/app/components/motion'
import { useSettings } from '@/lib/use-pomodoro'
import { fmtMinutes } from '@/lib/time'

/** The day at a glance: focus minutes against the daily goal, and today's due tasks done. */
export default function TodayRings({ focus, due, done }: { focus: number; due: number; done: number }) {
const { goal } = useSettings()
return (
<div className="flex flex-col sm:flex-row items-center gap-6 sm:gap-10">
<Rings
size={176}
stroke={16}
gap={6}
rings={[
{ value: focus / goal, className: 'stroke-accent', label: 'Focus' },
{ value: due ? done / due : 0, className: 'stroke-mint', label: 'Due today' },
]}
>
<span className="text-3xl" aria-hidden="true">{focus >= goal ? '🏆' : '⚡'}</span>
</Rings>
<dl className="grid gap-5 w-full sm:w-auto">
<div>
<dt className="flex items-center gap-2 font-bold"><span className="size-3.5 rounded-full bg-accent border-2 border-ink" aria-hidden="true" />Focus</dt>
<dd className="mt-0.5"><span className="text-4xl font-extrabold tracking-tight"><CountUp value={focus} /></span><span className="text-muted font-bold"> min of your {fmtMinutes(goal)} goal</span></dd>
</div>
<div>
<dt className="flex items-center gap-2 font-bold"><span className="size-3.5 rounded-full bg-mint border-2 border-ink" aria-hidden="true" />Due today</dt>
<dd className="mt-0.5">
{due ? (
<><span className="text-4xl font-extrabold tracking-tight"><CountUp value={done} /></span><span className="text-muted font-bold"> of {due} done</span></>
) : (
<span className="text-muted font-bold">Nothing due today. Enjoy it.</span>
)}
</dd>
</div>
</dl>
</div>
)
}
24 changes: 24 additions & 0 deletions app/(app)/dashboard/up-next.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client'

import { AnimatePresence, motion } from 'motion/react'
import type { Task } from '@/types/db'
import { SPRING } from '@/app/components/motion'
import { TaskRow, useTaskMutations } from '@/app/(app)/task/task-list'

// Ticking a task off here removes it from the list with a short exit; the server catches up behind it.
export default function UpNext({ tasks }: { tasks: Task[] }) {
const { items, toggle } = useTaskMutations(tasks)
const open = items.filter((t) => !t.completed)
if (open.length === 0) return <p className="font-bold text-muted py-6 text-center"><span className="text-2xl mr-2" aria-hidden="true">🎉</span>All done. Add a task when something comes up.</p>
return (
<ul className="divide-y-2 divide-dashed divide-line-strong -my-1">
<AnimatePresence initial={false} mode="popLayout">
{open.map((t) => (
<motion.li key={t.id} layout="position" exit={{ opacity: 0, x: 12, transition: { duration: 0.2 } }} transition={SPRING}>
<TaskRow task={t} onToggle={() => toggle(t)} compact />
</motion.li>
))}
</AnimatePresence>
</ul>
)
}
Loading
Loading