leetui-terminal 0.4.0
Terminal-first LeetCode practice app powered by Textual
Requires Python: >=3.10
Keywords: leetcode, terminal, tui, practice, dsa, competitive-programming

# LeetUI (macOS-first Terminal LeetCode TUI)

A terminal-only LeetCode-style practice app built with Textual + Rich.

## Install

```bash
pip install leetui-terminal
```

or

```bash
pip3 install leetui-terminal
```

Then run:

```bash
leetui
```

That's it. No virtual environment needed.

> **Requires:** macOS (Terminal.app or iTerm2) with Python 3.10+
>
> If you don't have Python: `brew install python`

## Run from source (for contributors)

```bash
git clone https://github.com/siddartha018/leetcodecli.git
cd leetcodecli
python3 -m venv .venv
source .venv/bin/activate
pip3 install -e .
leetui
```

> Always work inside the venv when developing. To re-enter it later:
>
> ```bash
> cd leetcodecli
> source .venv/bin/activate
> ```

## Keyboard shortcuts (keyboard-only flow)

**Problem browser:**

- `↑` / `↓`: Move between search, filters, and problem list
- `←` / `→`: Move across filters
- `Enter`: Open selected problem in workspace
- `Esc`: Back to home

**Workspace (split view):**

- `e`: Focus the code editor (right pane)
- `s`: Toggle between Description and Solutions tabs (left pane)
- `Esc`: Editor → question pane → problem browser
- `↑` / `↓`: Scroll description or navigate solutions list
- `Ctrl+R` / `Alt+R`: Run current test
- `Ctrl+T` / `Alt+T`: Run all tests
- `Ctrl+D` / `Alt+D`: Save solution
- `PageUp` / `PageDown`: Fast scroll
- `Ctrl+Q`: Quit app

## Language support

- Current build is **Python-only** for writing and running code.
- Onboarding asks you to continue with Python before sheet selection.

## Search and filters

Start screen includes:

- Free text search (title/tags/patterns/companies)
- Company filter
- Pattern filter
- Difficulty filter (`easy`, `medium`, `hard`)
- Source filter (`leetcode`, `cses`, `web`, `local`)

## Sheets support

Included sheet catalog:

- NeetCode 150
- Striver DSA Sheet
- TLE Eliminators CP Sheet
- CSES Problem Set

The app shows local coverage as `(<local>/<total>)` per sheet.

To make these filters useful, include metadata in problem JSON:

```json
{
  "source": "leetcode",
  "companies": ["amazon", "google"],
  "patterns": ["two-pointers", "hashmap"]
}
```

## Adding questions from web / LeetCode

LeetUI reads local JSON files in `leetui/problems/`.
To include web/LeetCode questions, export or curate them into this JSON format and set:

- `"source": "leetcode"` (or `"web"`)
- `"source_url": "<original problem URL>"`
- `"companies": [...]`
- `"patterns": [...]`

This keeps the app terminal-only and fast while still supporting web-curated problem sets.

You can also import a JSON catalog directly:

```bash
leetui-import /path/to/catalog.json
# or
leetui-import https://example.com/leetui-catalog.json
```

## Share with friends

Tell them to run:

```bash
pip install leetui-terminal
leetui
```

Or using pipx (isolated install):

```bash
brew install pipx
pipx ensurepath
pipx install leetui-terminal
leetui
```

## Solutions page

Each problem has a read-only solutions page with:

- `Brute Force` explanation + Python code
- `Better` explanation + Python code
- `Optimal` explanation + Python code

## Project layout

```text
leetui/
├── app.py
├── ui/
│   ├── layout.py
│   └── bindings.py
├── problems/
│   └── two_sum.json
├── workspace/
│   └── solution.py
├── runner/
│   └── executor.py
├── models/
│   └── problem.py
├── storage/
│   └── progress.db (auto-created on first run)
└── utils/
    └── markdown.py
```