This is the core engine for the AI-Powered Quiz Application. It leverages Spring AI to transform text or PDF documents into interactive quizzes, managed through a secure JWT-based architecture.
Important
This service is designed to be paired with the AI-Powered Quiz App Frontend for a complete user experience.
- 🧠 AI Question Generation: Generate high-quality multiple-choice questions from any topic description or uploaded PDF file using Spring AI.
- 🔒 Secure Authentication: Robust user management with registration, login, and stateless JWT authentication.
- 🤝 Quiz Collaboration: Share quizzes with other users via email to allow them access.
- 📊 Analytics & Tracking: Track quiz attempts and view summarized performance analytics.
- 📄 PDF Integration: Automatic text extraction from PDF documents for context-aware quiz generation.
- Framework: Spring Boot 3.5.7
- AI: Spring AI with OpenAI/OpenRouter integration
- Security: Spring Security & JJWT
- Database: PostgreSQL with Spring Data JPA
- PDF Library: Apache PDFBox 3.0.6
- Utilities: Lombok, Dotenv, Jackson
The project follows a clean, modular Spring Boot architecture:
src/main/java/com/thilina271/AI/powered/Quiz/app/
├── config/ # Security & CORS configurations
├── controller/ # REST API Endpoints
├── dto/ # Data Transfer Objects for API communication
├── exception/ # Custom exception handling
├── filter/ # JWT Authentication filters
├── mapper/ # Object mapping logic
├── model/ # JPA Entities (User, Quiz, Question, etc.)
├── repository/ # Database access interfaces
├── service/ # Business logic & AI interaction
└── validation/ # Request validation groups
- JDK 17 or higher.
- PostgreSQL (running on port 5432).
- OpenAI/OpenRouter API Key.
# Clone the repository
git clone https://github.com/ThilinaJayamal/AI-powerd-Quiz-App-Backend.git
cd AI-powerd-Quiz-App-Backend
# Setup environment variables
# Create a .env file in the root directory:
DB_PASSWORD=your_postgres_password
OPENAI_API_KEY=your_api_key
# Run the application
./mvnw spring-boot:run
The application will be accessible at http://localhost:8080.
POST /register: Register a new user.POST /login: Authenticate and receive a JWT.POST /logout: Invalidate session.GET /me: Get current authenticated user details.
GET /: Generate questions from adescriptionandsize.POST /upload: Upload a PDF to generate questions from its content.
POST /: Save a generated quiz.GET /{id}: Fetch a specific quiz.GET /all: Fetch all quizzes created by the user.DELETE /{id}: Remove a quiz.
POST /{id}?email={user_email}: Share a quiz with another user.GET /{id}: View share details for a quiz.GET /all: View all quizzes shared with you.DELETE /delete: Revoke access for a shared user.
POST /api/attempt/quiz/{id}: Submit answers for a quiz.GET /api/attempt/quiz/all: View all previous quiz attempts.GET /api/analytics/summary: Get overall performance statistics.
We welcome contributions to improve the AI logic or add new features!
- Fork the project.
- Create your feature branch:
git checkout -b feature/AmazingFeature. - Commit changes:
git commit -m 'Add some AmazingFeature'. - Push to branch:
git push origin feature/AmazingFeature. - Open a Pull Request.
Thilina Jayamal - @ThilinaJayamal
This project is licensed under the MIT License.