# jeyprabu/leetcode-coach architecture

> Architecture diagram of the GitHub repository jeyprabu/leetcode-coach, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeyprabu/leetcode-coach
- Repository: https://github.com/jeyprabu/leetcode-coach

## Overview

LeetCode Coach is a local, stateful CLI for guided problem practice. A user starts or resumes a session; the CLI loads a problem and invokes a LangGraph workflow that analyzes it, offers progressive hints, waits for an approach, evaluates it, and either loops for another hint, stops at the hint limit, or explains complexity. Graph state is checkpointed in SQLite, while analysis, hints, evaluation, and complexity feedback use a structured local Ollama model. Workflow links are supported by the graph definition; persistence and resume capabilities are also documented in the README.

Main entry points: [`app/nodes/evaluate.py`](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/evaluate.py) (Answer Evaluation), [`app/llm.py`](https://github.com/jeyprabu/leetcode-coach/blob/master/app/llm.py) (Ollama Client), [`app/main.py`](https://github.com/jeyprabu/leetcode-coach/blob/master/app/main.py) (Session CLI), [`app/graph.py`](https://github.com/jeyprabu/leetcode-coach/blob/master/app/graph.py) (Workflow Graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Problems"]
  node_cli["Session CLI<br/>[main.py]"]
  node_loader["Problem Loader<br/>[problem_loader.py]"]
  node_problems[("Problem Repository<br/>[problems.json]")]
end

subgraph group_workflow["Coaching Workflow"]
  node_graph["Workflow Graph<br/>[graph.py]"]
  node_state["Workflow State<br/>[state.py]"]
  node_analyze["Problem Analysis<br/>[analyze.py]"]
  node_hint["Progressive Hints<br/>[hint.py]"]
  node_input["Answer Interrupt<br/>[user_input.py]"]
  node_evaluate["Answer Evaluation<br/>[evaluate.py]"]
  node_complexity["Complexity Feedback<br/>[complexity.py]"]
  node_limit["Hint Limit<br/>[max_hints.py]"]
end

subgraph group_model["Local Model"]
  node_llm["Ollama Client<br/>[llm.py]"]
  node_ollama["Ollama Runtime"]
end

subgraph group_persistence["Session Persistence"]
  node_sqlite[("SQLite Checkpoints")]
end

node_user(("Learner"))

node_user -->|"chooses session"| node_cli
node_cli -->|"loads problem"| node_loader
node_loader -->|"reads JSON"| node_problems
node_cli -->|"invokes or resumes"| node_graph
node_graph -->|"uses schema"| node_state
node_graph -->|"starts workflow"| node_analyze
node_analyze -->|"routes next"| node_hint
node_hint -->|"routes next"| node_input
node_input -->|"routes next"| node_evaluate
node_evaluate -->|"routes if unsolved"| node_hint
node_evaluate -->|"routes if solved"| node_complexity
node_evaluate -->|"routes at limit"| node_limit
node_analyze -->|"requests analysis"| node_llm
node_hint -->|"requests hint"| node_llm
node_evaluate -->|"requests evaluation"| node_llm
node_complexity -->|"requests analysis"| node_llm
node_llm -->|"runs inference"| node_ollama
node_graph -->|"checkpoints state"| node_sqlite
node_cli -->|"supplies response"| node_input

click node_cli "https://github.com/jeyprabu/leetcode-coach/blob/master/app/main.py"
click node_loader "https://github.com/jeyprabu/leetcode-coach/blob/master/app/problem_loader.py"
click node_problems "https://github.com/jeyprabu/leetcode-coach/blob/master/problems/problems.json"
click node_graph "https://github.com/jeyprabu/leetcode-coach/blob/master/app/graph.py"
click node_state "https://github.com/jeyprabu/leetcode-coach/blob/master/app/state.py"
click node_analyze "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/analyze.py"
click node_hint "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/hint.py"
click node_input "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/user_input.py"
click node_evaluate "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/evaluate.py"
click node_complexity "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/complexity.py"
click node_limit "https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/max_hints.py"
click node_llm "https://github.com/jeyprabu/leetcode-coach/blob/master/app/llm.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_loader,node_problems toneBlue
class node_graph,node_state,node_analyze,node_hint,node_input,node_evaluate,node_complexity,node_limit toneAmber
class node_llm,node_ollama toneMint
class node_sqlite toneRose
class node_user toneIndigo
```

## Components

### CLI and Problems

- [Session CLI](https://github.com/jeyprabu/leetcode-coach/blob/master/app/main.py): `app/main.py`
- [Problem Loader](https://github.com/jeyprabu/leetcode-coach/blob/master/app/problem_loader.py): `app/problem_loader.py`
- [Problem Repository](https://github.com/jeyprabu/leetcode-coach/blob/master/problems/problems.json): `problems/problems.json`

### Coaching Workflow

- [Workflow Graph](https://github.com/jeyprabu/leetcode-coach/blob/master/app/graph.py): `app/graph.py`
- [Workflow State](https://github.com/jeyprabu/leetcode-coach/blob/master/app/state.py): `app/state.py`
- [Problem Analysis](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/analyze.py): `app/nodes/analyze.py`
- [Progressive Hints](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/hint.py): `app/nodes/hint.py`
- [Answer Interrupt](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/user_input.py): `app/nodes/user_input.py`
- [Answer Evaluation](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/evaluate.py): `app/nodes/evaluate.py`
- [Complexity Feedback](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/complexity.py): `app/nodes/complexity.py`
- [Hint Limit](https://github.com/jeyprabu/leetcode-coach/blob/master/app/nodes/max_hints.py): `app/nodes/max_hints.py`

### Local Model

- [Ollama Client](https://github.com/jeyprabu/leetcode-coach/blob/master/app/llm.py): `app/llm.py`
- **Ollama Runtime**

### Session Persistence

- **SQLite Checkpoints**

### Other components

- **Learner**

## Connections

- Learner → Session CLI: chooses session (evidence: `app/main.py`)
- Session CLI → Problem Loader: loads problem (evidence: `app/main.py`)
- Problem Loader → Problem Repository: reads JSON (evidence: `app/problem_loader.py`)
- Session CLI → Workflow Graph: invokes or resumes (evidence: `app/main.py`)
- Workflow Graph → Workflow State: uses schema (evidence: `app/graph.py`)
- Workflow Graph → Problem Analysis: starts workflow (evidence: `app/graph.py`)
- Problem Analysis → Progressive Hints: routes next (evidence: `app/graph.py`)
- Progressive Hints → Answer Interrupt: routes next (evidence: `app/graph.py`)
- Answer Interrupt → Answer Evaluation: routes next (evidence: `app/graph.py`)
- Answer Evaluation → Progressive Hints: routes if unsolved (evidence: `app/graph.py`)
- Answer Evaluation → Complexity Feedback: routes if solved (evidence: `app/graph.py`)
- Answer Evaluation → Hint Limit: routes at limit (evidence: `app/graph.py`)
- Problem Analysis → Ollama Client: requests analysis (evidence: `app/nodes/analyze.py`)
- Progressive Hints → Ollama Client: requests hint (evidence: `app/nodes/hint.py`)
- Answer Evaluation → Ollama Client: requests evaluation (evidence: `app/nodes/evaluate.py`)
- Complexity Feedback → Ollama Client: requests analysis (evidence: `app/nodes/complexity.py`)
- Ollama Client → Ollama Runtime: runs inference (evidence: `app/llm.py`)
- Workflow Graph → SQLite Checkpoints: checkpoints state (evidence: `app/graph.py`)
- Session CLI → Answer Interrupt: supplies response (evidence: `app/main.py`)
