# namansingh69/exam-question-generator architecture

> Architecture diagram of the GitHub repository namansingh69/exam-question-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/namansingh69/exam-question-generator
- Repository: https://github.com/namansingh69/exam-question-generator

## Overview

##### Project type and purpose
- This is a full-stack web application (“Exam Question Generator”) built with Flask (Python) on the backend and plain HTML/JS/CSS on the frontend.
- Purpose: Accept course materials (PDF, text, JSON, etc.), extract topics via OCR/PDF processors, call Google Gemini AI to generate a configurable set of exam questions, and export the result as PDF/HTML/Markdown.

##### File structure
- Top-level files:
- app.py – main Flask application entry point and request handlers
- setup.py – environment setup script
- requirements.txt – Python dependencies
- LICENSE, README.md
- Directories:
- static/ – frontend assets (index.html, main.js, CSS)
- uploads/ – holds user-uploaded raw files
- (README mentions temp_outputs/ for generated files, though not in the snippet)
- Key patterns:
- Single-process, monolithic Flask server
- MVC-style separation: static frontend vs. Python server logic vs. data storage
- Integration points: OCR (pytesseract), PDF tools (PyPDF2, pdf2image, pdfkit), external AI API (Google Gemini)

##### README for additional insights
- The “Technology Stack” section confirms Flask backend, Bootstrap/JS frontend, AI and PDF/OCR integrations.
- Features list reveals the core flows: file upload → AI analysis → question generation → export.

##### Detail
- Every major function (uploading, OCR, AI call, formatting, exporting) is its own node.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        A1["index.html"]:::frontend
        A2["main.js"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        B["Flask App"]:::backend
        subgraph "Processing Pipeline"
            direction TB
            B1["PDF/Text Extractor"]:::backend
            B2["AI Client"]:::backend
            B3["Formatter & Exporter"]:::backend
        end
    end

    %% File Storage
    U["Uploads (raw inputs)"]:::storage
    T["Temp Outputs"]:::storage

    %% External Services
    C1["Google Gemini API"]:::external
    C2["Tesseract OCR"]:::external
    C3["wkhtmltopdf"]:::external

    %% Optional Database
    DB["Database (optional)"]:::db

    %% Project Documentation & Config
    Setup["setup.py"]:::config
    Readme["README.md"]:::doc
    License["LICENSE"]:::doc

    %% Data Flows
    A1 -->|HTTP POST upload| B
    A2 -->|HTTP POST upload| B
    B -->|save files| U
    U -->|read files| B1
    B1 -->|extracted text| B2
    B2 -->|API request| C1
    C1 -->|questions payload| B2
    B2 -->|payload| B3
    B3 -->|generate files| T
    T -->|serve files| B
    B -->|HTTP GET download| A1

    %% Optional DB interaction
    B ---|logs| DB

    %% Click Events
    click A1 "https://github.com/namansingh69/exam-question-generator/blob/main/Question Paper Generation/static/index.html"
    click A2 "https://github.com/namansingh69/exam-question-generator/blob/main/Question Paper Generation/static/js/main.js"
    click B "https://github.com/namansingh69/exam-question-generator/blob/main/Question Paper Generation/app.py"
    click Setup "https://github.com/namansingh69/exam-question-generator/blob/main/Question Paper Generation/setup.py"
    click U "https://github.com/namansingh69/exam-question-generator/tree/main/Question Paper Generation/uploads/"
    click Readme "https://github.com/namansingh69/exam-question-generator/blob/main/README.md"
    click License "https://github.com/namansingh69/exam-question-generator/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px;
    classDef backend fill:#D0FFD6,stroke:#333,stroke-width:1px;
    classDef external fill:#FFE5B4,stroke:#333,stroke-width:1px;
    classDef storage fill:#F0F0F0,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef db fill:#EEEEEE,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef config fill:#FFF0D0,stroke:#333,stroke-width:1px;
    classDef doc fill:#F9F9F9,stroke:#333,stroke-width:1px;
```
