{"slug": "debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my", "title": "DebugPal AI: An Offline-First Visual Socratic Pointer & Memory Tutor Built for my Classmate", "summary": "A developer built DebugPal AI, an offline-first visual Socratic debugging tutor that walks C/C++ students through pointer and memory bugs instead of handing them corrected code. The tool visualizes simulated memory state and pointer chains, then guides learners through three levels of questioning—what a pointer contains, whether the target address is valid, and which operation caused the invalid access—before revealing the root cause. It was created for the developer's classmate and lab partner, who repeatedly hit segmentation faults in university Data Structures labs.", "body_md": "I didn't build DebugPal AI because I wanted to make another coding chatbot.\n\nI built it because my friend **Rohan kept getting `Segmentation fault (core dumped)` in our Data Structures lab—and every time an AI fixed his code, he understood the bug a little less.**\n\nSo I built him something different.\n\n**DebugPal AI** is a visual, Socratic C/C++ debugging tutor that helps students understand *why* pointer and memory bugs happen instead of simply handing them corrected code.\n\n🔗 **Live Demo:** [https://debug-pal.vercel.app/](https://debug-pal.vercel.app/)\n\n🔗 **GitHub:** [https://github.com/ahanghosh77/debug-pal](https://github.com/ahanghosh77/debug-pal)\n\nRohan is my classmate and lab partner.\n\nWe're working through university Data Structures labs where we use **C and C++**, including pointers, linked lists, dynamic memory allocation, and manual memory management.\n\nFor someone coming from a higher-level language such as Python, the hardest part isn't always writing the algorithm.\n\nIt's understanding what is actually happening in memory.\n\nRohan's recurring enemy was:\n\n```\nSegmentation fault (core dumped)\n```\n\nThe compiler would tell him that the program crashed.\n\nBut it didn't give him the mental model he needed to understand **why**.\n\nAnd when he asked cloud AI tools for help, the usual experience was:\n\n\"Here's the corrected code.\"\n\nThe code worked.\n\nThe understanding didn't.\n\nThat was especially frustrating because our university exams aren't just about getting a program to run. We also have to explain the concepts on paper.\n\nSo I wanted to build something that would make him **think through the bug instead of simply copying the fix.**\n\nDebugPal AI takes a C/C++ memory bug and turns it into a visual debugging lesson.\n\nInstead of:\n\n```\nYour program crashed.\nHere is the corrected code.\n```\n\nthe experience is closer to:\n\n```\nWhat does this pointer currently contain?\n\n        ↓\n\nWhere is that address pointing?\n\n        ↓\n\nIs that memory actually valid?\n\n        ↓\n\nWhat invariant did your program violate?\n\n        ↓\n\nNow... how would you fix it?\n```\n\nThe goal is to create the **\"Ohhh, that's why!\"** moment.\n\nPointers are difficult to understand when they're represented only as text.\n\nDebugPal visualizes the simulated memory state with:\n\nFor example, instead of simply seeing:\n\n``` php\nhead->next->next\n```\n\nthe student can see the pointer chain and where the final arrow ends up.\n\nWhen the destination is invalid, DebugPal makes the crash point visually obvious.\n\nThis is particularly useful for beginners who have learned the syntax of pointers but haven't yet developed a mental model of memory.\n\nA segmentation fault is only the symptom.\n\nThe more important question is:\n\n**What rule did my program violate?**\n\nDebugPal tries to make that rule explicit.\n\nFor example:\n\n```\nhead\n  ↓\nnode\n  ↓\nNULL\n```\n\nand then:\n\n``` php\nhead->next->next\n```\n\nInstead of immediately revealing the corrected code, DebugPal asks the student to reason about the next pointer and whether the next dereference is valid.\n\nThis turns debugging into a small reasoning exercise.\n\nDebugPal deliberately doesn't reveal everything immediately.\n\nThe guidance is split into three levels:\n\nWhat does this pointer contain right now?\n\nIs the memory address you're about to dereference guaranteed to contain a valid object?\n\nWhat exact operation caused the invalid memory access?\n\nOnly after thinking through the first two stages does the student get the root-cause explanation.\n\nThe idea is simple:\n\n**Don't remove the student's debugging problem. Teach them how to debug it.**\n\nLow-level memory concepts can feel extremely abstract.\n\nSo DebugPal also explains them using everyday situations.\n\nImagine checking out of a hotel but continuing to use the room key.\n\nThe key still exists.\n\nThe room doesn't belong to you anymore.\n\nThat's roughly the mental model of a dangling pointer.\n\nImagine borrowing books from a library and never returning them.\n\nYou may still be able to use the books, but the library's available resources keep shrinking.\n\nThat's the intuition behind a memory leak.\n\nYou're following an address to find a destination, but the address effectively says:\n\n```\nThere is nothing here.\n```\n\nThen your program tries to use it anyway.\n\nDebugPal also provides a defensive code view.\n\nInstead of only showing:\n\n```\n❌ This is wrong.\n```\n\nit shows the vulnerable version and a safer version side by side, followed by a checklist of the programming rule involved.\n\nThe objective is to connect:\n\n**bug → memory state → violated invariant → defensive programming practice**\n\nrather than treating each compiler error as an isolated problem.\n\nThis is the part of the project that mattered especially for this Hacktoberfest challenge.\n\nThe challenge asks participants to build something with **open-source/open-weight AI at its core**, including local inference with open-weight models.\n\nDebugPal is designed around that idea.\n\nFor custom C/C++ code, the application can connect directly to a locally running **Ollama** instance.\n\nThe browser sends the code to the local Ollama API and asks the selected open-weight model to return a structured debugging analysis.\n\nThe model is instructed to produce:\n\nThe response is structured as JSON so the frontend can turn the model's reasoning into the visual debugging interface.\n\nThe relevant implementation is in `app.js`, where DebugPal calls the local Ollama `/api/generate` endpoint and requests a fixed JSON schema.\n\nThis was important because Rohan is a student.\n\nUniversity Wi-Fi isn't always reliable.\n\nSo DebugPal doesn't completely fall apart when Ollama isn't available.\n\nIt has a built-in heuristic fallback that can still identify common patterns such as:\n\n`free()`\nThe application therefore has two modes:\n\n```\n             C/C++ Code\n                  │\n                  ▼\n        ┌──────────────────┐\n        │  Local Ollama AI  │\n        │ Open-weight model │\n        └────────┬─────────┘\n                 │\n                 │ unavailable?\n                 ▼\n        ┌──────────────────┐\n        │ Heuristic Engine │\n        └────────┬─────────┘\n                 │\n                 ▼\n       Visual Debugging Lesson\n```\n\nThat architecture means the student can still use the core learning experience without depending on a remote AI server.\n\nI included four common problems that map closely to what students encounter while learning C/C++:\n\n``` php\nhead->next->next\n```\n\nwithout safely checking whether the required nodes exist.\n\nReturning or using the address of memory whose lifetime has already ended.\n\nAllocating dynamic memory without correctly freeing the allocated blocks.\n\nAn off-by-one loop accessing an array outside its valid bounds.\n\nEach preset is designed to demonstrate a different memory-safety concept.\n\nThis was the most important part of the project.\n\nI didn't just build the website and call it \"built for a friend.\"\n\nI actually handed it to Rohan in our hostel study room while we were preparing for our Data Structures lab evaluation.\n\nHe tried the linked-list segmentation fault example.\n\nHis reaction was:\n\n\"During our linked list assignment, I kept getting segfaults because I was chaining `head->next->next` without verifying if the list had fewer than 3 nodes. Cloud AI just gave me the corrected code without explaining why my logic failed.\"\n\nThen he saw the memory visualization:\n\n\"When DebugPal drew the Stack and Heap map and showed the arrow pointing into `0x00000000 [Unmapped Page 0]`, it instantly clicked why the CPU crashed.\"\n\nAnd the part I cared about most:\n\n\"The Socratic hints made me think about the loop condition instead of guessing.\"\n\nHe has already bookmarked DebugPal on his laptop for our upcoming evaluations.\n\nThat's probably the best validation I could have asked for.\n\nThe project is intentionally lightweight.\n\nNo heavy framework or build pipeline is required.\n\nThe repository can be opened directly in a browser.\n\nA built-in heuristic analysis engine handles common pointer/memory patterns when local AI isn't available.\n\nDebugPal can generate a Markdown debugging report containing:\n\nThat turns a debugging session into something the student can keep as study notes.\n\nFor this particular use case, local AI has some advantages.\n\nStudent code can stay on the student's machine instead of being sent to a third-party cloud service.\n\nA student shouldn't need an expensive subscription just to understand a segmentation fault in a lab assignment.\n\nThe tool can be used even when internet connectivity is poor.\n\nBecause the model is open-weight and runs locally, students can experiment with different models and prompts instead of being locked into a single cloud provider.\n\nThat's the part of open innovation I wanted to explore with this project.\n\n👉 [https://debug-pal.vercel.app/](https://debug-pal.vercel.app/)\n\n👉 [https://github.com/ahanghosh77/debug-pal](https://github.com/ahanghosh77/debug-pal)\n\nThe easiest way to try the application:\n\nIf you have Ollama running locally, you can also configure the local model from the application's model settings and analyze custom C/C++ code.\n\nThe challenge wasn't just:\n\n\"Build an AI application.\"\n\nIt was:\n\n**Build something for a real person.**\n\nRohan had a very specific problem.\n\nHe wasn't asking for another coding assistant.\n\nHe needed someone—or something—that would sit beside him and explain:\n\n**\"Stop. Look at what your pointer is actually doing.\"**\n\nThat's what I tried to build.\n\nDebugPal AI is basically a **visual teaching assistant for the moment when your C program crashes at 1 AM and you have no idea why.**\n\nAnd if it helps Rohan walk into our next Data Structures lab a little less afraid of pointers, then the project has already done what I wanted it to do.\n\nThere are several things I'd like to improve after the challenge:\n\nFor now, though:\n\n**Rohan has stopped being scared of `Segmentation fault`.**\n\nAnd that's a pretty good first version.\n\n`HTML` · `CSS` · `JavaScript` · `Ollama` · `Open-weight AI` · `C/C++ debugging concepts`\n\nMIT\n\nBuilt with ❤️ for Hacktoberfest 2026.", "url": "https://wpnews.pro/news/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my", "canonical_source": "https://dev.to/abhishek_jha_db6eaa98a2af/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my-classmate-282f", "published_at": "2026-10-04 16:37:31+00:00", "updated_at": "2026-10-04 16:42:27.064138+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["DebugPal AI", "Rohan", "GitHub", "Vercel"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my", "markdown": "https://wpnews.pro/news/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my.md", "text": "https://wpnews.pro/news/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my.txt", "jsonld": "https://wpnews.pro/news/debugpal-ai-an-offline-first-visual-socratic-pointer-memory-tutor-built-for-my.jsonld"}}