Prepity: AI-powered MCQ generator

Prepity: AI-powered MCQ generator

Prepity is an AI-driven application designed to generate on-demand multiple-choice questions for interview and exam preparation using large language models. Developed with Next.js, it integrates AI SDK and Prisma to facilitate efficient, customized question creation.

Project links

Project date

Jan 2023

Project authors

Praveen Thirumurugan

Project Overview

Prepity is an AI-powered platform that leverages large language models to generate high-quality multiple-choice questions on demand. Built for students, job seekers, and professionals preparing for interviews and examinations, it provides instant, customized question sets tailored to specific topics and difficulty levels.

Key Features

  • AI-Powered Question Generation - Utilizes large language models to produce tailored multiple-choice questions for diverse subjects
  • Full-Stack Next.js Application - Built with Next.js for optimal performance with server-side rendering and API routes
  • AI SDK Integration - Seamless integration with AI SDK for efficient LLM interactions and streaming responses
  • Prisma Database Management - Robust data layer with Prisma ORM for secure storage and retrieval of generated content
  • Customizable Parameters - Users can specify topic, difficulty level, number of questions, and question format

Technical Implementation

Full-Stack Architecture

Next.js Application

Built a modern full-stack application using Next.js:

  • App Router: Leveraged Next.js 13+ App Router for improved performance
  • Server Components: Utilized React Server Components for efficient rendering
  • API Routes: Built RESTful API endpoints using Next.js API routes
  • Streaming: Implemented streaming for real-time question generation

Application features:

  • Responsive Design: Mobile-first responsive interface
  • Fast Navigation: Client-side routing for instant page transitions
  • SEO Optimized: Server-side rendering for search engine optimization
  • Performance: Optimized for Core Web Vitals

TypeScript Implementation

Comprehensive TypeScript throughout the stack:

  • Type Safety: End-to-end type safety from database to UI
  • Interface Definitions: Clear interfaces for questions, users, and sessions
  • Generic Types: Reusable type definitions across components
  • Type Inference: Leveraged TypeScript's powerful inference capabilities

AI Integration

AI SDK for LLM Integration

Integrated AI SDK for seamless LLM interactions:

  • Multiple Providers: Support for OpenAI, Anthropic, and other providers
  • Streaming Responses: Real-time question generation with streaming
  • Prompt Engineering: Carefully crafted prompts for high-quality questions
  • Context Management: Efficient context handling for better results

Question generation features:

  • Topic-Based Generation: Generate questions for any topic
  • Difficulty Levels: Easy, Medium, Hard difficulty options
  • Answer Explanations: AI-generated explanations for each answer
  • Question Validation: Automatic validation of generated questions

Prompt Engineering

Sophisticated prompt engineering for quality questions:

  • Structured Prompts: Well-defined prompt templates for consistency
  • Context Inclusion: Include relevant context for accurate questions
  • Format Specification: Strict formatting for parseable output
  • Error Recovery: Fallback prompts for edge cases

Database & Storage

Prisma ORM

Implemented robust data layer with Prisma:

  • Schema Definition: Type-safe database schema
  • Migrations: Version-controlled database migrations
  • Query Optimization: Efficient queries with Prisma's query engine
  • Type Generation: Automatic TypeScript types from schema

Database schema:

  • Users: User accounts and authentication
  • Questions: Generated questions with metadata
  • Question Sets: Collections of related questions
  • User Progress: Track user attempts and scores
  • Topics: Categorization and organization

PostgreSQL Database

Utilized PostgreSQL for reliable data storage:

  • Relational Structure: Normalized database design
  • Indexing: Optimized indexes for query performance
  • Full-Text Search: Search questions by topic and content
  • JSON Support: Store complex question metadata

Frontend Design

Tailwind CSS Styling

Modern, beautiful UI with Tailwind CSS:

  • Utility-First: Rapid UI development with utility classes
  • Responsive: Mobile-first responsive design system
  • Dark Mode: Full dark mode support
  • Custom Theme: Branded color scheme and components

UI Components:

  • Question Cards: Beautiful display of questions and options
  • Progress Indicators: Visual feedback during generation
  • Interactive Forms: Smooth form interactions
  • Result Display: Clear presentation of scores and explanations

