metadata
title: QuizFlash - AI-Powered Quiz Generation
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
app_port: 3000
QuizFlash π
An intelligent quiz generation platform powered by AI that creates customizable educational questions from any source material.
Features
- Multiple Question Types: Support for multiple choice, cloze (fill-in-the-blank), grammar check, reading comprehension, and essay questions
- AI-Powered Generation: Uses OpenAI GPT-4 to generate high-quality, educational questions
- Configurable Parameters: Each question type has customizable difficulty levels and specific parameters
- Source Material Support: Generate questions based on your own text content
- Real-time Question Bank: Build and manage a collection of generated questions
- Modern UI: Clean, responsive interface built with Next.js and Tailwind CSS
Getting Started
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
System Architecture
graph TD
A["π§ Question Config<br/>(questionConfig.ts)"] --> B["π Parameter Form<br/>(QuestionParameterForm)"]
B --> C["ποΈ Parameter Input<br/>(ParameterInput)"]
C --> D["π€ User Input<br/>(UI Interaction)"]
D --> E["π Parameters Object<br/>(QuestionParameters)"]
E --> F["π― Question Type<br/>Selection"]
F --> G["π Source Material<br/>(Optional)"]
E --> H["π Generate Question<br/>(API Call)"]
G --> H
H --> I["π€ AI Generation<br/>(OpenAI API)"]
I --> J["π Prompt Templates<br/>(prompt-management.ts)"]
J --> K["π Template Rendering<br/>(renderTemplate)"]
K --> L["π€ Final Prompt<br/>(to AI Model)"]
L --> M["π§ AI Processing<br/>(GPT-4 Mini)"]
M --> N["π Zod Schema<br/>Validation"]
N --> O["β
Structured Response<br/>(JSON Object)"]
O --> P["πΎ Question Bank<br/>(State Management)"]
P --> Q["π΄ Question Card<br/>(UI Component)"]
Q --> R["ποΈ User Display<br/>(Question Bank UI)"]
subgraph "Configuration Layer"
A
B
C
end
subgraph "User Interaction Layer"
D
E
F
G
end
subgraph "API Processing Layer"
H
I
J
K
L
end
subgraph "AI Generation Layer"
M
N
O
end
subgraph "Display Layer"
P
Q
R
end
style A fill:#e1f5fe
style J fill:#fff3e0
style Q fill:#f3e5f5
style M fill:#e8f5e8
Flow Description
1. Configuration Layer
- Question Config: Abstract configuration system that defines parameter schemas for each question type
- Parameter Form: Dynamically renders form fields based on the configuration
- Parameter Input: Reusable input components (select, range, input, checkbox)
2. User Interaction Layer
- User Input: Users interact with dynamically generated parameter forms
- Parameters Object: Collects user preferences (difficulty, number of options, etc.)
- Question Type Selection: Users choose from available question types
- Source Material: Optional text input to provide context for questions
3. API Processing Layer
- Generate Question: API endpoint processes the generation request
- Prompt Templates: Pre-defined, configurable templates for each question type
- Template Rendering: Dynamic substitution of user parameters into prompt templates
- Final Prompt: Complete, contextualized prompt ready for AI processing
4. AI Generation Layer
- AI Processing: OpenAI GPT-4 Mini generates questions based on the prompt
- Zod Schema Validation: Ensures AI responses match expected structure
- Structured Response: Clean, validated JSON object containing question data
5. Display Layer
- Question Bank: State management for storing and organizing generated questions
- Question Card: UI components for rendering individual questions
- User Display: Final question bank interface with selection and management features
Key Architecture Benefits
- π§ Configurable: Adding new question types requires only configuration changes
- β»οΈ Reusable: Components work across all question types
- π‘οΈ Type-Safe: Full TypeScript support throughout the entire flow
- π¦ Modular: Clean separation of concerns between layers
- π Scalable: Easy to extend with new features and question types
Tech Stack
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- AI Integration: OpenAI GPT-4 Mini, Vercel AI SDK
- Validation: Zod schema validation
- Styling: Tailwind CSS with dark mode support
- State Management: React hooks and context
Project Structure
src/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β β βββ chat/ # Chat functionality
β β βββ generate-question/ # Single question generation
β β βββ generate-quiz/ # Multiple question generation
β βββ page.tsx # Main application page
βββ components/ # React components
β βββ QuestionParameterForm.tsx # Dynamic parameter form
β βββ ParameterInput.tsx # Reusable input components
βββ types/ # TypeScript type definitions
β βββ quiz.ts # Core quiz types
β βββ questionConfig.ts # Configuration types and schemas
βββ prompts/ # AI prompt templates
βββ prompt-management.ts # Question generation prompts
Adding New Question Types
Thanks to the abstract configuration system, adding new question types is incredibly simple:
- Add configuration to
src/types/questionConfig.ts:
'your-new-type': {
id: 'your-new-type',
parameters: [
{
key: 'difficulty',
label: 'Difficulty Level',
type: 'select',
defaultValue: 'intermediate',
options: [
{ value: 'beginner', label: 'Beginner' },
{ value: 'intermediate', label: 'Intermediate' },
{ value: 'advanced', label: 'Advanced' },
],
},
// Add more parameters as needed
],
}
- That's it! No component modifications required. The UI will automatically render the appropriate form fields.
Learn More
To learn more about the technologies used:
- Next.js Documentation - learn about Next.js features and API
- Vercel AI SDK - AI integration toolkit
- OpenAI API - AI model documentation
- Tailwind CSS - utility-first CSS framework
Deploy on Vercel
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.