Spaces:
Sleeping
Sleeping
|
Download Backend/README.md from smit9604/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 3.84 kB
-
https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Backend/README.md
- Command line
-
hf download hf://spaces/smit9604/ExamCraftAI/Backend/README.md
-
curl -L -o README.md https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Backend/README.md
3.84 kB
| # ExamCraft.ai - AI-Powered Question Paper Generator | |
| ExamCraft.ai is a high-performance web application designed for educators to generate structured, academically rigorous question papers in seconds. By leveraging **Llama 3.3 (70B)** via Groq AI, it maps syllabus content directly to **Bloom’s Taxonomy** cognitive levels. | |
| --- | |
| ## 🚀 Tech Stack & Tools | |
| ### **1. Backend (The Brain)** | |
| - **Python & Flask**: The core web framework handling routing, file management, and API orchestration. | |
| - **Groq AI SDK**: Used to interface with the Llama 3.3 70B model for lightning-fast inference (low latency). | |
| - **PyPDF2 & python-docx**: Robust libraries used to parse text from complex PDF and Word documents. | |
| - **ReportLab**: A professional PDF toolkit used to programmatically generate the final exam papers. | |
| ### **2. Frontend (The Experience)** | |
| - **Tailored CSS & Bootstrap 5**: Implements a "Premium Glassmorphism" design system with mesh gradients and fluid layout. | |
| - **Vanilla JavaScript**: Handles asynchronous file uploads (AJAX), multi-step state management, and real-time UI updates (like the stepper and preview). | |
| - **FontAwesome & Google Fonts**: Integrated **Plus Jakarta Sans** and **Outfit** for clean academic typography. | |
| --- | |
| ## 🧠 Core Functionalities & Logic | |
| ### **A. Intelligent Text Extraction (`extractor.py`)** | |
| **Logic:** The system detects the file extension and routes it to the specific parser. | |
| - **PDF**: Uses `PdfReader` to iterate through pages and extract text layers. | |
| - **DOCX**: Iterates through paragraphs and tables to preserve content order. | |
| - **Implementation**: Text is stripped of excess whitespace and truncated to fit within optimal AI context windows (Token optimization). | |
| ### **B. AI Question Generation (`ai_generator.py`)** | |
| **Logic:** We use a "Structured Prompting" strategy. Instead of just asking for questions, the system passes: | |
| 1. **The Context**: Extracted text from the syllabus. | |
| 2. **The Cognitive Framework**: The selected Bloom’s levels (Remember, Apply, Analyze, etc.). | |
| 3. **The Constraint Matrix**: Difficulty level and the user-defined Exam Pattern (marks, question counts). | |
| 4. **The Output Format**: Forces the AI into **JSON Mode**, ensuring the backend can always parse the result into a preview. | |
| ### **C. The 3-Step Workflow Implementation** | |
| 1. **Upload Phase**: The file is stored with a unique UUID to prevent collisions. JavaScript triggers the extraction instantly. | |
| 2. **Configuration Phase**: Users define the exam "Schema." UI buttons dynamically add or remove sections ($N$ questions of $X$ marks). | |
| 3. **Generation Phase**: A POST request sends the JSON payload to Flask, which awaits the Groq API response. | |
| ### **D. Professional PDF Export (`pdf_generator.py`)** | |
| **Logic:** Converts the raw JSON from the AI into a structured document. | |
| - **Formatting**: Uses `ParagraphStyles` to apply academic formatting (Times New Roman style, bold question numbers, alignment). | |
| - **MCQ Parsing**: Automatically detects MCQ types to create indented [A, B, C, D] lists. | |
| - **Implementation**: ReportLab's `SimpleDocTemplate` builds the "story" sequentially, ensuring page breaks and headers are handled correctly. | |
| --- | |
| ## ✨ UI/UX Philosophy | |
| - **Glassmorphism**: Using `backdrop-filter` and semi-transparent layers to create depth. | |
| - **Interactive Feedback**: A dynamic **Stepper** updates states as you progress, and badges confirm successful file processing. | |
| - **Accessibility**: High-contrast light text on dark backgrounds ensures readability for long documentation. | |
| --- | |
| ## 🛠️ Installation & Setup | |
| 1. **Clone & Install**: | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| 2. **Environment**: | |
| Set `GROQ_API_KEY` in a `.env` file. | |
| 3. **Launch**: | |
| ```bash | |
| python app.py | |
| ``` | |
| --- | |
| *Developed with ❤️ as a premium tool for modern educators.* | |