An AI-powered application that generates custom question papers using the Gemini API. This application allows you to create exams with multiple sections and automatically generates questions for each section based on the requirements.
- Create exams with configurable sections
- Section configurations include:
- Section name
- Number of total questions
- Number of questions to attempt
- Marks per question
- Negative marking settings
- Question types (MCQ, MSQ, Numerical)
- AI-powered question generation using Google's Gemini API
- Generate questions section by section
- Persistent storage in SQLite database
- RESTful API for frontend integration
- FastAPI - High-performance web framework
- SQLAlchemy - SQL toolkit and ORM
- Google Gemini API - AI-powered content generation
- Pydantic - Data validation
- SQLite - Database (can be configured to use other databases)
- Python 3.8+
- Gemini API key (from Google AI Studio)
-
Clone the repository:
git clone https://github.com/yourusername/qpgen.git cd qpgen -
Install dependencies:
pip install -r requirements.txt -
Create a .env file:
cp .env.example .env -
Edit the .env file and add your Gemini API key:
GEMINI_API_KEY=your_api_key_here
Start the FastAPI server:
python main.py
The API will be available at http://localhost:8000.
- API documentation: http://localhost:8000/docs
- Interactive API explorer: http://localhost:8000/redoc
POST /api/exams/
Request body:
{
"name": "Physics Mid-term",
"time_minutes": 180,
"sections": [
{
"name": "Mechanics",
"total_questions": 10,
"questions_to_attempt": 8,
"marks_per_question": 5.0,
"negative_marking_allowed": true,
"negative_marks": 1.0,
"question_type": "MCQ"
},
{
"name": "Thermodynamics",
"total_questions": 5,
"questions_to_attempt": 5,
"marks_per_question": 10.0,
"negative_marking_allowed": false,
"question_type": "NUM"
}
]
}GET /api/exams/{exam_id}
POST /api/exams/sections/{section_id}/generate-questions
GET /api/exams/sections/{section_id}/questions
The application uses two key features of the Gemini API:
-
Structured Response - Ensures questions are generated in a consistent format suitable for different question types (MCQ, MSQ, Numerical).
-
Function Calling - Enables advanced question generation with specific formatting requirements.
MIT