Transform any PDF or text into a polished question bank — in seconds.
Upload → Generate → Preview → Export. Powered by Gemini AI, built with FastAPI & React.
Demo · Features · Quick Start · API Docs · Contributing
MCQ Generator Pro is a full-stack AI application that eliminates the tedious work of writing multiple-choice questions. Upload a PDF or paste text, configure your settings, and get a complete, export-ready question bank in moments.
Built for educators, trainers, content creators, and anyone who needs questions — fast.
| Feature | Description |
|---|---|
| 📄 PDF & Text Upload | Drag-and-drop PDF or raw text input |
| 🤖 AI Generation | Powered by Google Gemini for accurate, context-aware MCQs |
| 👁️ Live Preview | Review all questions before exporting |
| 📝 3-Format Export | Word doc with answers, without answers, and answer key only |
| ⚡ Fast API Backend | Async FastAPI with auto-generated Swagger docs |
| 🎨 Clean React UI | Responsive, intuitive frontend |
mcq_generator_pro/
├── backend/ # FastAPI application
│ ├── app/
│ │ ├── main.py # Entry point & route registration
│ │ ├── routers/ # API route handlers
│ │ ├── services/ # Gemini AI integration & MCQ logic
│ │ └── models/ # Pydantic schemas
│ ├── requirements.txt
│ └── .env.example # Environment variable template
│
├── frontend/ # React application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Route-level pages
│ │ └── services/ # API client
│ ├── package.json
│ └── vite.config.js
│
├── .gitignore
└── README.md
- Python 3.9+
- Node.js 18+
- A Google Gemini API key — get one free at aistudio.google.com
git clone https://github.com/Vellorpavan/mcq_generator_pro.git
cd mcq_generator_procp .env.example .envOpen .env and fill in your values:
# .env
GEMINI_API_KEY=your_actual_api_key_here # Required — never share this🔒 Security note:
.envis listed in.gitignoreand will never be committed. See the Security section for best practices.
cd backend
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # macOS / Linux
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Start the development server
uvicorn app.main:app --reloadThe API will be live at http://localhost:8000
Interactive docs available at http://localhost:8000/docs
Open a new terminal tab:
cd frontend
npm install
npm run devThe app will be live at http://localhost:5173
Keeping your API key safe is critical. Follow these practices:
✅ Do
- Store secrets in
.envonly — it's already in.gitignore - Rotate your Gemini API key if you suspect it was exposed
- Use environment variables in production (e.g., Railway, Render, Vercel env settings)
- Restrict your API key in Google AI Studio to specific IPs or referrers where possible
❌ Never
- Commit
.envto version control - Hardcode your API key in source files
- Share your key in GitHub Issues, Discord, or screenshots
If you accidentally pushed your key: Remove the commit, invalidate the key immediately in Google AI Studio, and generate a new one.
The backend exposes a RESTful API. Full interactive documentation is auto-generated by FastAPI.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/upload |
Upload a PDF or text content |
POST |
/api/generate |
Generate MCQs from uploaded content |
GET |
/api/preview |
Fetch generated questions for preview |
POST |
/api/export |
Export questions as Word documents |
Run locally: http://localhost:8000/docs
Backend
- FastAPI — High-performance Python API framework
- Google Generative AI SDK — Gemini model integration
- python-docx — Word document generation
- PyMuPDF / pdfplumber — PDF text extraction
- Uvicorn — ASGI server
Frontend
Contributions are welcome! Here's how to get involved:
- Fork this repository
- Create a feature branch:
git checkout -b feat/your-feature-name - Commit your changes:
git commit -m "feat: add your feature" - Push to your branch:
git push origin feat/your-feature-name - Open a Pull Request
Please follow Conventional Commits for commit messages.
This project is licensed under the MIT License — see the LICENSE file for details.
Made with ❤️ by Vellorpavan
⭐ Star this repo if it saved you time!