Under the Hood

How LabLens
actually works.

Not prompt engineering. Not a chatbot wrapper. A structured pipeline that turns every student reply into a cognitive state update.

Architecture
๐Ÿ‘ค
Student Input
Free-text reasoning
โ†’
โ–ฒ
Next.js Route Handler
/api/socratic ยท App Router
โ†’
๐Ÿชถ
Featherless.ai
OpenAI-compatible API
โ†’
๐Ÿง 
Qwen2.5-72B-Instruct
70B parameter LLM
Structured JSON response โ†“
{ "reply": "If R1 uses up current, what happens to the electrons after passing through?", "analysis": { "misconception": "current-consumed", "confidence": 0.92, "progress": 1, "next_move": "challenge_analogy", "teacher_note": "Student holds the current-attrition misconception โ€” redirect with flow analogy." } }
๐Ÿ’ฌ
Chat UI
Renders reply + chips
+
๐Ÿท
Cognitive Chips
Misconception ยท Progress ยท Move
Stack

What powers each layer

Frontend
Next.js 16 App Router
Server components for static pages, client component for the chat thread. No unnecessary JS on first load.
AI Provider
Featherless.ai
OpenAI-compatible inference API. Serverless โ€” no GPU management. Sub-10s cold starts on Qwen2.5-72B.
Model
Qwen2.5-72B-Instruct
72 billion parameter instruction-tuned model. Reliably produces valid JSON output given a strict system prompt.
Prompt Design
Socratic System Prompt
Every session injects: subject config, the target misconception, Socratic rules (never answer directly), and a JSON-only output contract.
Resilience
Hardcoded Fallback
If the API times out or fails, a curated fallback response is returned so the demo never breaks during a presentation.
Deployment
Vercel Edge Network
Static pages pre-rendered at build time. API routes are serverless functions. Zero config, global CDN.
Prompt Engineering

The Socratic contract

The system prompt is the core of LabLens. It does three things:

1
Injects subject context โ€” the exact problem, the target misconception label, and the correct understanding โ€” so the model knows what to guide toward without stating it.
2
Enforces Socratic rules โ€” the model is forbidden from stating the answer. It must ask one question per reply, 2โ€“4 sentences max.
3
Demands structured JSON โ€” the response contract requires a reply field and a full analysis object with misconception tag, confidence, progress (0โ€“5), next move, and teacher note. No prose outside the JSON.