Skip to content

Repository files navigation

P2P Tutors

Next.js Prisma Supabase NextAuth Stripe Tailwind

Product Overview — The Why

P2P Tutors is an AI-guided, syllabus-aware peer tutoring platform for higher education. Students discover verified tutors who already mastered the same course, match via vector search over syllabi, schedule lessons, pay securely, and meet inside built-in video classrooms while staying connected through an interactive community layer.

Key Features

  • AI Matching — Vector search (pgvector + OpenAI/Gemini embeddings) pairs students with tutors based on the actual course syllabus.
  • Smart Scheduling — Availability management, conflict prevention, and automatic ICS invites keep bookings reliable.
  • Payments — Stripe Checkout runs the entire billing pipeline, including promo codes, invoices, and webhook processing.
  • Video Class — Agora-powered, in-browser classrooms with audio, video, and screen share.
  • PWA Ready — Installable experience for mobile and desktop with offline shell support.
  • Community — Q&A forum, rich messaging, and tutor inboxes to sustain engagement outside sessions.

Environment Variables (.env Setup)

Copy .env to .env.local (or configure via your hosting provider) and provide the following values:

Variable Purpose
DATABASE_URL PgBouncer/transaction-pooler connection string used by the running app.
DIRECT_URL Direct Postgres session connection for Prisma migrations or db push.
NEXTAUTH_URL Absolute URL for NextAuth callbacks (http://localhost:3000 in dev).
NEXTAUTH_SECRET Secret used to sign and encrypt NextAuth JWT/session cookies.
REGISTRATION_INVITE_CODE Lightweight gate to block unauthorized registrations.
OPENAI_API_KEY Key for the OpenAI-compatible API used to embed syllabi and run AI helpers.
OPENAI_BASE_URL Base endpoint for the OpenAI-compatible (Gemini) API.
GEMINI_API_KEY Optional direct Gemini key for lesson plan generation fallbacks.
AI_LESSON_PLAN_MODEL Model identifier for automated tutor prep plans.
RESEND_API_KEY Resend API key for transactional onboarding/payment emails.
NEXT_PUBLIC_BASE_URL Public URL used in Stripe redirects and outbound emails.
STRIPE_PUBLISHABLE_KEY Client-side Stripe key for Checkout and Elements.
STRIPE_SECRET_KEY Server-side Stripe key for Checkout Sessions and refunds.
STRIPE_WEBHOOK_SECRET Signing secret to verify inbound Stripe webhooks.
NEXT_PUBLIC_AGORA_APP_ID Agora application ID for live classrooms.
OSS_ENDPOINT MinIO/S3 endpoint for syllabus and transcript uploads.
OSS_ACCESS_KEY / OSS_SECRET_KEY Object storage credentials.
OSS_BUCKET_NAME Bucket holding uploaded assets.
NEXT_PUBLIC_OSS_BUCKET_NAME Client-exposed bucket name for previews/uploads.
OSS_PUBLIC_URL Optional CDN/public base URL for serving uploaded files.
OSS_REGION Optional region string for S3-compatible providers.
OSS_USE_SSL true/false flag toggling HTTPS for object storage calls.
SEED_ACCESS_TOKEN Token required by internal seeding utilities.

Keep .env.local out of version control. In production, load secrets from your deployment platform (Vercel, Supabase, AWS, etc.).

Getting Started

  1. Install dependencies
    npm install
  2. Push the schema to the cloud database (cloud-first workflow)
    npx prisma db push
    This command synchronizes Supabase/Postgres using DIRECT_URL/DATABASE_URL and regenerates the Prisma Client.
  3. Run the app
    npm run dev
    Open http://localhost:3000 and test the end-to-end flow (auth, booking, payment, video, forum). Stripe operates in test mode until you swap in live keys.

Database Model Overview

The core entities are defined in prisma/schema.prisma:

  • University → Course — Universities own many courses. Each course stores embeddings for AI matching and ties to uploaded syllabi.
  • User ↔ Course — Tutors list their teachable courses; students indirectly associate through enrollment and sessions.
  • Session ← User — Sessions connect a student and tutor for a specific course, capturing price, Stripe session IDs, reviews, and status.
  • Question → Course/User — Community Q&A posts link to the authoring student and the relevant course, powering discovery feeds.
  • PromoCode — Discount entities with activation flags and usage caps consumed during Stripe checkout.

This schema is deployed via npx prisma db push or migrations, and pgvector-powered search layers on top of the course embeddings.

Repository Layout

app/                  # App Router routes, layouts, API handlers, UI components
prisma/schema.prisma  # Canonical Prisma data model
lib/                  # Prisma client, OSS utilities, mailers, Agora helpers
public/               # Static assets, manifest, icons
scripts/              # Seed and maintenance scripts
docker-compose.yml    # Optional local Postgres + MinIO stack

Supporting Stack

  • Next.js 14 App Router with server components and edge-ready API routes.
  • Prisma ORM + Supabase Postgres + pgvector for transactional and semantic data.
  • NextAuth for credential login and role-based routing.
  • Stripe for checkout, webhooks, and promo-aware billing.
  • OpenAI/Gemini for embeddings, semantic search, and AI-generated lesson plans.
  • Resend for transactional email delivery.
  • Agora for low-latency video classrooms.
  • Tailwind CSS and fully responsive UI primitives.
  • PWA tooling enabling installation and offline shell.

With this documentation you can provision environment variables, push the schema to the cloud, and run the full P2P Tutors experience end to end.***

Releases

Packages

Contributors

Languages