DEV Community

dineshkottaKota
dineshkottaKota

Posted on

SkillDuel — I Built an AI Socratic Learning Partner for My Friend (Runs 100% Locally, Free Forever)

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

What I Built

⚡ SkillDuel — an adaptive AI Socratic learning partner that challenges you with smart, probing questions to make you actually think instead of just passively consuming content.

I built this for my friend who has been learning Python for 3 months. She felt stuck — she could follow tutorials, but wasn't sure if she truly understood things or just recognized familiar patterns. She needed something that would ask her the hard questions, kindly and adaptively, without judgment.

SkillDuel works for any skill — Python, chess, cooking, math, a new language. You type your answers and the AI:

  1. Evaluates your understanding with honest, warm feedback
  2. Explains the ideal answer clearly
  3. Drops a deeper insight to spark curiosity
  4. Adapts — harder if you nail it, gentler if you're struggling
  5. Tracks XP and streaks to keep you motivated

When I showed it to her, she said: "This is the first time I've actually had to think instead of just type."

Demo

🖥️ Run locally in 3 steps (see How I Built It below). No deployment needed — that's the point.

1. Enter your name + skill → choose difficulty → pick your local model
2. AI asks a Socratic question ("What happens when Python evaluates `2 + True`?")
3. You answer → AI evaluates, explains, and gives a deeper insight
4. XP + streaks update → next adaptive question loads
Enter fullscreen mode Exit fullscreen mode

Code

SkillDuel/
├── backend/
│   ├── main.py           ← FastAPI + LangChain Socratic engine (~300 lines)
│   └── requirements.txt
├── frontend/
│   └── index.html        ← Full dark-mode UI, single file, no framework
└── README.md
Enter fullscreen mode Exit fullscreen mode

Backend — the Socratic engine core (backend/main.py):

# LangChain orchestrates two prompts per round:
# 1. Generate a Socratic question adapted to current level + topic
# 2. Evaluate the answer and generate the next question

SYSTEM_PROMPT = """You are SkillDuel — a brilliant, warm Socratic learning partner.
Your friend {friend_name} is learning {skill} at the {level} level.
Ask ONE focused question. Use the Socratic method.
Respond ONLY with JSON: { "question": "...", "hint": "...", "topic": "..." }"""

EVALUATE_PROMPT = """Evaluate {friend_name}'s answer while they learn {skill}.
Question: {question} | Answer: {answer}
Respond ONLY with JSON: { "is_correct": true, "score": 0-100,
  "feedback": "...", "explanation": "...", "follow_up_insight": "..." }"""
Enter fullscreen mode Exit fullscreen mode

The app calls Ollama's local HTTP API directly (localhost:11434) — no cloud, no keys.

Adaptive difficulty logic:

if score >= 80:
    xp_gained = 30
    session["streak"] += 1
elif score >= 50:
    xp_gained = 15
    session["streak"] = max(0, session["streak"] - 1)
else:
    xp_gained = 5
    session["streak"] = 0

# Streak bonus — 3+ correct in a row = 1.5x XP
if session["streak"] >= 3:
    xp_gained = int(xp_gained * 1.5)
Enter fullscreen mode Exit fullscreen mode

How I Built It

Open-source stack — every piece:

Layer Technology Why
🦙 LLM Runtime Ollama Runs any open-weight model locally
🔗 Agent Framework LangChain Core Prompt orchestration + output parsing
⚡ API FastAPI Async Python backend
🎨 UI Vanilla HTML/CSS/JS Zero dependencies, single file
🧠 Models llama3.2 (default) Swap to Mistral, Gemma, Phi, CodeLlama freely

Architecture:

Browser (index.html)
    ↓ REST (localhost:8000)
FastAPI + LangChain
    ↓ HTTP (localhost:11434)
Ollama → llama3.2 (local, on your machine)
Enter fullscreen mode Exit fullscreen mode

To run it yourself:

# 1. Install & start Ollama
winget install Ollama.Ollama
ollama pull llama3.2

# 2. Start the backend
cd backend && pip install -r requirements.txt && python main.py

# 3. Open frontend/index.html in your browser
Enter fullscreen mode Exit fullscreen mode

LangChain handles the two-prompt pipeline — one to generate an adaptive Socratic question, one to evaluate and explain the answer — with robust JSON parsing to handle LLM output variability.

Why Does Open Innovation Matter?

Four things that would be impossible with a closed API:

🔒 True privacy. My friend's learning journey — her struggles, her gaps, her questions — stays on her machine. No logs shipped to a server she doesn't control. A closed API makes that impossible by definition.

💸 $0 to run. There's no API bill. No credit card. No rate limits. A student or someone in a lower-income country can run this forever at the cost of electricity. Closed APIs price people out.

🔄 Model freedom. Learning to code? Use codellama. Want faster responses on a slow laptop? Switch to phi3. Want the most capable model? Run llama3.1:70b if you have the GPU. You control the intelligence, not a vendor.

✏️ Full hackability. The Socratic prompts are plain text in main.py. My friend can edit them — make the AI stricter, warmer, more technical, more playful. She can fine-tune a model on her own Q&A style. A closed API gives you a black box; open source gives you a whiteboard.

Open innovation here means: the tool belongs to the person using it.

Prize Categories

  • 🦙 Ollama — core inference runtime, runs all local models
  • 🔗 LangChain — open-source agent framework powering the Socratic engine

Built in one weekend. Works on a laptop with no internet. Costs nothing to run. The data stays yours.

Top comments (0)