An AI-powered algorithm tutor that provides personalized learning with accountability, persistence, and real-time feedback. Think LeetCode + OpenAI Study Mode but with Socratic questioning, line-by-line feedback, and structured pattern recognition.
- 🤖 LLM-Powered Guidance: Uses OpenAI GPT-4 for Socratic questioning and personalized feedback
- 📚 Structured Curriculum: Progressive learning path covering all essential algorithm patterns
- 💾 Session Persistence: Your progress and learning sessions are saved and tracked
- ⚡ Real-time Code Execution: Execute and test your solutions instantly with detailed feedback
- 🎯 Pattern Recognition: Automatically identifies algorithm patterns in your code
- 📝 Line-by-line Feedback: Detailed analysis of your solution with suggestions for improvement
- 🔄 Quality over Quantity: Focus on deep understanding rather than solving many problems
- ❓ Progressive Hints: Get hints that guide your thinking without giving away solutions
- Clone the repository:
git clone <your fork or this repo>
cd algotutor- Install dependencies:
pip install -e .- Set up environment variables:
cp .env.example .env
# Edit .env and add your OpenAI API key- Initialize the database:
algotutor --initalgotutor --user your_username- solve: Work on algorithm problems with AI guidance
- review: Review your past solutions and progress
- progress: View detailed learning statistics
- quit: End your session
When solving problems, you can:
- code: Write and edit your solution
- hint: Get progressive hints (3 levels available)
- submit: Test your solution and get detailed feedback
- skip: Move to another problem
algotutor/
├── core/ # Core configuration and utilities
├── models/ # Database models and schemas
├── services/ # Business logic services
│ ├── llm.py # OpenAI integration for AI feedback
│ ├── execution.py # Code execution and testing
│ ├── database.py # Data persistence
│ └── curriculum.py # Learning curriculum management
├── cli/ # Command-line interface
└── data/ # Sample data and curricula
-
LLM Service: Handles all AI interactions including:
- Socratic questioning
- Pattern recognition
- Line-by-line code analysis
- Progressive hint generation
-
Code Execution Service: Safely executes Python code with:
- Syntax validation
- Test case execution
- Timeout protection
- Basic complexity analysis
-
Database Service: Manages persistence for:
- User progress tracking
- Session history
- Problem attempts and feedback
- Curriculum data
-
Curriculum Service: Organizes learning with:
- Structured topic progression
- Pattern-based problem categorization
- Difficulty-adaptive content
The tutor covers essential algorithm patterns:
- Arrays & Strings: Two pointers, sliding window
- Hash Tables: Fast lookups, frequency counting
- Linked Lists: Traversal, cycle detection, reversal
- Stacks & Queues: LIFO/FIFO, monotonic patterns
- Trees: Traversals, BST operations, construction
- Graphs: DFS/BFS, topological sort, union-find
- Dynamic Programming: Memoization, tabulation, patterns
- Backtracking: Constraint satisfaction, exhaustive search
- Sorting & Searching: Binary search, custom comparators
Environment variables (.env):
# Required
OPENAI_API_KEY=your_api_key_here
# Optional
MODEL_NAME=gpt-4-turbo-preview
MAX_TOKENS=2000
TEMPERATURE=0.7
DATABASE_URL=sqlite:///cb_tutor.db
DEBUG=False
LOG_LEVEL=INFO- Start Session:
algotutor --user alice - Choose Problem: System suggests "Two Sum" for beginners
- Code Solution: Interactive editor with syntax highlighting
- Get Feedback: AI asks "What data structure could help you find complements efficiently?"
- Refine Approach: Based on Socratic guidance
- Submit & Test: Real-time execution with test cases
- Review Results: Line-by-line analysis and pattern recognition
Your Code:
def twoSum(nums, target):
for i in range(len(nums)):
for j in range(i+1, len(nums)):
if nums[i] + nums[j] == target:
return [i, j]AI Feedback:
- "Your solution works but has O(n²) complexity. What if the array was very large?"
- "Line 2-3: The nested loops suggest we're checking every pair. Can we avoid this?"
- Pattern Recognition:
nested_loops,brute_force - Suggestion: "Consider using a hash map to store numbers you've seen"
- Uses SQLAlchemy for database ORM
- Pydantic for data validation
- Rich library for beautiful CLI interface
- Click for command-line parsing
- OpenAI API for LLM integration
problem = db_service.create_problem(
title="Your Problem",
description="Problem description...",
difficulty="medium",
category="Dynamic Programming",
patterns=["dp", "memoization"],
solution_template="def solve():\n pass",
test_cases=[{"input": [1, 2], "expected": 3}],
hints=["Think about subproblems", "Consider memoization"]
)- Fork the repository
- Create a feature branch
- Add your improvements
- Submit a pull request
MIT License - see LICENSE file for details.
Happy Learning! 🚀 The best way to master algorithms is through guided practice with immediate feedback. AlgoTutor provides the AI mentorship you need to level up your coding skills.