An enterprise-grade, AI-powered learning platform built with React 18, TypeScript, Node.js, and Google Gemini. Features adaptive quiz engines with real-time difficulty scaling, spaced repetition flashcards, automated PDF/DOCX summarization, interactive Monaco code execution, dual-model AI failover resilience, and ClamAV malware inspection.

Modern self-directed learners face fragmented study workflows. They constantly switch between disconnected tools for reading documents, creating flashcards, testing comprehension, and reviewing code snippets.
Key challenges students face include:
- Inefficient Revision: Static flashcards and generic question banks lack memory decay adaptation, causing poor knowledge retention.
- LLM Fragility in Production: Standard generative AI study assistants suffer from API rate limits, 503 service overloads, and unpredictable output schemas during bulk quiz generation.
- Security & File Safety Concerns: Uploading external academic documents (PDFs, Word docs) into cloud environments exposes platforms to malicious scripts and unvalidated payloads.
- Lack of Actionable Progress Tracking: Traditional learning dashboards offer vanity metrics rather than pinpointing exact conceptual weaknesses and topic-level mastery.
Architected and built StudyForge, an end-to-end learning operating system that consolidates intelligent study tools into a unified, high-performance web application:
- Resilient AI Pipeline: Implemented Google Gemini 3.1 Flash Lite with an automated hot-standby failover to Gemini 2.5 Flash on 503 errors or traffic spikes. Coupled with a Redis/in-memory caching layer using SHA-256 prompt hashing to minimize token latency and API overhead.
- Fault-Tolerant JSON Parsing: Engineered custom batch prompt builders, schema validators, and JSON repair parsers to sanitize and validate AI-generated quiz questions against strict Zod definitions before database insertion.
- Adaptive Testing & Spaced Repetition: Designed an adaptive quiz engine that adjusts question difficulty dynamically based on real-time student performance, accompanied by an SM-2 inspired spaced repetition system (SRS) for flashcard decks.
- Enterprise-Grade Hardening: Integrated ClamAV daemon scanning for all uploaded PDFs/DOCX files, dual-token JWT authentication with IP/User-Agent fingerprinting, bcrypt hashing, and Helmet-based Content Security Policies.
- Developer-Ready Learning: Embedded a Monaco Editor workspace backed by JDoodle API for sandboxed multi-language code compilation and instant execution.
1. Handling LLM Schema Hallucinations & Truncated Responses:
* Challenge: High-volume multiple-choice question generation frequently produced truncated strings, missing brackets, or unexpected Markdown code blocks that broke standard JSON.parse().
* Solution: Created a multi-tier parsing pipeline batch-json-parser.ts) that strips Markdown code fencing, attempts regex-assisted bracket balancing, and falls back to deterministic regex pattern matching before running Drizzle-Zod validations.
2. Preventing High-Concurrency Service Failures:
* Challenge: Gemini API rate limits and upstream 503 errors during peak usage caused student quiz and chat sessions to drop abruptly.
* Solution: Built an automated failover client gemini.ts) that catches transient network and rate errors, immediately delegates the payload to a backup model gemini-2.5-flash), and logs usage metrics to an ai_usage_logs audit table.
3. Secure Multi-Format Document Ingestion:
* Challenge: Parsing multi-megabyte PDFs and DOCX files for automated summarization opened potential vulnerabilities to zip bombs and malicious embedded scripts.
* Solution: Implemented strict multer buffer validation, enforced file size caps, and piped files through a ClamScan virus inspection stream before passing extracted text to pdf-parse and mammoth.
- Designing for LLM Unpredictability: Treating AI responses as untrusted user input is vital. Structuring defensive schemas, fallback parsers, and caching layers ensures platform stability even when upstream providers degrade.
- Relational Integrity at Scale: Managing 30+ relational tables using Drizzle ORM and PostgreSQL demonstrated the value of strict foreign key cascades, unique indexes, and audit logging for security-sensitive user data.
- Full-Stack State Synchronization: Leveraging TanStack Query alongside lightweight client routing wouter) significantly reduced client-side bundle size while providing instant optimistic updates and smooth cache invalidations.
- Production DevOps Readiness: Building Dockerized multi-stage containers with Nginx reverse proxying, gzip compression, and rate limiting prepared the app for seamless containerized production deployments.