Skip to content

SadhanaShree25/AI-Quiz-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Quiz Generator (QUIZ.AI)

๐Ÿš€ A premium, full-stack AI-powered learning platform that generates intelligent, personalized quizzes from any topic or text-readable PDF. Users can create accounts, track their progress, and review complete historical questions and answers with detailed AI explanations.


๐Ÿ†• What's New (Latest Updates)

Here is a summary of the major features, UI redesigns, and bug fixes recently implemented:

1. ๐Ÿ“‚ PDF Quiz Generation (Contextual Extraction)

  • Document Parsing: Added support for uploading study materials, lecture notes, or textbook chapters in PDF format (up to 5MB).
  • Robust PDF Parsing: Integrated class-based parsing via pdf-parse v2 (new PDFParse(Uint8Array)), fixing legibility and server crashes caused by legacy function-based parser integrations.
  • Smart Quiz Extraction: AI analyzes the semantic context of your uploaded PDF and generates precise questions matching your preferred blueprint.

2. ๐Ÿ“ Quiz Revision History

  • Question Logs Retention: Extended the MongoDB schema to retain complete historical records of quiz runsโ€”storing questions, option arrays, correct answers, explanations, and user selections.
  • Detailed Revision Modal: Built a dedicated revision review window in the History tab. Users can review past quizzes with color-coded options (green for correct, red for selected wrong answers) and reference easy AI explanations for revision.

3. ๐ŸŒ— Universal Light & Dark Mode

  • Theme Contrast Optimization: Fixed visibility bugs in light theme. High-contrast colors are applied to labels, metric values, inputs, and dropdowns. Correct/incorrect highlights dynamically swap to rich dark-emerald and dark-rose tones in light mode to guarantee full readability.
  • Responsive Profile Section: Refactored the ProfileSection subcomponent to listen directly to the global theme context, ensuring identity cards and metric cards adapt seamlessly.

4. โšก Sleek, Simplified User Flow

  • Direct Landing Dashboard: Removed the generic landing page. Both / and /dashboard load the main dashboard directly.
  • Dynamic Guest View: Logged-out visitors can explore the dashboard's features, capability cards, and product descriptions, with a clear "Login / Register ๐Ÿ”‘" button below the header. Protecting api routes keeps keys secure, prompting guests to authenticate only when launching a quiz.
  • Unified Auth Rename: Cleaned up route structures and normalized the login/signup controllers.

5. ๐Ÿ› ๏ธ Authentication & Evaluation Bug Fixes

  • Case-Insensitive Logins: Standardized user creation and authentication handlers to enforce trimmed, lowercase emails, resolving MongoDB duplication and registration blocks.
  • Strict Evaluation logic: Normalized AI-generated answers to strictly match one of the provided option choices (case-insensitive fallback), preventing evaluation discrepancy.

โœจ Core Features

  • ๐Ÿง  AI Quiz Generator: Create custom quizzes on any topic using Groq's Llama 3.3 70B models, selecting question counts (5-20) and format blueprints (MCQs, True/False, Mixed).
  • ๐ŸŒ— Dark & Light Modes: Seamless visual settings saved locally.
  • ๐Ÿ“Š Analytics Matrix: Tracks your total quizzes completed, learning streak, best scores, and average score directly on the dashboard.
  • ๐ŸŽฎ Interactive Quiz Player: Includes a live progress tracker, instant answer grading, and contextual explanations.

๐Ÿ› ๏ธ Tech Stack

๐Ÿ’ป Frontend

  • React 19 & Vite 7 (Modern UI & ultra-fast hot reloading)
  • React Router 7 (Unified routing)
  • Tailwind CSS 4 (Responsive styling and layouts)
  • Axios (API requests)

๐Ÿ–ฅ๏ธ Backend

  • Node.js & Express 5 (Server framework)
  • MongoDB (Database, using Mongoose)
  • JWT & bcryptjs (Secure authentication mapping)
  • pdf-parse (PDF text extraction)
  • Groq SDK (Orchestrates Llama model integration)

๐Ÿ“ Project Structure

