Overview
Knorvex is an agentic exam-preparation product. Students upload course materials (PDFs, slides, readings) and practice through chat, quizzes, flashcards, and structured study artifacts.
The product thesis is simple: Stop rereading. Start getting tested. Practice should feel like how a professor actually examines (tone, traps, formats, marking strictness), not another passive summary.
Primary audiences
- Students who need exam-realistic practice from their own notes
- Study groups sharing quizzes, decks, and agents
- Platform admins operating billing, moderation, and support
The problem
Most students still prepare by re-reading slides. That feels productive and rarely transfers to exam performance. Generic AI quiz tools make it worse: they invent questions from the model’s prior knowledge, ignore the syllabus, and collapse when the course is niche or institution-specific.
What students actually need:
- Material-first practice: questions grounded in uploaded PDFs, DOCX, and slides
- Examiner realism: difficulty, marking style, favorite topics, and common traps
- A conversational surface: request a mock, flashcards, or a study guide in plain language
- Integrity: no leaking answer keys mid-attempt; grading boundaries that respect exams
Goals & constraints
| Goal | Constraint | |------|------------| | Material-focused generation | Untrusted uploads must be fenced against prompt injection | | Chat-first UX | Long generations must queue without blocking the thread | | Exam integrity | Play payloads omit keys until submit | | Self-hostable locally | Deterministic fallbacks when no LLM key is configured | | Multi-provider media | Switch local / S3-R2 via config, not rewrites |
Process: ideation → platform
- 1
Problem framing
Passive re-reading fails students. Generic AI drills ignore the syllabus. The product had to be material-focused and examiner-realistic from day one.
- 2
MVP foundation
Core tables for users, courses, materials, quizzes, flashcards, professor agents, billing plans, community, and blog shipped in the first migration as a core schema.
- 3
Agentic pivot
Chat became the primary surface. Async generation jobs, BYOK keys, pgvector search, and generation profiles turned the MVP into an active study loop.
- 4
Platform maturity
Agent MCP connections, admin ops, media uploads, a credit ledger, and study artifacts moved Knorvex from a study tool to a subscription platform.
Architecture
Browser → Next.js (client/)
→ FastAPI (api/)
→ Postgres + pgvector
→ Redis + Arq workers
→ OpenRouter / OpenAI
→ Stripe
→ Media (local | Cloudinary | S3/R2)
The Next.js app proxies authenticated requests through an App Router catch-all that converts httpOnly session cookies into Bearer tokens, forwards client IP / User-Agent for login alerts, and enforces CSRF on cross-site mutations.
Backend layering
Thin routers → services → SQLAlchemy models. Prompt templates live as Jinja files. Background work runs in Arq workers with a queue-first policy for quiz, flashcard, and study-artifact generation when Redis is available.
Frontend surfaces
Public marketing and legal pages; a private workspace for chat, quizzes, flashcards, agents, materials, community, billing, CV, and admin analytics.
Core features
Conversational chat + artifact routing
Streaming SSE via the AI SDK protocol. An intent classifier routes messages to quiz, flashcards, summary, study guide, notes, mind map, practice exam, or plain chat. Artifacts persist as structured JSON and render as cards in the thread.
Study search & Ask RAG
A dedicated search API with a private UI. Users run scoped searches over their materials with streaming responses and direct citations.
Generation profiles & automation
Users manage generation profiles and task-type model defaults. Async Arq fan-out handles heavy uploads and links generated artifacts directly to profiles.
Professor agents
Natural-language examiner profiles with structured fields: difficulty, marking strictness, question style, favorite topics, traps, feedback tone, and rubric preferences. Processed materials generate insights injected into prompts. Student question ratings dynamically tune agent preferences. Agents can also connect external MCP servers with OAuth and a bounded tool loop.
Course Material RAG
Upload → parse (Anydoc + fallbacks) → chunk (~1400 chars, 150 overlap) → embed (text-embedding-3-small, 1536-dim pgvector). A context builder assembles token-budgeted retrieval with keyword scoring and short-lived caching.
Multi-provider media
A MediaStorageProvider abstraction over local disk and S3-compatible storage. Chat supports paste-to-upload with a 25 MB limit; office docs parse to markdown chunks for AI context.
Billing & credits
Stripe subscriptions (Free / Pro / Enterprise) plus a FIFO credit ledger with expiry. Rate limits protect generation endpoints (e.g. quiz and chat generation per hour).
Platform extras
Community groups and voting, blog, CV tailoring, admin support tickets, moderation appeals, and audit logs. Built-in guardrails block raw material sharing and flag sensitive resources for review in a dedicated moderation queue.
Engineering challenges
# Generation funnel (simplified)
clamp → rate_limit → retrieve_chunks
→ build_quiz_corpus → queue | inline
→ persist_generated_quiz
Data model evolution
Twenty-five Alembic migrations tell the product story:
- 1
Foundation (Jun 9)
Users, courses, materials, quizzes, flashcards, professor agents, plans, subscriptions, blog, and community in one core schema.
- 2
Agentic layer (Jun 11-13)
Chat threads/messages, generation jobs, BYOK API keys, institutions, and pgvector embeddings on material chunks.
- 3
Social depth (Jun 12)
Roles, nested replies, voting, profiles, notifications, and study-session tracking.
- 4
Specialized features (Jun-Jul)
CV documents and tailorings, OTP hardening, study-loop provenance, blog comment threads.
- 5
Platform maturity (Jul-Aug)
Agent MCP connections, admin support/moderation/audit, media attachments, credit ledger, seeded plans, and study artifacts.
Deployment
Production is self-hosted on a VPS managed through the Dokploy interface, running three services:
| Service | Role | |---------|------| | API | FastAPI + Uvicorn; Alembic on startup via entrypoint | | Worker | Arq consumer for parse/chunk/embed and generation jobs | | Client | Next.js App Router |
Dokploy handles container orchestration, environment variables, domain routing, and SSL certificates from a single dashboard. Locally: Docker Compose for Postgres (pgvector), Redis, Adminer, and a hot-reloading worker. Production storage prefers S3-compatible (R2); email via Resend or SMTP.
Deploy order that mattered in practice: Postgres → Redis → API → Worker → Client → update API_CORS_ORIGINS.
Outcomes & reflections
What worked
- Chat as the primary generation surface made the product feel agentic without burying settings
- A single quiz orchestration path ended subtle correctness bugs
- Spec-driven media storage kept infra flexible as costs changed
- Documenting VPS/Dokploy pitfalls turned deploy pain into a repeatable runbook
What I’d change
- Introduce the unified generation funnel earlier: divergence cost more than the refactor
- Invest sooner in visual regression for the chat artifact cards
- Tighten observability (job latency, LLM error classes) before scaling traffic
Open questions
- How far to push MCP tools in professor agents without confusing study sessions
- Credit pricing vs flat Pro entitlements as usage patterns emerge
Gallery
Metrics
25
Alembic migrations
40+
Data models
28
API route modules
3
Dokploy services
