Skip to content
Sanjiv Sutar
ReactJSNextJSWeb AppTypeScriptLLMAIGenerative AIFrontendAPIBackend

TopicTutor: AI Tutorial Generator That Spends Tokens Only Once

TopicTutor is an AI tutorial generator that turns any keyword into a level-based mini-course with runnable code and embedded videos, built from one cached model call.

Share
TopicTutor hero mockup: a hand-drawn browser window with a topic search bar, three difficulty levels, a lesson panel with runnable code and a Run button, and an embedded video player
The question
I wanted one page that teaches any topic at my level, with lessons, runnable code and videos, using only free API tiers and finishing inside a ten-second Netlify function timeout.
Stack & tools
Next.js 16, React 19, TypeScript, Google Gemini API, Groq API, YouTube Data API v3, Vimeo API, Netlify Blobs, Netlify, highlight.js, Plyr, jsonrepair
What I found
Each topic and level normally costs one model call, then repeat visits hit a 30-day cache at zero tokens. Broken JSON gets repaired locally, and degraded builds never get cached.

Every time I tried to learn something new, I ended up with ten tabs: a blog post pitched too low, a docs page pitched too high, and three videos that spent five minutes on setup. I wanted an AI tutorial generator that took one keyword, asked how deep I wanted to go, and gave me a real mini-course on one page. That became TopicTutor.

The first sketch was a search box and three level buttons. The constraint that shaped everything came from hosting: Netlify's free plan kills a synchronous function at about ten seconds, and I didn't want a database or a bill. So every request gets a wall-clock budget of nine seconds, roughly 70% for the lesson and the rest for videos.

The core rule is one model call per topic and level. The prompt asks for strict minified JSON with four or five subtopics, each holding a lesson, key points, short code snippets, an experiment and one official reference. Gemini's lite flash model runs first with temperature 0.4 and output capped at 5,120 tokens. A heavier model only runs on a retry with more than 18 seconds left, so never on Netlify.

Models often break JSON, usually with a stray quote inside a code string. Paying for a second call to fix that felt wasteful, so the parser runs jsonrepair first, then a brace-matching salvager that keeps every complete subtopic it can find. When Groq rejects a response, the error still carries the model's text, and I feed that into the same repair path instead of calling again.

Caching is the database. Keywords become slugs in the edge proxy, so "React Hooks!" and "react-hooks" land on the same key, slug::level, stored in Netlify Blobs for 30 days. Only a fully successful AI build is saved; a fallback lesson from a busy model gets retried next visit. The page and its metadata share one memoised build per request, and each IP gets 20 fresh generations an hour.

Videos got the same treatment. YouTube and Vimeo are searched in parallel with at most three subtopics in flight, since each YouTube search costs 100 quota units. Non-embeddable results are dropped, both lists are ranked together by how well the title matches the subtopic, and the page shows thumbnails only. No player loads until someone clicks.

Most of the work wasn't the AI part. It was deciding when not to call it.

Gallery

Platforms I've helped build for

  • Honda logo
  • Tata Steel Aashiyana logo
  • myTrident logo
  • Hero Lectro logo
  • GSK Protect logo
  • Sokrati logo
  • Axis Mutual Fund logo
  • Aditya Birla Capital logo
  • Croma logo
  • Trident Group logo

Kind words

Don't just take my word for it

Notes from teammates and client stakeholders I've worked alongside.

Testimonial 1 of 8.

Had the pleasure of working closely with Sanjiv, and he is an exceptional leader who seamlessly bridges high-level strategy with deep technical execution.

Sanjiv excels in technical problem-solving—when complex, high-stakes engineering or architectural challenges arise, he is the person you want in the room. He approaches problems analytically, quickly getting to the root cause and devising elegant, scalable solutions.

Beyond his technical acumen, Sanjiv is a standout leader in solution delivery and team management. He has a proven ability to align cross-functional teams, streamline processes, and keep project milestones on track without sacrificing quality. His clear communication, structured approach, and genuine investment in supporting team members make him a trusted partner and a pillar on any team.

I highly recommend Sanjiv to any organization looking for a strong technical strategist and reliable leader who consistently delivers results.

Aman Kumar Sinha(LinkedIn profile, opens in a new tab)

Senior Product Manager at Merkle Sokrati · Oct 2026