Skip to content

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.

Next.jsNextAuthFlaskMongoDBOpenAIRAGSerpAPI
AI Quiz & MCQ Generator — schematic overview diagram
Schematic overview — a diagram, not a product screenshot
01Overview

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.

04Key features

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.

05Architecture

How the pieces fit together.

AI Quiz & MCQ Generator — system architecture diagram
Document and web-search paths converging on generation. Diagram, not a screenshot.
  1. 01

    Next.js app

    Interface plus NextAuth session handling. Proxies AI requests to the Flask service rather than calling the model directly.

  2. 02

    Flask AI service

    Python service that owns parsing, retrieval, SerpAPI calls and OpenAI generation.

  3. 03

    Retrieval layer

    Uploaded documents are chunked and embedded; the highest-scoring chunks become the generation context.

  4. 04

    SerpAPI

    Fallback context source when the request is topic-based rather than document-based.

  5. 05

    MongoDB

    Stores users, chat sessions, generated quizzes and attempt results.

06Technology

The stack.

Chosen for the problem, not for the resume.

Frontend
Next.jsReactNextAuth
Backend
FlaskPythonREST APIs
AI
OpenAIRAGEmbeddingsSerpAPI
Data
MongoDB
07AI & data workflow

From input to output.

The sequence a single request travels through.

  1. 01

    Source

    Either an uploaded document or a SerpAPI search result set becomes the raw material.

  2. 02

    Chunk & retrieve

    Content is split and the passages most relevant to the requested topic are selected.

  3. 03

    Generate

    OpenAI produces question stems, distractors and the correct option from that context.

  4. 04

    Grade & store

    Submissions are scored server-side and written to MongoDB against the signed-in user.

08What I learned

The part that stuck.

Student portfolio, so this section is the point — here is what this build actually taught me.

  • 01

    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.

  • 02

    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.

  • 03

    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.

Next project

Medical Chatbot

A retrieval-augmented chatbot that answers from a curated medical knowledge base instead of from model memory.

Work together

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)

Chat on WhatsApp