cd /news/artificial-intelligence/how-i-over-engineered-an-ai-tutor-on… · home › topics › artificial-intelligence › article
[ARTICLE · art-177775] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

How I Over-Engineered an AI Tutor on WhatsApp — And Why 4 Tenth Graders Humbled Me

A solo engineer built Masterji, a WhatsApp-based AI tutor for Indian Class 10 board exam students that uses a multi-agent supervisor router, Socratic state machines, and a curriculum RAG grounded in official marking schemes. The engineer solved a split-brain hallucination bug caused by Meta firing concurrent webhooks for rapid-fire student messages by implementing an in-process per-phone serialization mutex that chains each student's messages into an asynchronous FIFO queue. Testing with four tenth graders revealed the bot's tone was too condescending for 15-year-olds.

recommendation

When a messaging platform fires concurrent webhooks per user, chain each user's requests through a per-phone FIFO mutex so later messages wait for prior DB writes and dispatches before processing.

more in playbook: Designing agent systems
by read6 min views13 publishedNov 28, 2026

Confessions of a solo engineer building Masterji for Indian Class 10 Boards: How I built multi-agent supervisors, Socratic state machines, and concurrency mutexes, only to realize my bot was talking to 15-year-olds like they were five.

India's Class 10 Board Exams (CBSE, ICSE, and State Boards like Karnataka SSLC) are an emotional pressure cooker. For over 20 million students every year, this is their first national standardized exam. It dictates streaming (Science, Commerce, Arts), family prestige, and immense personal anxiety.

Yet, the after-school support system for most students is deeply flawed:

The Masterji Thesis was simple:

Build a 24/7 personal tutor on WhatsApp — where students and parents already live — that refuses to spoon-feed answers. Instead, it guides the student step-by-step using the Socratic method, grounds every hint in official board marking schemes, and sends parents a daily digest of what their child actually practiced.

No app installs. No logins. Just send a photo of your notebook or text a doubt on WhatsApp, and Masterji helps you solve it yourself.

As a software engineer, when I looked at this problem, I didn't see pedagogy first; I saw distributed systems problems.

I asked myself:

So, I built an enterprise-grade backend.

flowchart TD
    User["Student on WhatsApp"] --> Ingress["Meta Cloud API Webhook"]
    Ingress --> Mutex["Per-Phone Webhook Mutex (queue.ts)"]
    Mutex --> Dedup["CSO-02 Idempotency & Replay Guard"]
    Dedup --> Router["Supervisor Router (supervisor/router.ts)"]

    subgraph State["Persistence & Grounding Layer"]
        L1["L1 In-Memory RAM Cache"]
        L2["L2 Supabase PostgreSQL (socratic_threads)"]
        RAG["Curriculum RAG & PYQ Bank (2022-2026)"]
    end

    Router <--> State

    Router --> ModeDecision{"Intent & Pedagogical Mode"}
    ModeDecision -->|Quadratic / Geometry / AP| MathsSir["Maths Sir Specialist"]
    ModeDecision -->|Circuits / Optics / Reactions| ScienceTeacher["Science Teacher Specialist"]
    ModeDecision -->|Motivation / Banter| GeneralMentor["General Mentor Specialist"]

    MathsSir --> Guardrails["Post-Flight Anti-Cheat Sanitizer"]
    ScienceTeacher --> Guardrails
    GeneralMentor --> Guardrails

    Guardrails --> Outbound["Meta WhatsApp Outbound Dispatcher"]
    Outbound --> User

router.ts): LEARN``PRACTICE`` EVALUATE On paper and in the terminal, the system was a marvel. Over several weeks of intense development, we conquered tricky real-world engineering bugs:

Teenagers do not send one neat, well-formed paragraph. They send five rapid fragments in two seconds:

"sir"
"in question 4"
"why is current same?"
"in series"
"tell me"

Initially, Meta fired five concurrent webhook POST requests to our Fastify server. Because LLM inference takes 800ms–2s, request #2 would read state from Supabase before request #1 finished persisting it. The system suffered split-brain hallucinations: the bot would answer question #3, evaluate question #2 as a math answer, and wipe out the conversation thread.

We had to design an in-process per-phone serialization mutex:

// src/modules/whatsapp/queue.ts
const phoneQueues = new Map<string, Promise<void>>();

export async function enqueuePhoneTask<T>(phone: string, task: () => Promise<T>): Promise<T> {
  const norm = phone.trim();
  const prev = phoneQueues.get(norm) ?? Promise.resolve();

  let taskResult!: T;
  const next = (async () => {
    await prev.catch(() => {});
    taskResult = await task();
  })();

  const chained = next.then(() => {}, () => {});
  phoneQueues.set(norm, chained);

  try {
    await next;
    return taskResult;
  } finally {
    if (phoneQueues.get(norm) === chained) {
      phoneQueues.delete(norm);
    }
  }
}

