How ratna-babu/jntuk-question-bank-solver works
Project Type and Purpose
• The project is a full-stack web application built with Next.js 13+ and React.
• Its purpose is to allow users to upload a PDF of a question bank, extract questions, generate detailed answers using Google’s Generative AI (Gemini), and finally produce an answer PDF.
• The process involves handling file uploads, PDF text extraction (using pdf-parse), AI integration, and generating downloadable PDFs.
Analyzing the File Structure
• The top-level “app” directory indicates use of Next.js 13’s App Router. Here you have:
• Pages (e.g., app/page.js – the home page for file upload)
• API routes (under app/api/):
▸ app/api/extract-questions/route.js – handles question extraction from PDFs.
▸ app/api/generate-answers/route.js – calls the Gemini API to generate detailed answers.
• Other directories like "components" (e.g., ErrorBoundary.js) and configuration files under "app/config" (e.g., answerFormat.js, fakeanswer.js) that provide settings for the operations.
• The “public” folder contains static assets including a generated answers PDF, suggesting that the output is served statically post-generation.
Key Components & Their Relationships
• Frontend (Next.js/React UI):
• Provides the user interface – upload button, progress feedback, and a link to download the generated PDF.
• Consumes API endpoints for question extraction and answer generation.
• Backend (Next.js API Routes):
• Endpoint for extracting questions from the uploaded PDF.
• Endpoint for generating answers with Google Generative AI.
• PDF Processing Module:
• Uses the pdf-parse library to extract text/questions from the PDF.
• AI Integration:
• Connects to Google Generative AI (Gemini) for generating detailed answers. This integration is critical as it drives the answer generation logic.
• File/Asset Management:
• Uploaded PDFs are processed.
• Generated answer PDFs are stored in the “public” directory to be easily served.
Architectural Patterns and Design Principles
• Separation of Concerns: The file structure neatly divides UI components, API endpoints, configuration, and static assets.
• Modular API Endpoints: Clearly split between extraction and answer generation.
• External API Integration: The system depends on an external AI API which is modular and can be replaced or updated independently.
• Use of Next.js best practices: Leveraging file-based routing for APIs and components within the “app” directory.