Socrates Pocket

The AI tutor that refuses to give you the answer — and makes you actually learn.

Socrates Pocket architecture

Socrates Pocket is a multimodal, anti-answer AI tutor we built for the Nira hackathon. A student snaps a photo of any textbook page (NCERT, CBSE, college, or anything else), and instead of being handed an explanation, they are met with a calibrated probing question. The tutor — powered by Google Gemini 2.5 — listens to how the student reasons, identifies the exact sub-concept that's fuzzy, and Socratically guides them until they can teach the idea back themselves. Every exchange updates a live Concept Mastery Map that turns from red ("faking it") to amber to green ("owned"), giving students and teachers an honest mirror of real understanding.

Why we built this

Every other AI tool in education makes students faster at copying. Peer-reviewed 2025 evidence — the Kestin RCT (Nature Sci. Reports), Baillifard's semester-long study, the JRC Policy Lab on Dialogic AI — is unambiguous: students who reconstruct ideas themselves outperform students handed clean answers, in retention and engagement. Yet ChatGPT, Khanmigo, Socra, and Study Mode all default to giving the answer. We wanted to build the only AI tutor designed around the actual mechanism of learning: productive struggle.

What it does (60-second tour)

  1. Snap-to-Tutor — The student opens the app on their phone, points the camera at, say, a Class 11 NCERT Physics page on Newton's Second Law, and taps once. Gemini reads diagrams, equations, and Hindi text natively in one multimodal call.
  2. Anti-Answer Engine — The tutor opens with: "Before I say anything — if I push a shopping cart and a truck with the same force, what happens, and why?" The student fumbles. The AI zeroes in: "You used 'force' correctly — but you said 'weight'. In this push, weight acts downward, not along your push. Is the resistance really weight, or something more fundamental?"
  3. Live Concept Mastery Map — Every exchange emits a structured signal that updates a per-concept heatmap on the right rail. Force glows green. Mass ↔ Acceleration lights up red. The student watches their own understanding form in real time.
  4. "Just Tell Me" — at a cost — There is a button to demand the answer. Pressing it visibly drops the mastery score on that concept, with a satisfying animation. The struggle is the feature.
  5. Spaced-Repetition Micro-Reviews — Weak nodes auto-enqueue into a 60-second daily deck pushed at scientifically-optimal intervals.
  6. Teacher Tutor Links — A teacher seeds a lesson plan and pedagogical style once and shares one link; every student in class gets their own personalised tutor mirroring that teacher's voice. The teacher dashboard surfaces a class-wide weakness heatmap.
  7. Voice mode — Web Speech API for spoken probing questions and voice answers — accessibility win for low-literacy and visually-impaired students.

Quick demo (no setup)

The app ships with a fully seeded session, mastery map, spaced-repetition deck, and a populated teacher dashboard, so you can explore every feature without an API key. With no key, the tutoring engine runs in offline mock mode (a rule-based Socratic engine we wrote specifically for the demo storyline).

docker build -t socrates-pocket .
docker run -p 3000:3000 socrates-pocket
# open http://localhost:3000

To enable the live Gemini-powered tutor, open Settings in the app and paste a free Gemini key from https://aistudio.google.com/app/apikey. Keys are stored only in your browser's localStorage — never on our server.

Local development

npm install
npm run dev
# open http://localhost:3000

Optionally set a server-side default key (overridden by user-supplied keys from the Settings panel):

echo "GEMINI_API_KEY=AIza..." > .env.local

Tech stack

  • Next.js 14 (App Router) + TypeScript for the whole frontend and serverless API routes
  • Tailwind CSS with a custom parchment/socratic palette and a small in-house component layer (btn, panel, chip, …) for a cohesive, judge-friendly UI without adding component-library bloat
  • Google Gemini 2.5 Flash (multimodal) via @google/generative-ai for OCR + concept extraction and the Socratic engine in a single API
  • lucide-react for icons, Web Speech API for voice mode
  • localStorage persistence — no database, no auth, judges open the link and it works
  • Docker multi-stage build producing a 100 MB-class standalone Next.js image

Architecture

The codebase is intentionally small and explicit:

app/
  layout.tsx            Root layout, AI-judge notice, header/footer
  page.tsx              Landing page with hero, features, teacher CTA
  tutor/                Main Socratic tutoring workspace
  mastery/              Cross-session concept mastery dashboard
  review/               Spaced-repetition deck
  teacher/              Teacher dashboard + create-link page
  settings/             API key panel
  api/
    extract/route.ts    Multimodal OCR + concept extraction (Gemini)
    tutor/route.ts      Per-turn Socratic tutoring engine (Gemini)
components/             ConceptMasteryMap, ChatBubble, JustTellMeButton, …
lib/
  gemini.ts             SDK call + battle-tested mock fallback
  socraticPrompt.ts     The Socratic system prompt (the actual product)
  store.ts              localStorage hooks + signal → state reducer
  seed.ts               Demo data so the app looks alive on first run

The Socratic engine is the heart of the product. The system prompt forces the model to emit two structured envelopes per turn — a <reply> (the natural-language probing question) and a <signal> (a strict JSON object describing which sub-concept was probed, what mastery deltas to apply, and any new concepts to register). This separation is what makes the live mastery map possible without a second API call.

When no Gemini key is configured, lib/gemini.ts falls back to a hand-written rule-based Socratic engine that demonstrates the same behavior on Newton's Second Law — so the demo never breaks because of a rate limit.

Pedagogical credits

We built our Socratic prompt and mastery model on top of:

  • Kestin et al., AI tutoring outperforms in-class active learning: an RCT, Nature Scientific Reports, 2025
  • Baillifard et al., Effective learning with a personal AI tutor, Education and Information Technologies, 2025
  • JRC Policy Lab 2025 on Dialogic AI in education
  • Maity et al., Generative AI and Its Impact on Personalized Intelligent Tutoring Systems, arXiv:2410.10650

Team

Built by Aryan Choudhary (aryancta@gmail.com) for the Nira hackathon.

License

MIT — go forth and refuse to give answers.

Built With

  • docker
  • google-gemini-2.5-flash
  • google-generative-ai-sdk
  • lucide-react
  • next.js-14
  • react-18
  • tailwindcss
  • typescript
  • web-speech-api
Share this project:

Updates