DEV Community

kshitiz Tiwari
kshitiz Tiwari

Posted on

CodeBuddy — An AI Coding Mentor That Learns From Your Mistakes

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

What I Built

I built CodeBuddy, a local-first AI coding mentor for a friend who is learning programming and DSA.

My friend often gets stuck while debugging code and usually has to ask someone else for help. The problem isn't always finding the correct solution — it's understanding why the code is wrong and how to avoid making the same mistake again.

CodeBuddy lets them paste their code, select the programming language, and provide an error or describe the expected behavior. Instead of immediately giving them the answer, it guides them through the problem using progressive hints and explanations.

It can:

🔍 Identify and explain the problem
💡 Provide hints before revealing the solution
📚 Explain the underlying programming concept
🛠️ Suggest a possible fix
🧠 Remember previous mistakes
🔄 Identify recurring mistakes over time

I built it specifically for my friend because I wanted to turn the kind of debugging help I was repeatedly giving them into a tool they could use themselves.

The goal isn't to replace learning with AI. It's to use AI to make the learner better at solving problems independently.

Demo

🌐 Live Demo: https://code-buddy-eight-psi.vercel.app/

The demo shows the core CodeBuddy workflow:

Code → Diagnosis → Hint → Concept Explanation → Fix → Lesson → Mistake Memory

Code

💻 GitHub Repository: https://github.com/kshitiz374/CodeBuddy

How I Built It

CodeBuddy is built as a local-first AI application, with an open-weight AI model running locally through Ollama.

The main idea is to make the AI model an actual part of the learning workflow rather than simply putting a chatbot interface on top of an AI API.

Tech Stack
Next.js + TypeScript + Tailwind CSS — frontend
FastAPI + Python — backend
SQLite — local learning history and mistake memory
Ollama — local AI inference
Open-weight AI model — code analysis and learning guidance
How It Works

The workflow is:

Code + Error
↓
Local AI Analysis
↓
Problem Diagnosis
↓
Progressive Hint
↓
Concept Explanation
↓
Possible Fix
↓
Lesson to Remember
↓
Mistake Memory

My friend enters their code, programming language, and error or expected behavior. CodeBuddy sends this context to the locally running AI model.

The model analyzes the problem and produces a structured response containing the diagnosis, hints, explanation, possible fix, and lesson.

I also built a Mistake Memory feature that stores previous debugging sessions locally. This allows CodeBuddy to recognize recurring mistakes and make future guidance more relevant.

For example, if a learner repeatedly makes mistakes involving pointers, CodeBuddy can use their previous learning history to help them recognize that pattern.

The AI isn't just an add-on chatbot — the open-weight local model is at the core of the debugging and learning experience.

Why Does Open Innovation Matter?

Open innovation matters to CodeBuddy because the project is built around learning, local use, and user control.

My friend shares source code, programming mistakes, and learning history with CodeBuddy. With a local open-weight model, the core AI processing can happen on the user's own machine rather than requiring every interaction to be sent to a closed cloud AI API.

It also gives me more control over how the AI behaves. I can experiment with different open-weight models, modify the prompts and mentoring approach, and potentially customize the system for programming education without being locked into a single AI provider.

Another important aspect is offline capability. After the required model and software are installed, the core AI experience can run without an internet connection, and there is no per-request API charge.

A closed API could provide similar coding assistance, but using an open approach made it possible to build CodeBuddy around local inference, model flexibility, customization, and offline use.

My Agent Session

Prize Categories

Built for a Friend ❤️

CodeBuddy started with a simple problem:

“My friend keeps getting stuck on the same coding mistakes.”

Instead of just fixing the code for them, I wanted to build something that could help them understand why they were stuck.

That's what CodeBuddy is about:

Less “Here's your answer.”
More “Here's how you can figure it out.”

Top comments (0)