# What I learned building an AI study app with Next.js 16, Supabase and FSRS

> Source: <https://dev.to/m_kashifiqbal_9589140133/what-i-learned-building-an-ai-study-app-with-nextjs-16-supabase-and-fsrs-2mfm>
> Published: 2026-11-25 03:07:53+00:00

**Recommendation:** Schema-validate LLM-generated questions and discard or regenerate failures, and run long generations as claimed jobs in Postgres rather than inside a request.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

I'm Kashif, and for the last few months I've been building [StudyCove](https://studycove.pro), an app that turns lecture PDFs into flashcards, practice quizzes, timed mock exams, mind maps and a daily study plan.

This isn't a launch post. It's the handful of things that bit me while building it, in case they save you a weekend.

My first version used a hand-rolled SM-2 variant. It "worked", but intervals drifted in weird ways once people skipped a few days. Switching to FSRS via `ts-fsrs` fixed it, and the library handles the awkward cases (lapses, relearning, overdue cards) better than I would have. Store the full card state, not just the next due date, so you can re-schedule if you ever change parameters.

LLMs will happily return a multiple-choice question with two correct answers, an answer that isn't in the options, or a duplicate of question 3. I now validate each question against a strict schema and drop or regenerate anything that fails, instead of trusting the response. Users notice one broken question far more than they notice ten good ones.

Generating a 40-question mock exam from a 90-page PDF can take a while. Doing it inside a request meant timeouts and stuck spinners. Moving generation to a job table with a claim/dispatch pattern in Postgres (and an index on the dispatch query) made it reliable, and lets the UI poll for progress.

I hit cases where a Server Action promise never settled after a network blip, leaving buttons disabled forever. Wrapping UI-side calls in a small "settle within N seconds or show a retry" helper made the app feel far more solid on bad connections, which is exactly where students are (library Wi-Fi, buses).

Rendering mind maps on a canvas myself was a time sink. Mind Elixir gave me editing, drag and keyboard shortcuts for free. The catch: its change events plus my autosave created a save loop. An `inFlight` guard and a revision number on every save fixed it, and revision numbers also stopped two tabs from overwriting each other.

I'm working on making mock exams feel closer to real papers (sections, marks, time per question). If you've built something similar, or you're a student with opinions, I'd love to hear what you'd do differently.

You can try it at [studycove.pro](https://studycove.pro).
