💡 Inspiration ExamForgeAI was born from a simple observation: educators and students struggle with creating high-quality, diverse exam papers efficiently. Traditional exam generation is time-consuming, repetitive, and often lacks variety. We envisioned a solution that combines the power of artificial intelligence with practical education technology to:

Empower educators to create comprehensive exams in minutes, not hours Generate multiple variations of questions to reduce cheating and improve learning assessment Democratize quality exam creation for teachers with varying technical expertise Provide intelligent question generation based on specific educational content Support multiple document formats to make the tool universally applicable The vision is to transform exam preparation from a tedious manual task into an intelligent, automated process that maintains educational quality while saving valuable time.

🎯 What it does ExamForgeAI-Service is an intelligent backend API that:

Accepts educational content - Users can provide study materials, textbooks, or course notes via direct text input or PDF file uploads Leverages AI Intelligence - Uses Google's advanced Gemini AI model to understand content deeply and extract key learning concepts Generates Multiple-Choice Questions - Automatically creates high-quality MCQs with: Relevant, well-crafted questions Multiple plausible answer options Clear correct answers Educational variety to test different levels of understanding Produces Formatted Output - Converts generated questions into professional PDF exam papers ready for printing or digital distribution Ensures Content Safety - Sanitizes and validates all generated HTML content to prevent security issues Provides RESTful API - Exposes intuitive endpoints for easy integration with frontend applications Core API Endpoints: GET /api/gemini/ask - Generate AI responses from prompts POST /api/gemini/pdf - Generate complete exam PDFs from text and optional document attachments 🔧 How we built it Architecture Overview We built ExamForgeAI-Service following microservices and clean architecture principles:

┌─────────────────────────────────────────────────────┐ │ Frontend Application (React/Angular) │ └────────────────┬────────────────────────────────────┘ │ HTTP/REST ┌────────────────▼────────────────────────────────────┐ │ API Layer - GeminiController │ │ (/ask, /pdf endpoints) │ └────────────────┬────────────────────────────────────┘ │ ┌────────────────▼────────────────────────────────────┐ │ Business Logic Layer - Services │ │ ├─ GeminiService (AI interaction) │ │ ├─ DocumentService (orchestration) │ │ └─ PdfConversor (PDF rendering) │ └────────────────┬────────────────────────────────────┘ │ ┌────────────────▼────────────────────────────────────┐ │ Utility Components │ │ ├─ PromptBuilder (intelligent prompt crafting) │ │ └─ HtmlSanitizer (content security) │ └────────────────┬────────────────────────────────────┘ │ ┌────────────────▼────────────────────────────────────┐ │ External Services │ │ ├─ Google Gemini AI API │ │ └─ OpenHTML to PDF Renderer │ └─────────────────────────────────────────────────────┘ Key Development Decisions: Spring Boot Framework - Chose for rapid development, excellent ecosystem, and production-ready features Gemini AI Model (gemini-2.5-flash) - Selected for its superior understanding of educational content and fast response times Service-Oriented Architecture - Separated concerns into GeminiService, DocumentService, and utility components Component-Based Design - Created reusable components for prompt building and HTML sanitization RESTful API Design - Implemented clean, predictable endpoints following REST conventions PDF Generation Pipeline - Integrated OpenHTML to PDF for professional document rendering Technology Choices: Java 17 - Latest LTS version with modern language features Spring Boot 3.5.9 - Provides enterprise-grade stability with latest framework improvements Google Genai Library - Direct integration with Gemini AI API JSoup & OpenHTML to PDF - Powerful combination for HTML processing and PDF generation CORS Configuration - Enables seamless frontend-backend communication 🚧 Challenges we ran into

  1. AI Model Consistency and Quality Control Challenge: Getting the Gemini AI model to consistently generate well-structured MCQs with appropriate difficulty levels Solution: Implemented PromptBuilder component with intelligent prompt engineering techniques, including specific formatting instructions and quality guidelines
  2. PDF Generation Complexity Challenge: Converting dynamically generated HTML to professional-quality PDFs while maintaining formatting and styling Solution: Integrated OpenHTML to PDF library with comprehensive HTML sanitization to ensure both quality output and security
  3. HTML Security and Sanitization Challenge: AI-generated HTML could contain malicious scripts or problematic markup that could compromise security Solution: Developed HtmlSanitizer component using JSoup to strip dangerous elements while preserving legitimate formatting
  4. Large File Handling Challenge: Processing large PDF files without overwhelming server resources or timing out Solution: Configured Spring Boot to handle multipart file uploads up to 50MB with appropriate timeout settings
  5. CORS and Frontend Integration Challenge: Enabling secure cross-origin requests for the frontend while maintaining security standards Solution: Implemented CorsConfig class with appropriate allowed origins, methods, and headers configuration
  6. Prompt Engineering Optimization Challenge: Balancing comprehensive instructions to the AI model while keeping prompts concise for faster responses Solution: Created modular PromptBuilder that constructs optimized prompts based on user requirements
  7. API Response Time Challenge: Ensuring reasonable response times when processing complex document analysis and question generation Solution: Selected Gemini 2.5-Flash model specifically for its speed while maintaining quality 🏆 Accomplishments that we're proud of
  8. Intelligent End-to-End Pipeline ✨ Successfully built a complete pipeline that transforms raw educational content into professional exam PDFs with minimal user intervention. The flow from document upload → AI processing → PDF generation works seamlessly.

  9. Robust Content Security 🔒 Implemented a comprehensive security layer with HTML sanitization that protects against injection attacks while maintaining the quality of AI-generated content. This ensures the platform is safe for educational institutions.

  10. Clean, Maintainable Architecture 🏗️ Structured the codebase with clear separation of concerns, making it easy to maintain, test, and extend. Each component has a single responsibility, following SOLID principles.

  11. Comprehensive Test Coverage ✅ Developed unit tests for core components:

