# CodeTutor

Coding interview preparation application with curated questions, educational
explanations, and multiple solution approaches.

## Features

- **Interactive code editor** with Python execution in the browser (via Pyodide)
- Run and submit solutions with instant feedback on test cases
- Supports all problem types: simple functions, trees, linked lists, and class-based designs
- Curated collection of coding interview questions
- Detailed explanations with approach, intuition, and complexity analysis
- Common pitfalls and key takeaways for each question
- Multiple solution implementations (optimal and alternative approaches)
- Filter by difficulty, category, and algorithmic pattern
- Links to LeetCode for practice

## Tech Stack

- **Backend:** FastAPI, SQLAlchemy, PostgreSQL, Alembic
- **Frontend:** Next.js 15, React, TypeScript, Tailwind CSS
- **Infrastructure:** Docker, Docker Compose

## Quick Start

### Prerequisites

- Docker and Docker Compose
- Python 3.12+ (for local backend development)
- Node.js 20+ (for local frontend development)

### Using Docker (Recommended)

```bash
# Set required environment variable
export POSTGRES_PASSWORD=your_secure_password

# Start all services
docker compose up

# Access the application
# Frontend: http://localhost:3000
# API: http://localhost:8000
# API Docs: http://localhost:8000/docs
```

### Local Development

1. Start the database:

```bash
export POSTGRES_PASSWORD=your_secure_password
docker compose up db
```

2. Set up the backend:

```bash
cd backend
cp .env.example .env
# Edit .env with your database credentials
pip install -e ".[dev]"
alembic upgrade head
python scripts/load_data.py
uvicorn src.main:app --reload
```

3. Set up the frontend:

```bash
cd frontend
npm install
npm run dev
```

## Project Structure

```
codetutor/
├── backend/           # FastAPI application
│   ├── src/           # Source code
│   ├── alembic/       # Database migrations
│   ├── data/          # Question content (YAML)
│   ├── scripts/       # Data loading utilities
│   └── tests/         # Backend tests
├── frontend/          # Next.js application
│   └── src/           # Source code
└── docker-compose.yml # Development environment
```

## API Documentation

Once running, access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc

## Content

Questions are organised by:

**Categories:** Arrays, Strings, Hash Tables, Linked Lists, Trees, Graphs,
Dynamic Programming, Binary Search, Sorting, Stack, Queue, Heap, Two Pointers,
Recursion, Math

**Patterns:** Two Pointers, Sliding Window, Fast & Slow Pointers, Binary Search,
BFS, DFS, Backtracking, Dynamic Programming, Greedy, Monotonic Stack, Heap,
Union Find, Trie

## License

MIT
