DEV Community

Academic
Academic

Posted on

Samjhao — I built my friend a Hinglish study buddy on open-weight Gemma

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

Around midnight, my phone buzzes. It's Suyash — a screenshot of a textbook page and three words: "yeh kya bol raha hai?" ("what is this even saying?").

Suyash is my closest friend, and he's preparing for JEE here in Prayagraj. Everything he studies from — NCERT, coaching modules, previous-year solutions — is in English. He thinks in Hindi. The problem isn't vocabulary; he can read every word. The problem is register: a textbook explains like a textbook, and Suyash understands when a friend explains. For months, that friend has been me, at midnight, re-typing paragraphs in Hinglish with a chai analogy thrown in.

So I built Samjhao (समझाओ — "explain it to me"): a small web app that does what I do at midnight, without me.

  • Paste a paragraph, a PDF page, or just a topic name — "Le Chatelier's principle" is enough.
  • Pick a depth — Bilkul basic, Exam ke liye, or Deep dive — and a language — Hinglish, Hindi, or English.
  • It explains the way Suyash actually talks, pulls out the key terms (English → Hindi), gives three memory hooks, and ends with one realistic exam question with a model answer. Formulas render properly, because JEE Physics without ½mv² is just vibes.
  • Quiz banao turns the same material into five MCQs and scores them, with a why under each — because JEE is MCQs, and the wrong answer you don't understand is the one you'll repeat.
  • Everything goes into a Doubt Diary. Wrong answers become weak points; one tap builds a revision test that targets exactly those.

I showed it to Suyash as soon as it ran, with his name in the title bar — Suyash ka padhai saathi. He was shocked. Not polite-shocked; actually shocked that the paragraphs he'd been sending me had turned into a real app built around how he learns.

Demo

🔗 Live app: https://samjhao.onrender.com — a free Render instance, so give it ~40 seconds to wake up. Paste any paragraph from NCERT and press Samjhao 🙏. Gemma 4 thinks before it answers, so the first explanation takes 30–60 seconds; the app shows a "🤔 Gemma soch raha hai… 23s" timer while you wait.

Here's the work-energy theorem, pasted straight from a Physics textbook, explained Exam ke liye in Hinglish — definition, exam-ready points, key terms, a UPI-transaction memory hook, and one exam question:

The work-energy theorem paragraph pasted into Samjhao and explained in Hinglish: definition with the rendered formula W_net = ΔK = ½mv² − ½mu², exam-ready points, key terms, memory hooks and an exam question

One tap on Quiz banao turns that same paragraph into five MCQs. I deliberately got two wrong — every answer gets a ✅/❌ and a one-line why:

Five-question Hinglish quiz on the work-energy theorem, scored 3/5, with the correct answer and a one-line explanation under each question

And the Doubt Diary remembers it: the two wrong answers are now weak points, one button builds a revision test from them, and the whole thing downloads as Markdown or JSON (nothing is stored on a server):

The Doubt Diary tab: a table of explanations and quizzes with scores, a Revision test button, and Download/Backup buttons

Code

GitHub logo Yuser00123 / samjhao

Samjhao (समझाओ) — a Hinglish study buddy built for my friend Suyash's JEE prep, powered by open-weight Gemma. Paste a paragraph → friend-style explanation, quiz, Doubt Diary. Hacktoberfest 2026 Weekend Challenge: Build for a Friend.

📚 Samjhao (समझाओ) — a Hinglish study buddy, built for one friend

Paste a paragraph from the textbook (or a PDF page, or just a topic name) → get it explained the way a smart friend would, in Hinglish, with key terms, memory hooks and an exam question → take a 5-question quiz → everything you struggled with lands in a Doubt Diary that turns into a weekly revision test.

Built for Hacktoberfest 2026 · DEV Weekend Challenge: Build for a Friend, with an open-weight model (Gemma) at its core.

Why open-weight matters here

Need of a student in a UP hostel What open weights make possible
No money Gemma 4 is free on Google AI Studio (no card). Zero running cost.
Hostel wifi dies Same app, LLM_BASE_URL=http://localhost:11434/v1 → Gemma 3 4B via Ollama, fully offline on a CPU laptop.
Their notes are theirs Nothing is stored server-side.
…

MIT licensed. The repo was created and finished inside the challenge window. The README has a five-command quickstart, the three screenshots above, and an offline mode.

How I Built It

The open-source AI at the core is Gemma 4 (gemma-4-31b-it), Google's Apache-2.0 open-weight model, served through Google AI Studio's free tier. It does everything: the explanation, the quiz (as strict JSON), and the revision test. There is no closed model anywhere in the code — not even as a fallback.

