Skip to content

Srishanth57/QuizGeneratorAssignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  AI Wiki Quiz Generator

Transform any Wikipedia article into an interactive, educational quiz using AI! This full-stack application uses Google's Gemini AI to automatically generate engaging quizzes from Wikipedia content.

Python FastAPI React License

โœจ Features

  • ๐Ÿ”— URL Input: Simply paste any Wikipedia article URL
  • ๐Ÿค– AI-Powered: Uses Google Gemini to generate intelligent quiz questions
  • ๐Ÿ“ Smart Quizzes: Creates 5-10 multiple choice questions with explanations
  • ๐Ÿ’พ History Tracking: Saves all generated quizzes in a database
  • ๐ŸŽฏ Interactive UI: Take quizzes with instant feedback and scoring
  • ๐Ÿ“Š Answer Explanations: Learn why answers are correct or incorrect

๐ŸŽฅ Demo

Screenshot1 Screenshot2

๐Ÿ› ๏ธ Tech Stack

Backend

  • Python 3.10+ - Core programming language
  • FastAPI - Modern web framework for APIs
  • SQLAlchemy - Database ORM
  • LangChain - Framework for LLM applications
  • Google Gemini - AI model for quiz generation
  • BeautifulSoup4 - Web scraping library
  • SQLite - Database for storing quizzes

Frontend

  • React - UI library
  • Tailwind CSS - Styling framework
  • Vite - Build tool

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • Node.js 16+ and npm
  • Google Gemini API key (Get it here)

Installation

1. Clone the repository

git clone https://github.com/Srishanth57/QuizGeneratorAssignment.git
cd ai-wiki-quiz-generator

2. Setup Backend

cd backend

# Create virtual environment
python -m venv venv

# Activate it
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
echo "GEMINI_API_KEY=your_api_key_here" > .env

3. Setup Frontend

cd ../frontend

# Install dependencies
npm install

Running the Application

Start Backend (Terminal 1)

cd backend
python main.py

Backend runs at http://localhost:8000

Start Frontend (Terminal 2)

cd frontend
npm run dev

Frontend runs at http://localhost:5173

Open your browser and visit http://localhost:5173 ๐ŸŽ‰

๐Ÿ“– How to Use

  1. Generate a Quiz

    • Click on "Generate Quiz" tab
    • Paste a Wikipedia URL (e.g., https://en.wikipedia.org/wiki/Artificial_intelligence)
    • Click "Generate Quiz"
    • Wait 10-30 seconds for AI to create your quiz
  2. Take the Quiz

    • Select answers for each question
    • Click "Submit Quiz" when done
    • See your score and read explanations
  3. View History

    • Click "Quiz History" tab
    • See all your generated quizzes
    • Click "View Details" to retake any quiz

๐Ÿ—๏ธ Project Structure

ai-quiz-generator/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ database.py              # Database setup
โ”‚   โ”œโ”€โ”€ models.py                # Data models
โ”‚   โ”œโ”€โ”€ scraper.py               # Wikipedia scraper
โ”‚   โ”œโ”€โ”€ llm_quiz_generator.py    # AI quiz generation
โ”‚   โ”œโ”€โ”€ main.py                  # FastAPI app
โ”‚   โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”‚   โ””โ”€โ”€ .env                     # API keys (create this)
โ”‚
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ components/
    โ”‚   โ”‚   โ””โ”€โ”€ QuizDisplay.jsx  # Quiz UI component
    โ”‚   โ”œโ”€โ”€ services/
    โ”‚   โ”‚   โ””โ”€โ”€ api.js           # API calls
    โ”‚   โ”œโ”€โ”€ tabs/
    โ”‚   โ”‚   โ”œโ”€โ”€ GenerateQuizTab.jsx
    โ”‚   โ”‚   โ””โ”€โ”€ HistoryTab.jsx
    โ”‚   โ”œโ”€โ”€ App.jsx              # Main app
    โ”‚   โ””โ”€โ”€ index.css            # Styles
    โ””โ”€โ”€ package.json

๐Ÿ”Œ API Endpoints

Method Endpoint Description
POST /generate_quiz Generate quiz from Wikipedia URL
GET /history Get all generated quizzes
GET /quiz/{id} Get specific quiz by ID

Example Request

curl -X POST http://localhost:8000/generate_quiz \
  -H "Content-Type: application/json" \
  -d '{"url": "https://en.wikipedia.org/wiki/Python_(programming_language)"}'

๐Ÿงช Testing

Test the Backend API

# Visit the interactive API docs
http://localhost:8000/docs

Test with Sample URLs

  • Python: https://en.wikipedia.org/wiki/Python_(programming_language)
  • AI: https://en.wikipedia.org/wiki/Artificial_intelligence
  • Space: https://en.wikipedia.org/wiki/Solar_System

๐Ÿ› Troubleshooting

Backend Issues

"GEMINI_API_KEY not found"

  • Make sure you created .env file in backend folder
  • Check your API key is correct

"Module not found"

  • Activate virtual environment: source venv/bin/activate
  • Install dependencies: pip install -r requirements.txt

Frontend Issues

"Failed to fetch"

  • Make sure backend is running on port 8000
  • Check if both frontend and backend are running

Styles not loading

  • Run npm install again
  • Clear browser cache

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ง Contact

Your Name - @yourtwitter

Project Link: https://github.com/yourusername/ai-wiki-quiz-generator


โญ If you found this project helpful, please give it a star!

๐Ÿ”ฎ Future Enhancements

  • User authentication and profiles
  • Difficulty level selection
  • Export quiz to PDF
  • Share quizzes with friends
  • Quiz analytics and statistics
  • Support for multiple languages
  • Mobile app version
  • Timed quiz mode
  • Leaderboard system

Releases

No releases published

Packages

No packages published

Languages