Inspiration

Most AI study tools optimise content generation: summaries, notes, explanations. The science of learning says something else — durable learning comes from active recall and spaced repetition. MentorAI was built around that gap: an AI tutor that asks instead of lectures, flashcards scheduled by the SM-2 algorithm, quizzes with instant grading, and voice recall where you explain answers out loud and get AI-scored feedback.

For the PayPal AI Hackathon we closed the loop on access: students without an OpenRouter API key can now buy credits with PayPal and spend them on AI time, one credit per request.

What it does

  • AI Tutor — Socratic tutoring sessions; the tutor teaches through questions, with streaming answers and per-message retry.
  • Flashcards — generate decks from any topic or from your weak areas, reviewed on an SM-2 spaced-repetition schedule.
  • Quiz — auto-generated quizzes with instant verdicts and explanations; answers are graded without leaking the answer key.
  • Voice Recall — record or type an explanation, get AI evaluation against the key points, with weak-topic extraction feeding back into flashcards.
  • Knowledge Graph — visual map of concepts and their relations, built from your notes.
  • Workspace & notes — PDF import with AI structuring, note summarising and translation.
  • Credits (PayPal) — buy Starter (50/$5.00), Standard (200/$15.00), or Bulk (1000/$50.00) packs via PayPal (sandbox for the demo). Keyless users spend 1 credit per AI request on the shared key; users with their own OpenRouter key are never charged; demo accounts never pay. Failed requests refund automatically, and captures are idempotent — retrying can never double-credit.

How we built it

React 19 + TypeScript + Vite frontend; Express API on Node; MongoDB Atlas; OpenRouter as the AI provider with a bring-your-own-key or shared-key path; PayPal Orders API (sandbox) for payments; a standalone Whisper service for transcription. Deployed on free tiers: Vercel (frontend), Render (backend + Whisper).

The payments slice is deliberately hardened: prices live in a server-side pack table (never the request body), the PayPal client refuses any non-sandbox API base, balance changes go through a single atomic service with a $gte-guarded spend, and the capture path verifies COMPLETED status plus exact amount match before crediting.

Challenges we ran into

  • Demo credentials shipped in the client bundle. Fixed with a server-side passwordless demo-login endpoint; the client never sees a demo password now.
  • Rate limiters keyed on a forgeable header. Re-keyed authed limiters by user id behind trust proxy.
  • Credits unspendable at first — the client key-gate blocked every AI action for keyless users, which would have made purchased packs dead on arrival. Made the gate credit-aware; the server stays authoritative.
  • Free-tier cold starts — the first request after idle can take ~20 s and briefly report a degraded DB connection; the app recovers on its own.
  • Whisper on 512 MB — the small model OOMs on Render's free tier, so the service ships tiny with the model selectable by env.

Accomplishments that we're proud of

  • End-to-end PayPal sandbox flow live: order → sandbox approval → idempotent capture → balance → credit-funded AI request.
  • A per-request usage/cost ledger for every AI call (the honesty layer behind the credit price).
  • Zero-spend stack: the whole thing runs on free tiers.
  • 237 server tests green; the deployed client and server ship from the same commits, so no version drift.

What we learned

Payment code has to be boring: server-side prices, idempotent captures, atomic balances, and a sandbox-only API base enforced in code, not in docs. And a "free" AI product still needs a real access model — credits turned out to be the simplest honest one.

What's next for MentorAI

  • Cost-based credit pricing from the metered usage ledger (today it's a flat 1 credit per request).
  • Real buyer onboarding past the demo: receipts, invoices, and a credit-expiry policy.

Built With

Share this project:

Updates

Submission history