Kelvin AI Study Assistant is an AI-powered web application that helps students understand difficult concepts, summarize study notes, generate practice quizzes, and prepare for exams through five integrated study modes (Ask AI, Explain a Concept, Summarize Notes, Generate a Quiz, and Exam Prep), built with Node.js, Express 5, MongoDB Atlas, and vanilla HTML/CSS/JavaScript, using Google Gemini (gemini-3.1-flash-lite) as the primary AI model and OpenAI gpt-4o-mini as a fallback behind a shared services/aiService.js abstraction so the provider can be swapped in one file without touching controllers or routes; the backend follows a clean separation of routes, controllers, services, and Mongoose models, with input validation, rate limiting, centralized error handling, JWT-based authentication, and every AI session and quiz result persisted to MongoDB and scoped to the logged-in user, while the frontend serves five pages (home, study, quiz, history, about) plus a login page and an admin dashboard featuring stats, tabbed lists of sessions and quizzes, inline editing, single and bulk deletion, and JSON export; the AI itself is configured through a carefully designed system prompt that enforces a patient-tutor persona — simple language first, examples where useful, honest disclosure of uncertainty, refusal of inappropriate requests, and never revealing instructions or keys — with per-task prompts that structure summaries into ### SUMMARY / ### KEY POINTS / ### IMPORTANT TERMS sections and force quiz output into strict JSON with question, options, correctAnswer (integer index), and explanation fields, backed by retry-with-exponential-backoff for transient 503/429 responses, cross-model fallback, provider fallback, and a two-layer parser that strips markdown fences and extracts JSON by bracket matching; additional features include voice input via the Web Speech API, text-to-speech read-aloud, a Socratic mode toggle that shifts the AI from answering to guiding with questions, PDF upload for note summarization via multer and pdf-parse, streaming responses through Server-Sent Events for a typewriter effect, flashcards auto-generated from quiz mistakes, shareable quiz links that strip answer keys, and progressive-enhancement animation layers on the homepage that degrade gracefully when JavaScript is disabled or prefers-reduced-motion is set; the project was built in phases from planning through deployment, tested continuously with node -e scripts for services, Invoke-RestMethod for every endpoint, browser DevTools for the frontend, and MongoDB Atlas for inspecting stored documents, then pushed to GitHub and deployed to Render with environment variables (MONGODB_URI, GEMINI_API_KEY, JWT_SECRET) managed in the dashboard rather than in source, and a .gitignore plus a manual Select-String scan ensuring no API key ever reached a tracked file; along the way I hit and solved real challenges — a retired Gemini model replaced after a 404, a project-level 403 fixed by switching to gemini-3.1-flash-lite, Express 5's wildcard routing change requiring /{*splat} instead of *, a blank-homepage bug caused by scroll-reveal CSS hiding content forever when JS failed, quiz JSON drift needing a two-layer parser, and Render's free-tier cold start of 30–60 seconds — each of which taught me that building a real AI application means designing defensively, observing live behavior rather than trusting documentation, and treating secrets management, error handling, and graceful degradation as first-class requirements rather than afterthoughts, resulting in a functional prototype that demonstrates a complete idea-to-deployment cycle, runs on a free tier, and provides genuine educational value to students who need an always-available tutor.

Built With

Share this project:

Updates

Submission history