<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: V K Adhithiya Kumar</title>
    <description>The latest articles on Forem by V K Adhithiya Kumar (@devadhithiya).</description>
    <link>https://forem.com/devadhithiya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3838791%2F93aaadc3-b3c7-483e-a0cf-098848dbbef9.png</url>
      <title>Forem: V K Adhithiya Kumar</title>
      <link>https://forem.com/devadhithiya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/devadhithiya"/>
    <language>en</language>
    <item>
      <title>Beyond the Chatbot: Engineering a Hybrid AI Math Tutor for the Future</title>
      <dc:creator>V K Adhithiya Kumar</dc:creator>
      <pubDate>Sun, 22 Mar 2026 18:52:13 +0000</pubDate>
      <link>https://forem.com/devadhithiya/beyond-the-chatbot-engineering-a-hybrid-ai-math-tutor-for-the-future-86g</link>
      <guid>https://forem.com/devadhithiya/beyond-the-chatbot-engineering-a-hybrid-ai-math-tutor-for-the-future-86g</guid>
      <description>&lt;p&gt;Building AI tools for education is tricky. Schools and students need the intelligence of cutting-edge LLMs, but they also need strict privacy, offline capabilities, and guardrails against prompt injection and toxic outputs. &lt;/p&gt;

&lt;p&gt;For this hackathon, I built &lt;strong&gt;Neural Math Lab&lt;/strong&gt;: a React/Vite-based math orchestrator that seamlessly switches between &lt;strong&gt;Azure OpenAI (with RAG)&lt;/strong&gt; and &lt;strong&gt;Local Ollama (DeepSeek-R1 and minicpm v)&lt;/strong&gt;, all sitting behind a custom security proxy. &lt;/p&gt;

