Generative AI / RAG / Full Stack
AI Quiz & MCQ Generator
A full-stack AI application that generates intelligent quizzes from uploaded documents or web-sourced information. Users sign in, upload material or ask a topic question, and get a graded MCQ set back with their history saved.
What it is.
The app has two ways in. A learner can upload their own file, in which case questions are generated from retrieved chunks of that file. Or they can ask about a topic they have no material for, and the app pulls current information through SerpAPI before generating.
Attempts are graded immediately and stored per user, so the chat history doubles as a record of what has been practised.
02 — The problem
Writing good practice questions is slow, and the questions you most need are the ones about material you have just been given. Generic quiz banks never cover a specific handout or a current topic.
03 — The approach
Split the pipeline into a Next.js app that owns authentication and the interface, and a Flask service that owns retrieval and generation — so the Python AI work stays in Python while the UI stays in the React ecosystem.
What it actually does.
Authentication with NextAuth
Session handling on the Next.js side so quiz history and uploads belong to a specific account.
Document upload
Files are parsed, chunked and retrieved from, so generated questions stay tied to the uploaded content.
Web-sourced generation
When there is no document, SerpAPI supplies current search results as the context for generation.
Graded MCQs
Answers are scored as soon as the quiz is submitted, with the correct option and reasoning revealed.
Chat and quiz history
Past sessions are persisted in MongoDB and can be reopened rather than regenerated.
Context-aware answers
Follow-up questions reuse the same retrieved context instead of starting from scratch.
How the pieces fit together.
Next.js app
Interface plus NextAuth session handling. Proxies AI requests to the Flask service rather than calling the model directly.
Flask AI service
Python service that owns parsing, retrieval, SerpAPI calls and OpenAI generation.
Retrieval layer
Uploaded documents are chunked and embedded; the highest-scoring chunks become the generation context.
SerpAPI
Fallback context source when the request is topic-based rather than document-based.
MongoDB
Stores users, chat sessions, generated quizzes and attempt results.
The stack.
Chosen for the problem, not for the resume.
- Next.jsReactNextAuth
- FlaskPythonREST APIs
- OpenAIRAGEmbeddingsSerpAPI
- MongoDB
From input to output.
The sequence a single request travels through.
- 01
Source
Either an uploaded document or a SerpAPI search result set becomes the raw material.
- 02
Chunk & retrieve
Content is split and the passages most relevant to the requested topic are selected.
- 03
Generate
OpenAI produces question stems, distractors and the correct option from that context.
- 04
Grade & store
Submissions are scored server-side and written to MongoDB against the signed-in user.
The part that stuck.
Student portfolio, so this section is the point — here is what this build actually taught me.
Running the AI work in a separate Flask service kept the Python tooling I wanted without fighting the Next.js runtime — and made the boundary between UI and model work obvious.
Distractor quality is the hard part of MCQ generation. Asking the model for plausible-but-wrong options explicitly, rather than just 'four options', changed the output substantially.
NextAuth removed a whole class of session bugs I would have written myself, but it made me actually read how sessions and callbacks work rather than copying a snippet.
Medical Chatbot
A retrieval-augmented chatbot that answers from a curated medical knowledge base instead of from model memory.
Have a project idea?
I'm open to freelance projects, collaborations, internships, and opportunities where I can contribute while continuing to grow.
Usually replies within a day · Lahore, Pakistan · PKT (UTC+5)