DocumentServiceTest GeminiControllerTests HtmlSanitizerTest ExamForgeAiServiceApplicationTests

  1. Professional PDF Output 📄 Generated exam papers look professional and are ready for immediate use - they maintain formatting, support complex HTML structures, and are fully customizable.

  2. Flexible API Design 🔌 Created versatile endpoints that support multiple use cases:

Simple text-to-questions generation Document-based exam creation Flexible parameter options for customization

  1. Developer-Friendly 👨‍💻 Comprehensive code documentation, clear component organization, and RESTful API design make it easy for developers to understand and extend the system.

📚 What we learned

  1. AI Prompt Engineering is an Art Learned that the quality of AI output heavily depends on how well you phrase your prompts. Invested time in understanding how to structure comprehensive yet efficient prompts that guide the AI toward desired outputs.

  2. Security First Architecture Discovered that integrating security measures early in the development process (like HTML sanitization) is far more efficient than adding them later. Every layer needs security consideration.

  3. PDF Generation Complexity Realized that converting HTML to PDF involves numerous edge cases around styling, fonts, and layout. Proper testing and fallback mechanisms are essential.

  4. Importance of Error Handling Understood that in AI-driven applications, comprehensive error handling and validation are crucial because AI models can produce unexpected results.

  5. Spring Boot Best Practices Gained deep experience with:

  6. Dependency injection and component lifecycle

  7. Configuration management

  8. RESTful controller design

  9. Integration with external APIs

  10. Educational Content Understanding

  11. Learned nuances about what makes good exam questions:

  12. Clarity and precision in question wording

  13. Multiple viable answer options

  14. Questions that test different cognitive levels

  15. Appropriate difficulty progression

  16. Scalability Considerations Understanding that a service like this needs to handle varying loads, from individual teachers to entire school districts, requires thoughtful architecture and caching strategies.

🚀 What's next for ExamForge AI Phase 2 - Enhanced Features Multiple Question Types - Support for True/False, Short Answer, Essay, and Fill-in-the-Blank questions. Difficulty Level Control - Allow users to specify question difficulty (easy, medium, hard). Question Customization - Users can review and edit AI-generated questions before finalizing. Image Support - Extract and include images from PDF documents in questions where relevant.

Phase 3 - Analytics & Insights Question Quality Metrics - AI-powered analysis of question quality and difficulty discrimination. Usage Analytics - Track which questions are most frequently used and perform well. Performance Tracking - Correlate exam performance with content topics. Student Analytics - Provide educators with insights into student performance and learning gaps.

Phase 4 - Advanced Intelligence Adaptive Question Generation - Generate questions based on student performance history. Content Recommendations - Suggest topics for exam coverage based on curriculum analysis. Multi-Language Support - Generate exams in multiple languages with cultural relevance. Voice-Based Input - Accept questions via voice commands and audio content.

Phase 5 - Integration & Ecosystem LMS Integration - Direct integration with Learning Management Systems (Canvas, Blackboard, Moodle). Mobile Application - Native mobile app for on-the-go exam creation. Collaboration Features - Allow multiple educators to collaborate on exam creation. Question Bank - Build a searchable repository of generated questions for reuse. Cloud Deployment - Deploy on cloud platforms with auto-scaling capabilities.

Phase 6 - Premium Features Custom Branding - School/institution branding on generated exams. Advanced Formatting - Custom templates and styling options. Bulk Processing - Generate multiple exams from batch inputs. Export Options - Support for multiple export formats (DOCX, HTML, LaTeX). Version Control - Track changes and maintain exam revision history.

Share this project:

Updates