&lt;p&gt;Here is how I built a system designed for the &lt;strong&gt;Offline-Ready AI&lt;/strong&gt; and &lt;strong&gt;Agentic System Architecture&lt;/strong&gt; tracks.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;[&lt;a href="https://github.com/dev-Adhithiya/Neural-Math-Lab" rel="noopener noreferrer"&gt;https://github.com/dev-Adhithiya/Neural-Math-Lab&lt;/a&gt;]&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ The Architecture: Client, Proxy, and Intelligence
&lt;/h2&gt;

&lt;p&gt;I wanted to build something beyond a simple API wrapper. The app is split into a frontend UI and a Node.js backend proxy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend (React + Vite):&lt;/strong&gt; Handles the UI, the Node-link Topic Map for navigation, and local state management (IndexedDB).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Proxy (Node.js/Express):&lt;/strong&gt; The true engine of the app. It holds all Azure keys securely server-side and runs all prompts through policy middleware before they ever reach an LLM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The AI Layer:&lt;/strong&gt; A toggleable hybrid system connecting to either Azure AI Foundry/OpenAI or a local Ollama instance.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛡️ Responsible AI &amp;amp; The Security Proxy
&lt;/h2&gt;

&lt;p&gt;One of my main focuses was building "Enterprise-grade" safety into an educational tool. If a student tries to jailbreak the tutor, the system needs to catch it.&lt;/p&gt;

&lt;p&gt;Instead of calling LLMs directly from the browser, I routed everything through a custom backend proxy. This allowed me to implement a robust &lt;strong&gt;Policy Middleware&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Injection Filter:&lt;/strong&gt; Detects and blocks system override attempts before the LLM processes them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safety Categories:&lt;/strong&gt; Scans for violence, self-harm, hate speech, and cyber abuse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict Mode:&lt;/strong&gt; A toggleable setting that completely blocks flagged outputs rather than just warning the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By keeping the Azure keys in the server &lt;code&gt;.env&lt;/code&gt;, the client remains entirely unprivileged.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔌 Hybrid Intelligence: Cloud RAG vs. Local Inference
&lt;/h2&gt;

&lt;p&gt;Not every student has a stable internet connection, and not every query needs to be sent to the cloud. Neural Math Lab features a unified streaming interface that supports two distinct modes:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Local Mode (Privacy-First &amp;amp; Multi-AI Orchestration)
&lt;/h3&gt;

&lt;p&gt;Unlike standard implementations that rely on a single model, Neural Math Lab uses a Local Multi-Agent Pipeline via Ollama. This allows for complex, multimodal workflows entirely on-device:&lt;/p&gt;

&lt;p&gt;The Vision Agent (MiniCPM-V): When a student uploads a photo of a handwritten equation or a geometric diagram, the app routes the image to MiniCPM-V. This specialized model "sees" the math, performing spatial reasoning to convert visual homework into structured digital text.&lt;/p&gt;

&lt;p&gt;The Reasoning Agent (DeepSeek-R1): Once the problem is digitized, it is passed to DeepSeek-R1. R1 doesn't just provide an answer; it uses its internal Chain-of-Thought (CoT) to "think" through the logical steps, explaining the process of solving the math.&lt;/p&gt;

&lt;p&gt;Zero Latency &amp;amp; 100% Privacy: Because both MiniCPM and DeepSeek run via Ollama, sensitive student data (like photos of their desk or handwriting) never leaves their machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Online Mode (Azure RAG)
&lt;/h3&gt;

&lt;p&gt;When connected to the internet, the app leverages an Azure OpenAI endpoint combined with &lt;strong&gt;Azure AI Search&lt;/strong&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I chunked and indexed a &lt;code&gt;math_textbook.pdf&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;When a student asks a complex question, the proxy fetches top matches from the Azure index and injects them as grounding context. The AI doesn't just guess; it teaches directly from the syllabus.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔒 User Control and Data Retention
&lt;/h2&gt;

&lt;p&gt;To round out the privacy-first approach, I built comprehensive data controls directly into the frontend Settings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Persistent Chat via IndexedDB:&lt;/strong&gt; Chats are saved locally in the browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encrypted Local State:&lt;/strong&gt; Users can set a &lt;code&gt;VITE_LOCAL_VAULT_KEY&lt;/code&gt; to encrypt their local data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-Delete Retention:&lt;/strong&gt; Configurable settings to automatically prune chat history after a set number of days, plus one-click export/delete controls.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Running it Locally
&lt;/h2&gt;

&lt;p&gt;If you are testing this out, getting started is easy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo and run &lt;code&gt;npm install&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Copy &lt;code&gt;.env.example&lt;/code&gt; to &lt;code&gt;.env&lt;/code&gt; and add your Azure keys (kept safely on the server!).&lt;/li&gt;
&lt;li&gt;Start your local Ollama instance: &lt;code&gt;ollama run deepseek-r1:7b&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Spin up the full stack: &lt;code&gt;npm run dev:full&lt;/code&gt; (Starts Vite on port 5173 and the Proxy on 8787).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🛠️ Step-by-Step Walkthrough: How it Works&lt;br&gt;
Step 1: Secure Request Handling (The Backend Proxy)&lt;br&gt;
Most frontend apps leak API keys in the network tab. I built a Node.js/Express proxy to solve this. When a user sends a math question:&lt;/p&gt;

&lt;p&gt;The frontend hits &lt;a href="http://localhost:8787/api/chat" rel="noopener noreferrer"&gt;http://localhost:8787/api/chat&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Policy Middleware scans the prompt for injection attacks (e.g., "forget your math rules").&lt;/p&gt;

&lt;p&gt;If safe, the backend attaches the Azure OpenAI Key (stored securely in .env) and forwards the request.&lt;/p&gt;

&lt;p&gt;Step 2: The "Hybrid" Fork&lt;br&gt;
In the Settings.tsx component, I implemented a state-managed switch. Depending on the toggle:&lt;/p&gt;

&lt;p&gt;Online Path: The proxy uses the openai SDK to call Azure. It simultaneously queries Azure AI Search to find relevant math formulas from a pre-indexed textbook.&lt;/p&gt;

&lt;p&gt;Local Path: The request is redirected to the Ollama API (localhost:11434). This allows the app to work 100% offline using the DeepSeek-R1 reasoning model.&lt;/p&gt;

&lt;p&gt;Step 3: Visual Learning with the Topic Map&lt;br&gt;
I moved beyond standard chat lists by building a node-link Topic Map.&lt;/p&gt;

&lt;p&gt;Using a graph-based navigation system, students can see how "Algebra" connects to "Calculus."&lt;/p&gt;

&lt;p&gt;Clicking a node triggers a state update that fetches the specific context for that math topic, grounding the AI's response in that specific domain.&lt;/p&gt;

&lt;p&gt;Step 4: Local Privacy &amp;amp; Persistence&lt;br&gt;
Data privacy is a right, not a feature. I used IndexedDB for chat history storage.&lt;/p&gt;

&lt;p&gt;Persistence: Chats stay in the browser even after a refresh.&lt;/p&gt;

&lt;p&gt;Optional Encryption: Users can toggle "Encrypt local state." This uses a vault key to scramble the data before it hits the browser storage, protecting it from other users on the same machine.&lt;/p&gt;

&lt;p&gt;Step 5: Responsible AI Filtering&lt;br&gt;
Before the response is streamed back to the student, it passes through a final Output Filter.&lt;/p&gt;

&lt;p&gt;If the model attempts to generate restricted content (violence, self-harm, or non-educational topics), the stream is intercepted and replaced with a "Safety Policy Violation" message.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Building Neural Math Lab proved to me that we don't have to compromise between powerful AI and strict safety/privacy. The hybrid approach—RAG when you need accuracy, Local when you need privacy—is the future of educational tech.&lt;/p&gt;

&lt;p&gt;Thanks for checking out my submission! I'd love to hear your thoughts in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>javascript</category>
      <category>security</category>
    </item>
  </channel>
</rss>
