Lernivox
A pnpm/Turborepo TypeScript platform that turns uploaded textbooks and lecture materials (.pdf, .docx, .txt, .md) into interactive study workspaces with a virtualized native reader, source-cited AI tutoring, SM-2 flashcards, adaptive study plans, and collaborative study groups.
Lead Full-Stack Systems Engineer
149 Commits (Production Monorepo Architecture)
Next.js 15 / NestJS 12 / BullMQ / Prisma + pgvector / Gemini
768-dim HNSW pgvector / 400+ Page Virtual Reader / 42 Schema Models

Passive PDF Reading, Ungrounded LLM Answers, and Sleeping Workers
Studying dense academic textbooks in embedded browser frames breaks text selection and memory bounds, while open-ended LLM chat fabricates citations and free-tier background workers stall if they sleep between uploads.
Passing raw document text directly into chat prompts lets untrusted book content steer model behavior or invent page references.
Native <iframe> and <embed> PDF previews prevent consistent cross-browser text selection, citation-jump scrolling, and bounded DOM memory on 400+ page textbooks.
Web-triggered background parsing and embedding jobs stall when low-cost Render worker instances spin down between user uploads.
Contract-First Monorepo Across Web, API, and Queue Workers
Structured as a pnpm and Turborepo workspace separating Next.js 15 client rendering, NestJS 12 API orchestration, and BullMQ ingestion workers over shared contracts, PostgreSQL + pgvector storage, and pluggable AI/storage ports.
App Router interface pairing pdfjs-dist and docx-preview rendering with SM-2 flashcards, auto-graded quizzes, and collaborative groups.
Cookie/JWT HTTP REST API enforcing document access checks, rate limiting, and worker wake orchestration.
Processes UPLOADED documents, extracts deterministic outlines, chunks text (1000 chars / 200 overlap), and generates 768-dim embeddings.
42 Prisma models with HNSW vector indexing alongside AiProvider (GeminiProvider / MockAiProvider) and StorageService abstractions.
Key Challenges & Trade-offs
Wake Handshake for Sleep-Prone Free-Tier Workers
Keeping an always-on worker dyno running is expensive for an early-stage deployment, yet cold Render free-tier workers drop or delay queued ingestion jobs.
Implemented an authenticated /internal/wake and /readyz readiness handshake in WorkerWakeService paired with BullMQ on Upstash Redis TLS, accepting up to ~95s cold-start latency instead of always-on dyno costs.
Strict Grounding Against Citation Hallucinations
Academic study assistants lose trust immediately if an answer cites non-existent sections or follows prompt instructions embedded inside an uploaded PDF.
Isolated untrusted passages inside <<<SOURCE_PASSAGES>>> delimiters (TUTOR_PROMPT_VERSION v1.0.0) and ran regex [S#] verification in citation-validator.ts to discard unretrieved IDs and attach verbatim page/chapter snippets.
Browser-Native Virtualized Reader for 400+ Page Textbooks
Rendering multi-hundred-page textbooks via browser PDF embeds breaks citation-jump scrolling and behaves inconsistently across desktop and mobile viewports.
Built a native virtualized viewport combining pdfjs-dist, docx-preview, and @tanstack/react-virtual, preserving clean text selection and bounded memory across 400+ page documents.
Deployed Multi-Service Monorepo with Grounded RAG Verification
Shipped across Vercel (frontend) and Render (API and background worker) with clean separation between domain contracts, deterministic outline extraction, mockable AI providers, and pgvector retrieval.