Every incoming webhook for that student joins an asynchronous FIFO chain. Message 2 waits cleanly for Message 1 to complete its DB write and dispatch before processing.

In an early build, if Masterji asked:

"What is the formula relating Voltage, Current, and Resistance?"

And the student replied:

"Wait, why does resistance increase when length increases?"

The router classified the student's message as an answer attempt (ANSWERING), compared it against Ohm's Law formula ( V = IR), marked it wrong, and consumed Strike 1!

Real students don't just answer questions; they ask questions back in the middle of answering. We had to refactor the active-thread supervisor to recognize CLARIFYING_DOUBT:

stateDiagram-v2
    [*] --> SocraticThreadActive
    SocraticThreadActive --> EvaluatingAnswer: Student attempts answer ("V = IR")
    SocraticThreadActive --> ClarifyingDoubt: Student asks counter-doubt ("Why does wire length matter?")

    ClarifyingDoubt --> ExplainMechanism: Masterji answers physics intuition
    ExplainMechanism --> ReBridgeQuestion: "Now coming back: what formula connects V, I, and R?"
    ReBridgeQuestion --> SocraticThreadActive

When implementing an interactive WhatsApp Chapter Picker so students could switch topics on the fly, Meta's Cloud API silently rejected payloads with HTTP 400 Bad Request.

Why? Meta strictly caps interactive list messages at 10 items across all sections. Class 10 Science has 13 chapters; Maths has 14 chapters. We had to build a prioritized slicing algorithm: show the top 10 most critical/board-frequent chapters in the interactive UI, while gracefully supporting fuzzy text search ("or type any chapter name like Circles, Heredity, or Light") for the rest.

By all technical metrics, the system was robust.

And then today, I put the bot into the hands of 4 real pilot students and their parents.

Within five minutes of watching them interact, I felt a knot in my stomach.

I had fallen into the classic solo engineer trap: I engineered an enterprise backend, but I had completely lost touch with the actual human using it.

The most brutal feedback from our pilot students was unanimous:

"Bhaiya, why is it talking to me like I’m in 3rd standard?"

Because I had prompted the LLM with generic "friendly, encouraging tutor" instructions, the model was responding with patronizing fluff:

"Awesome effort, champ! 🌟 Let's go on a fun little journey to explore how magical electricity flows through wires! Are you ready, my friend?"

A 15-year-old Indian student in Class 10 is stressed about their pre-board marks. They are studying late into the night. They do not want to be called "champ", they do not want emojis on every line, and they do not want to be babied. They want to be treated like an intelligent young adult preparing for a serious exam.

They wanted concise, respectful, exam-sharp guidance:

I had spent hours perfecting formal English prompts and edge cases, but real 10th graders communicate in rapid, terse adolescent shorthand:

When the bot replied with three long paragraphs explaining textbook theory, the students skimmed past it or stopped reading altogether. WhatsApp is a high-velocity chat medium, not an NCERT PDF viewer. Responses need to be punchy, bite-sized, and conversational.

During development, it's dangerously easy to rely on automated eval suites. You write 50 synthetic test prompts in a test runner, mock the responses, assert regexes on anti-cheat guardrails, and celebrate when tests pass green.

Synthetic evals are a comforting illusion. They test whether your software meets your own preconceived expectations. They do not test whether a tired student at 11 PM finds the explanation intuitive, or whether a parent reading the daily WhatsApp report feels confident in their child's progress.

Real users break your assumptions in ways synthetic benchmarks never predict.

Building in public means owning your missteps. I over-indexed on backend plumbing and under-indexed on pedagogical tone and user psychology.

Here is what we are fixing right now as we head toward our target launch in mid-December 2026:

We currently have 4 active pilot users helping us stress-test Masterji and understand the real mindset of a Class 10 student.

We are actively looking for more pilot duos (Student + Parent) preparing for:

If you are a 10th-standard student feeling overwhelmed by coaching classes, or a parent who wants visibility into your child’s daily practice without nagging them, we would love to have you test Masterji.

Your real-world feedback will directly shape how this product behaves before our mid-December release.

You can write the cleanest async mutexes, design the most elegant multi-agent supervisor, and pass every unit test in your terminal. But until you put your creation in front of the 15-year-old whose problem you claim to solve, you haven't built anything yet.

Don't hide behind your architecture. Get humbled early.

Building in public. Comments, feedback, and architectural critiques are warmly welcome below.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @masterji 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-i-over-engineere…] indexed:0 read:6min 2026-11-28 · —