User Experience

Intuitive interface designed for learning:

  • Simple Flow: Clear user journey from topic to results
  • Instant Feedback: Real-time feedback on answers
  • Progress Tracking: Visual progress through question sets
  • Bookmarking: Save questions for later review

Technologies Used

Frontend

  • Next.js: React framework for production
  • React: UI library with hooks and context
  • TypeScript: Type-safe frontend code
  • Tailwind CSS: Utility-first CSS framework

Backend

  • Next.js API Routes: Serverless API endpoints
  • Prisma: Next-generation ORM
  • PostgreSQL: Relational database
  • AI SDK: LLM integration library

AI & ML

  • OpenAI API: GPT-4 for question generation
  • AI SDK: Vercel's AI SDK for streaming
  • Prompt Engineering: Optimized prompts for quality

DevOps & Tools

  • Vercel: Deployment and hosting
  • Git: Version control
  • ESLint: Code linting
  • Prettier: Code formatting

Features & Functionality

Question Generation

Comprehensive generation capabilities:

  • Custom Topics: Generate questions on any subject
  • Difficulty Levels: Three difficulty levels for progressive learning
  • Question Types: Multiple choice, true/false, fill-in-the-blank
  • Batch Generation: Generate multiple questions at once
  • Instant Generation: Questions generated in seconds

Learning Features

Tools to enhance learning:

  • Answer Explanations: Detailed explanations for each answer
  • Score Tracking: Track performance over time
  • Topic Organization: Organize questions by topic
  • Review Mode: Review incorrect answers
  • Export Options: Export questions to PDF or text

User Management

Complete user account features:

  • Authentication: Secure user registration and login
  • Profile Management: Manage user preferences
  • History: View past question sets and scores
  • Favorites: Bookmark favorite topics
  • Progress Dashboard: Visual progress tracking

Impact & Results

User Engagement

  • Active Users: Growing user base of students and professionals
  • Question Generation: Thousands of questions generated monthly
  • User Satisfaction: Positive feedback on question quality
  • Retention: High user retention and repeat usage

Technical Performance

  • Response Time: Sub-3-second question generation
  • Reliability: 99.9% uptime
  • Scalability: Handles concurrent users efficiently
  • Quality: High-quality questions validated by users

Educational Impact

  • Exam Success: Users reporting improved exam performance
  • Interview Prep: Effective tool for interview preparation
  • Continuous Learning: Enables self-paced learning
  • Knowledge Gaps: Helps identify and fill knowledge gaps

Future Enhancements

Planned Features

  • More Question Types: Essay questions, coding challenges
  • Collaborative Learning: Share question sets with friends
  • AI Tutoring: Personalized tutoring based on performance
  • Mobile App: Native iOS and Android applications
  • Gamification: Points, badges, and leaderboards
  • Study Plans: AI-generated personalized study plans

Technical Improvements

  • Caching: Improve performance with intelligent caching
  • Offline Mode: Generate and review questions offline
  • Real-time Collaboration: Study groups and live quizzes
  • Advanced Analytics: Detailed performance analytics

Open Source

Prepity is open-source and available on GitHub:

  • MIT License: Free for personal and educational use
  • Community Contributions: Welcoming PRs and feedback
  • Documentation: Comprehensive setup guides
  • Examples: Sample integrations and use cases

Development Insights

Challenges Overcome

  • Question Quality: Ensuring consistently high-quality questions
  • Performance: Optimizing for fast generation times
  • Cost Management: Balancing quality with API costs
  • User Experience: Creating intuitive learning flow

Technical Learnings

  • Next.js provides excellent full-stack development experience
  • AI SDK simplifies LLM integration significantly
  • Prompt engineering is crucial for quality output
  • Streaming improves perceived performance dramatically

Use Cases

Prepity serves various learning scenarios:

  • Students: Exam preparation and study aid
  • Job Seekers: Technical interview preparation
  • Teachers: Generate quiz questions for classes
  • Professionals: Skill assessment and learning
  • Bootcamps: Supplemental learning material

Prepity demonstrates the practical application of generative AI in education, making personalized learning accessible and efficient for everyone.