Skip to content

sgkul2000/CodeTutor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§‘β€πŸ« CodeTutor β€” AI-Powered Coding Tutor

An intelligent coding practice platform that goes beyond pass/fail. Submit your code, get real-time AI feedback powered by Claude, and unlock progressively deeper hints as you learn β€” not just answers.

Screenshots

Login Problems List
Login with Google, GitHub, or Dev mode 10 curated DSA problems with difficulty & topic tags
AI Tutor Dashboard
Monaco editor + live code execution + AI analysis Knowledge radar chart, stats & recent activity

Features

  • πŸ€– AI Tutoring β€” Submit code and receive instant, Socratic-style feedback from Claude (claude-sonnet-4-5). The tutor nudges you towards the answer rather than giving it away.
  • πŸ’‘ 4-Level Hint Escalation β€” Start with a directional nudge, escalate through approach β†’ structure β†’ full walkthrough at your own pace.
  • πŸ’¬ Follow-up Chat β€” Ask follow-up questions in natural language and continue the tutoring conversation with full context.
  • ⚑ Real-time Streaming β€” AI responses stream token-by-token via SSE so you see feedback as it's generated.
  • πŸ–₯️ Monaco Editor β€” VS Code's editor in the browser with syntax highlighting for Python, Java, and JavaScript.
  • ▢️ Code Execution β€” Solutions are run against test cases using the Piston code execution engine.
  • πŸ“Š Knowledge Dashboard β€” Radar chart visualising topic proficiency across Arrays, Strings, Hash Maps, Stack/Queue, Graphs, and more.
  • πŸ” OAuth 2.0 Auth β€” Sign in with Google or GitHub; JWT access tokens with silent background refresh.
  • βš™οΈ Assistance Levels β€” Four tutor personas from "Nudge me" (minimal hints) to "Full guidance".
  • πŸ› οΈ Admin Panel β€” CRUD interface for managing the problem bank.

Tech Stack

Layer Technology
Frontend React 19, TypeScript, Vite, Tailwind CSS
Editor Monaco Editor (@monaco-editor/react)
State Zustand + persist middleware
Backend FastAPI (Python 3.12), async/await throughout
Database MongoDB 7 via Beanie ODM
Cache / Rate-limit Redis 7.2 + SlowAPI
AI Anthropic Claude (claude-sonnet-4-5) via SSE streaming
Code Execution Piston API (self-hostable, multi-language)
Auth OAuth 2.0 (Google + GitHub), JWT (access + refresh tokens)
Infrastructure Docker Compose

Getting Started

Prerequisites

1. Clone the repo

git clone https://github.com/sgkul2000/CodeTutor.git
cd CodeTutor

2. Start infrastructure (MongoDB + Redis)

docker compose up -d

This starts:

  • MongoDB 7 on port 27017
  • Redis 7.2 on port 6379

3. Configure the backend

cd ai-tutor-backend
cp .env.example .env   # or create .env manually (see below)

Minimum required .env:

# MongoDB
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB_NAME=ai_tutor

# Redis
REDIS_URL=redis://localhost:6379

# JWT
JWT_SECRET_KEY=your-super-secret-key-change-in-production
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=15
JWT_REFRESH_TOKEN_EXPIRE_DAYS=30

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# App
ENVIRONMENT=development
BACKEND_URL=http://localhost:8000
FRONTEND_URL=http://localhost:5173

# OAuth (optional β€” dev login works without these)
# GOOGLE_CLIENT_ID=...
# GOOGLE_CLIENT_SECRET=...
# GITHUB_CLIENT_ID=...
# GITHUB_CLIENT_SECRET=...

4. Install backend dependencies & seed the database

# In ai-tutor-backend/
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Seed 10 DSA problems
python -m scripts.seed_problems

5. Start the backend

uvicorn app.main:app --reload --port 8000

API docs available at http://localhost:8000/docs

6. Install frontend dependencies & start the dev server

cd ../ai-tutor-frontend
npm install
npm run dev

Open http://localhost:5173 in your browser.

7. Log in

Click ⚑ Sign in (Dev Mode only) on the login page β€” no OAuth credentials required in development.


Project Layout

CodeTutor/
β”œβ”€β”€ docker-compose.yml               # MongoDB + Redis
β”œβ”€β”€ ai-tutor-backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                  # FastAPI entry-point
β”‚   β”‚   β”œβ”€β”€ config.py                # Settings (pydantic-settings)
β”‚   β”‚   β”œβ”€β”€ models/                  # Beanie ODM models (User, Problem, Submission…)
β”‚   β”‚   β”œβ”€β”€ routers/                 # auth, problems, submissions, tutor
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ auth_service.py      # JWT helpers, OAuth client
β”‚   β”‚       β”œβ”€β”€ judge_service.py     # Piston API integration
β”‚   β”‚       └── tutor_service.py     # Claude streaming, hint escalation
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   └── seed_problems.py         # Seeds 10 starter DSA problems
β”‚   └── requirements.txt
└── ai-tutor-frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ api/                     # Axios client (silent refresh) + SSE helpers
    β”‚   β”œβ”€β”€ components/              # Shared UI components
    β”‚   β”œβ”€β”€ hooks/                   # useAuth, useTutor, useProblems…
    β”‚   β”œβ”€β”€ pages/                   # Login, Problems, ProblemSolve, Dashboard
    β”‚   β”œβ”€β”€ stores/                  # Zustand app store
    β”‚   └── types/                   # Shared TypeScript types
    └── package.json

How the AI Tutor Works

  1. Submit β€” Your code is sent to the Piston execution engine and run against test cases.
  2. Analyse β€” Regardless of pass/fail, the code and test results are sent to Claude with a Socratic prompt tailored to your chosen assistance level (1–4).
  3. Stream β€” Claude's response streams back token-by-token via SSE and appears in real time.
  4. Hint escalation β€” If you need more help, click Deeper hint β†’ to escalate from Direction β†’ Approach β†’ Structure β†’ Full Walkthrough.
  5. Follow-up β€” Ask questions in the chat input; the full conversation history is maintained so Claude has context.

Available Scripts

Directory Command Description
root docker compose up -d Start MongoDB + Redis
ai-tutor-backend uvicorn app.main:app --reload Start API server (port 8000)
ai-tutor-backend python -m scripts.seed_problems Seed 10 DSA problems
ai-tutor-frontend npm run dev Start Vite dev server (port 5173)
ai-tutor-frontend npm run build Production build
ai-tutor-frontend npm run lint ESLint check

API Overview

Method Endpoint Description
GET /api/auth/dev-login Dev-only instant login
GET /api/auth/{provider} OAuth redirect (google/github)
POST /api/auth/refresh Silent token refresh
GET /api/problems List problems (filter by difficulty/topic)
POST /api/submissions Submit code for execution
POST /api/tutor/analyze Stream AI analysis of a submission
POST /api/tutor/hint Stream next hint level
POST /api/tutor/ask Stream follow-up chat response
GET /api/users/dashboard User stats + topic proficiency

Full interactive docs: http://localhost:8000/docs


License

MIT

About

An AI powered tutor that helps you with coding.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors