This document is a high-level map of the codebase: what the app does, how it is structured, and where the main responsibilities live.
Study Buddy v2 is an exam-preparation platform for secondary-school learners. The current product centers on:
- account creation and login
- student profile capture
- subject/topic practice
- mock exams with scoring
- progress and performance reporting
- AI chat and recommendation features
- subscription and payment handling
- internal admin/content workflows
- framework: Next.js 16 App Router
- language: TypeScript
- UI: React 18 + Tailwind CSS
- database: PostgreSQL via Prisma
- auth: Supabase SSR auth with cookies
- AI: OpenAI
app/ Pages, layouts, route handlers
components/ Reusable UI building blocks
lib/ Shared helpers and clients
prisma/ Schema, migrations, seeds
docs/ Supplemental project documentation
- most user-facing pages are App Router pages under
app/ - server-side route handlers live under
app/api/v1/ - Prisma is the application data layer
- Supabase manages auth identity; Prisma stores app-specific user data
- feature areas are split by domain: materials, exams, progress, chat, accounts, and admin
- landing page:
app/page.tsx - about/contact/legal pages under
app/
- login:
app/login - sign-up:
app/sign-up - forgot/reset password flows
- email verification and access-state pages
- dashboard:
app/dashboard - materials:
app/materials - exams:
app/exams - progress:
app/progress - chat:
app/chat
All current APIs are implemented under app/api/v1.
- signup, login, logout, reset password, current user
- reversible deactivation and permanent-deletion request/cancellation
- secret-authenticated, retryable account purge
- read and update current user profile
- materials overview
- questions by topic
- answer attempt submission
- question explanations
- list templates
- start exam
- fetch exam instance
- save progress
- submit
- grade
- full report
- per-subject progress upsert
- bulk progress updates
- quick chat messages
- question thread creation
- thread replies
- thread listing
- recommendations
- recommendation cron
- content/admin upload flows
- subscription lookup
- payment verification and webhook handling
- Prisma client:
lib/prisma.ts - auth guards:
lib/auth.ts - account lifecycle:
lib/account-lifecycle.ts - session helper:
lib/getSession.ts - browser Supabase client:
lib/supabaseClient.ts - study materials display mapping:
lib/materials-display.ts - mock-exam choice generation:
lib/mock-exam-multiple-choice.ts
The schema lives in prisma/schema.prisma.
UserUserProfileAccountDeletionRequest
SubjectTopicPastQuestionCurriculumFile
PastQuestionAttemptMockExamTemplateMockExamInstanceMockExamAnswerProgressTrack
AiQuestionAiQuestionMessageRecommendation
SubscriptionTransaction
Seed orchestration is in prisma/seed/index.ts.
Supporting seed files:
If you are new to the repo:
- read
README.md - read
docs/WEBSITE_GUIDE.md - inspect
prisma/schema.prisma - inspect
app/api/v1/README.md