Ai-Quiz-Generator/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ db.js              # MongoDB connection
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ authController.js  # Register, login, me, forgot/reset password (casing normalized)
โ”‚   โ”‚   โ””โ”€โ”€ quizController.js  # Generate quiz, PDF quiz extraction, save result, history, stats
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ authMiddleware.js  # JWT verification
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.js            # User schema (trimmed & lowercase email constraints)
โ”‚   โ”‚   โ””โ”€โ”€ QuizResult.js      # Quiz result schema (stores complete historical questions/answers)
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ authRoutes.js      # /api/auth/*
โ”‚   โ”‚   โ”œโ”€โ”€ quizRoutes.js      # /api/quiz/* (secured routes)
โ”‚   โ”‚   โ””โ”€โ”€ userRoutes.js      # /api/user/*
โ”‚   โ”œโ”€โ”€ .env                   # Backend environment variables
โ”‚   โ”œโ”€โ”€ server.js              # Express app entry point
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ QuizPlayer.jsx       # Theme-aware interactive player & summary sheet
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MyQuizzesSection.jsx # Quizzes history list & revision review modal
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ProtectedRoute.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AuthContext.jsx    # Authentication provider
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ThemeContext.jsx   # Dark/light theme state provider
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard.jsx      # Core Dashboard workspace & ProfileSection
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ QuizForm.jsx       # Topic-based quiz config form
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PdfQuizForm.jsx    # PDF upload drag-and-drop quiz form
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Login.jsx          # Login screen
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Signup.jsx         # Account registration screen
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js             # Axios setup with interceptors
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx            # Routing configuration
โ”‚   โ”‚   โ”œโ”€โ”€ index.css          # Design system classes
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx
โ”‚   โ”œโ”€โ”€ .env                   # Frontend environment variables
โ”‚   โ”œโ”€โ”€ tailwind.config.cjs
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ””โ”€โ”€ README.md

โš™๏ธ Setup & Installation

1. Prerequisites

  • Node.js 18+ installed on your system.
  • MongoDB connection (local server or MongoDB Atlas).
  • Groq API Key (Obtain for free at console.groq.com).

2. Installation Steps

  1. Clone the repository:

    git clone <repository-url>
    cd Ai-Quiz-Generator
  2. Configure the Backend:

    cd backend
    npm install

    Create a .env file in the backend folder:

    PORT=5000
    MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/ai_quiz_db
    JWT_SECRET=your_secure_jwt_random_secret_string
    GROQ_API_KEY=gsk_your_groq_api_key_here
    FRONTEND_URL=http://localhost:5174
  3. Configure the Frontend:

    cd ../frontend
    npm install

    Create a .env file in the frontend folder (optional, default falls back to 5000):

    VITE_API_URL=http://localhost:5000

๐Ÿš€ Running the Application

To run the application locally in development mode:

Terminal 1 โ€“ Start Backend:

cd backend
npm run dev

Backend runs at: http://localhost:5000

Terminal 2 โ€“ Start Frontend:

cd frontend
npm run dev

Frontend runs at: http://localhost:5174 (or http://localhost:5173 depending on port availability)


๐Ÿ“ก API Reference

Base URL: http://localhost:5000/api

๐Ÿ”‘ Authentication (/api/auth)

  • POST /register: Registers a new user.
  • POST /login: Log in user and receive a JWT.
  • GET /me: Fetch authenticated user profile data (Requires Token).

๐Ÿ“ Quiz Operations (/api/quiz)

  • POST /generate-quiz: Generates a quiz from a topic (JSON payload) or PDF (Multipart file upload). (Requires Token).
  • POST /save-result: Saves completed quiz answers, score, and explanations. (Requires Token).
  • GET /history: Retrieves authenticated user's quiz log history. (Requires Token).
  • GET /stats: Computes streak, total quiz counts, average scores. (Requires Token).
  • DELETE /history/all: Clears the user's completed history list. (Requires Token).

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Sadhana Shree

About

AI-powered full-stack quiz application that generates personalized quizzes on any topic using Groq (Llama). Includes authentication, quiz history, dashboard analytics, and an interactive quiz experience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors