# dagimg-dot/did-exit architecture

> Architecture diagram of the GitHub repository dagimg-dot/did-exit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dagimg-dot/did-exit
- Repository: https://github.com/dagimg-dot/did-exit

## Overview

##### Project type and purpose
- This is a single-page, browser-only web application (no dedicated backend server)
- Purpose: allow users to upload PDF exams, extract multiple-choice questions via Google Gemini AI, cache results locally, and present them as interactive quizzes

##### File structure
- Top-level artifacts
– index.html: entry point
– Makefile: build/serve helper (e.g., static-server or optimization tasks)
– README.md: high-level overview
- /css: styling for components, theme toggle, quiz layout
- /js: pure-JS modules, each encapsulating a major feature
– ai-integration.js: handles calls to Google Gemini AI
– pdf-processor.js & pdf-analyzer.js: split, chunk, parse PDF files
– batch-processor.js: orchestrates progressive loading of questions
– file-uploader.js: drag-and-drop file interface
– database-manager.js: localStorage/IndexedDB caching of API keys and processed PDFs
– quiz-manager.js: drives quiz logic (question navigation, exam vs. feedback mode)
– theme-manager.js & ui-components.js: UI theming, shared widgets
– app-info.js & main.js: application bootstrap, event wiring

##### README for insights
- External dependency: Google AI Studio (Gemini API)
- Key features: smart caching, progressive loading, two quiz modes, responsive design

a. Main components (containers)
1. User Interface (Browser)
– index.html + /css + ui-components.js + theme-manager.js
2. Application Controller
– main.js (wires modules)
– file-uploader.js
– quiz-manager.js
3. Service Layer
– pdf-processor.js
– pdf-analyzer.js
– batch-processor.js
– ai-integration.js
4. Storage Layer
– database-manager.js (localStorage / IndexedDB)
5. External Service
– Google Gemini AI API
b. Relationships & data flows
- User → (click/drag) → File Uploader → PDF Processor
- PDF Processor → (chunks) → Batch Processor
- Batch Processor → AI Integration → Google AI
- Google AI → AI Integration → PDF Analyzer → Quiz Manager
- Quiz Manager → UI Components → User (render questions, capture answers)
- Database Manager ↔ PDF Processor & AI Integration (cache raw & processed data, API keys)
- Theme Manager ↔ UI Components (switch light/dark CSS)
c. Architectural patterns & design principles
- Modular JS: each file is a single responsibility module
- Progressive loading: pipeline via Batch Processor → UI
- Local caching: offline/resume capability via database-manager
- Clear separation: View (UI), Controller (main, quiz, file-uploader), Services (PDF, AI)
d. Key technologies
- Vanilla JS modules & ES6 imports
- Google Gemini AI REST API
- Browser localStorage/IndexedDB
- Drag-and-drop File API
- Responsive CSS (mobile-first)

## Diagram (Mermaid)

```mermaid
flowchart TD
    User((User)):::user

    subgraph "User Interface (Browser)"
        UI_HTML["index.html"]:::ui
        CSS["css/"]:::ui
        UI_COMP["ui-components.js"]:::ui
        THEME["theme-manager.js"]:::ui
    end

    subgraph "Application Controller"
        MAIN["main.js"]:::ctrl
        UPLDR["file-uploader.js"]:::ctrl
        QUIZ["quiz-manager.js"]:::ctrl
    end

    subgraph "Service Layer"
        PDFP["pdf-processor.js"]:::svc
        PDFA["pdf-analyzer.js"]:::svc
        BATCH["batch-processor.js"]:::svc
        AI["ai-integration.js"]:::svc
    end

    subgraph "Storage Layer"
        DB["database-manager.js"]:::storage
    end

    subgraph "Bootstrap"
        APPINFO["app-info.js"]:::ctrl
    end

    subgraph "Build & Documentation"
        MAKE["Makefile"]:::misc
        README["README.md"]:::misc
    end

    EXTERNAL["Google Gemini AI API"]:::external

    %% Data Flows
    User -->|click/drag file| UPLDR
    UPLDR -->|"upload PDF file"| PDFP
    PDFP -->|"chunk PDF for AI"| BATCH
    BATCH -->|"send chunks to AI"| AI
    AI -->|"receive responses"| PDFA
    PDFA -->|"parsed questions"| QUIZ
    QUIZ -->|"render quiz"| UI_COMP
    UI_COMP -->|"display questions"| User

    %% Caching Loops
    PDFP <-->|cache raw PDF| DB
    AI <-->|cache processed questions & API keys| DB

    %% Wiring & Theming
    MAIN -->|wires modules| UPLDR
    MAIN -->|wires modules| QUIZ
    MAIN -->|wires modules| UI_COMP
    MAIN -->|wires modules| THEME
    THEME <-->|switch theme| UI_COMP

    %% External API
    AI -->|REST calls| EXTERNAL
    EXTERNAL -->|API responses| AI

    %% Click Events
    click UI_HTML "https://github.com/dagimg-dot/did-exit/blob/main/index.html"
    click CSS "https://github.com/dagimg-dot/did-exit/tree/main/css/"
    click UI_COMP "https://github.com/dagimg-dot/did-exit/blob/main/js/ui-components.js"
    click THEME "https://github.com/dagimg-dot/did-exit/blob/main/js/theme-manager.js"
    click MAIN "https://github.com/dagimg-dot/did-exit/blob/main/js/main.js"
    click UPLDR "https://github.com/dagimg-dot/did-exit/blob/main/js/file-uploader.js"
    click QUIZ "https://github.com/dagimg-dot/did-exit/blob/main/js/quiz-manager.js"
    click PDFP "https://github.com/dagimg-dot/did-exit/blob/main/js/pdf-processor.js"
    click PDFA "https://github.com/dagimg-dot/did-exit/blob/main/js/pdf-analyzer.js"
    click BATCH "https://github.com/dagimg-dot/did-exit/blob/main/js/batch-processor.js"
    click AI "https://github.com/dagimg-dot/did-exit/blob/main/js/ai-integration.js"
    click DB "https://github.com/dagimg-dot/did-exit/blob/main/js/database-manager.js"
    click APPINFO "https://github.com/dagimg-dot/did-exit/blob/main/js/app-info.js"
    click MAKE "https://github.com/dagimg-dot/did-exit/tree/main/Makefile"
    click README "https://github.com/dagimg-dot/did-exit/blob/main/README.md"

    %% Styles
    classDef ui fill:#a8ddb5,stroke:#666,stroke-width:1px
    classDef ctrl fill:#9ecae1,stroke:#666,stroke-width:1px
    classDef svc fill:#9ecae1,stroke:#444,stroke-width:1px
    classDef storage fill:#fee391,stroke:#666,stroke-width:1px
    classDef external fill:#fdae6b,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5
    classDef misc fill:#dddddd,stroke:#666,stroke-width:1px
    classDef user fill:#ffffff,stroke:#000,stroke-width:1px,stroke-dasharray: 2 2
```