Around it: Python, Gradio 6 mounted on FastAPI (UI plus a /health endpoint that Render pings; it ships as a PWA so it installs on a phone), the openai SDK pointed at an OpenAI-compatible endpoint, pypdf, and Render's free tier (Singapore region) for hosting.

The piece I'm proudest of is llm.py — a few hundred lines that know nothing about Google. It talks to any OpenAI-compatible endpoint, so the same Gemma family runs three ways with two environment variables:

# Google AI Studio — free, cloud
LLM_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
LLM_MODEL=gemma-4-31b-it

# Ollama — same app, no internet, CPU laptop
LLM_BASE_URL=http://localhost:11434/v1
LLM_MODEL=gemma3:4b
Enter fullscreen mode Exit fullscreen mode

It also absorbs the real-world mess: if a provider rejects the system role, the prompt is folded into the first user turn and retried; if it lacks response_format, a lenient JSON parser takes over; a 429 gets a polite retry and a Hinglish "Gemma thoda busy hai" instead of a stack trace.

The bug that taught me the most: Gemma 4 thinks out loud. The first time the deployed app answered, the explanation began with <thought>Ohm's Law. Suyash wants…</thought>. Gemma 4 is a reasoning model, and Google's OpenAI-compatible endpoint streams its chain of thought inline, as ordinary text. So llm.py grew a streaming-safe filter that removes <thought>…</thought> blocks even when a tag is split across two chunks, and the UI shows the soch raha hai timer until the first visible line arrives. The same afternoon the endpoint threw a few 500 Internal errors, and once the model spent its entire token budget thinking and returned nothing — both now retry automatically, and if all three attempts fail Suyash gets a Hinglish sentence, not a traceback. None of this is Gemma's fault; it's the price of using a reasoning model through a compatibility layer, and the fix is about eighty lines anyone can lift.

The persona is a prompt, not a fine-tune. Forty lines in prompts.py encode how Suyash likes things explained: Roman-script Hinglish "the way two friends chat on WhatsApp", technical terms kept in English with the Hindi meaning in brackets the first time, analogies from chai/cricket/trains/UPI only when they genuinely help, exam-precise definitions — and "if the material is garbled or isn't study material, say so; don't invent." The three depth levels change the word budget and structure, never the voice. (The UPI analogy in the screenshot? Gemma's own idea. The prompt just allowed it.)

The quiz is structured output. Gemma returns {"topic", "questions": [{"q", "options"[4], "answer_index", "why"}]}; the app validates every question (exactly four options, one valid index) and drops anything malformed rather than show a broken quiz. Wrong answers are stored as weak points, and the revision prompt is told to rephrase them, not repeat them.

The Doubt Diary is deliberately boring: a list in the browser session with JSON export/import. No accounts, no database, nothing stored on a server. For a tool used by one person, that's a feature.

Why Does Open Innovation Matter?

I could have built this on a closed API in the same weekend. Here's what would have been worse, concretely:

  1. It would cost money, and a JEE aspirant has none to spare. Gemma 4 on AI Studio's free tier needs no card. Suyash can run this every night until the exam for ₹0. The moment a study tool has a monthly bill, it stops being used.

  2. Internet is not a given at midnight. Data packs run out; wifi drops. Because the weights are open, the same code can point at Ollama with gemma3:4b on a laptop — no internet, no account, no key. It's the same OpenAI-compatible protocol, so it's two environment variables, documented in the README. A closed API cannot do this, by definition.

  3. Suyash's doubts are his business. The only thing that leaves the device is the pasted text, and it goes to a provider we choose — including our own machine. No vendor is building a profile of what a JEE aspirant struggles with the night before a test.

  4. The model can't be taken away. Closed models get deprecated, re-priced, or geo-restricted. Apache-2.0 weights don't. If the free tier changes tomorrow, I change one URL. If Suyash ever wants Samjhao to know his exact syllabus, the weights can be fine-tuned — that path exists because the model is open.

  5. Hinglish is a first-class citizen. I was genuinely surprised how well Gemma handles Roman-script Hindi + English code-switching with precise technical terms — look at "gatij urja" next to kinetic energy in the screenshot. With open weights, that's an advantage I get to keep.

The honest counterpoint: free-tier rate limits are real (~15 requests a minute), and a 31B reasoning model served remotely takes 30–60 seconds per explanation. For one student at midnight, neither matters — and when it does, the open weights mean the fix is a smaller Gemma on his own laptop, not a bigger bill.

Prize Categories

  • Best Use of Gemma — Gemma 4 (gemma-4-31b-it) is the only model in the project: explanation, quiz JSON, and revision test; swappable to Gemma 3 via Ollama for offline use.
  • Best Use of Render — deployed as a free Render web service from render.yaml (Blueprint), Singapore region, with /health as the health-check path; the app reads PORT and ships as a PWA.

Built solo.

Top comments (0)