This document describes the software architecture of MK QuizFlow.
idb package (wrapping standard IndexedDB APIs).src/app: Page components and API routes.src/components: UI widgets and components (layout, player, settings).src/lib: Common utility libraries (local generator, pdf parser, srs flashcards, storage engine).graph TD
Source[PDF / Paste] -->|Browser pdf.js| RawText[Text Extraction]
RawText -->|Quick Mode Heuristics| Generator[Local Heuristic Engine]
RawText -->|AI Mode| Api[POST /api/ai/quiz]
Api -->|Vercel AI SDK / Gateway| LLM[Claude / OpenRouter]
Generator -->|JSON Question set| QuizPlayer[Interactive Quiz Player]
LLM -->|JSON Question set| QuizPlayer
QuizPlayer -->|Save result| IndexedDB[(Local IndexedDB)]
src/lib is unit-tested with AAA-structured, behaviour-named tests — generators, text parsing, scoring, dedupe, the SRS scheduler, derived stats, share/export, AI catalog/models/quota/rate-limit, and the consent-gated analytics no-op. IndexedDB storage is tested with fake-indexeddb; DOM-dependent modules use the jsdom environment.pdf.ts, audio.ts, ai/client.ts) are excluded from unit coverage and exercised by the Playwright smoke instead.pnpm typecheck, pnpm lint, pnpm test (+ pnpm test:coverage), pnpm build, and pnpm exec playwright test. See DEPLOYMENT.md.