# amantulsiyan/seekho-math-tutor architecture

> Architecture diagram of the GitHub repository amantulsiyan/seekho-math-tutor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amantulsiyan/seekho-math-tutor
- Repository: https://github.com/amantulsiyan/seekho-math-tutor

## Overview

MathMind is a web tutor that finds the first incorrect line in a student’s maths working, diagnoses a likely misconception, and guides the student through a leak-checked hint ladder. The photo workflow transcribes handwriting for student confirmation before deterministic SymPy verification; typed input can start directly. The tutor also supports adaptive practice and English, Hindi, and Hinglish. Edges reflect the sampled callers and README-documented UI flow; unsampled UI details and other internal calls are not inferred.

Main entry points: [`app/tutor.py`](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/tutor.py) (Tutor state machine), [`app/main.py`](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/main.py) (Web API), [`app/extractor.py`](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/extractor.py) (Photo extractor), [`app/llm/groq_provider.py`](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/llm/groq_provider.py) (Groq provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student experience"]
  node_web_ui["Web interface<br/>[app.js]"]
  node_api["Web API<br/>[main.py]"]
end

subgraph group_ingestion["Photo reading"]
  node_extractor["Photo extractor<br/>[extractor.py]"]
  node_line_locator["Ink line locator<br/>[lines.py]"]
  node_llm_contract["LLM interface<br/>[base.py]"]
  node_groq["Groq provider<br/>[groq_provider.py]"]
end

subgraph group_math["Math reasoning"]
  node_parser["Math line parser<br/>[parser.py]"]
  node_verifier["Solution verifier<br/>[verifier.py]"]
  node_diagnoser["Misconception diagnoser<br/>[diagnoser.py]"]
  node_malrules["Buggy rule library<br/>[malrules.py]"]
end

subgraph group_tutoring["Adaptive tutoring"]
  node_tutor["Tutor state machine<br/>[tutor.py]"]
  node_hints["Hint ladder<br/>[hints.py]"]
end

subgraph group_language["Language and safety"]
  node_translation["Hint translation<br/>[i18n.py]"]
  node_leak_guard["Answer leak guard<br/>[leakguard.py]"]
end

node_student(("Student"))
node_groq_service{{"Groq API"}}

node_student -->|"uploads and replies"| node_web_ui
node_web_ui -->|"calls endpoints"| node_api
node_api -->|"extracts photos"| node_extractor
node_extractor -->|"requests transcription"| node_llm_contract
node_extractor -->|"assigns photo boxes"| node_line_locator
node_extractor -->|"checks transcribed lines"| node_parser
node_api -->|"creates provider"| node_groq
node_groq -->|"implements"| node_llm_contract
node_groq -->|"sends model requests"| node_groq_service
node_api -->|"starts and updates"| node_tutor
node_tutor -->|"parses student work"| node_parser
node_tutor -->|"checks solution steps"| node_verifier
node_tutor -->|"requests diagnosis"| node_diagnoser
node_diagnoser -->|"tests candidate rules"| node_malrules
node_diagnoser -->|"compares solution sets"| node_verifier
node_tutor -->|"builds hint turns"| node_hints
node_tutor -->|"localises messages"| node_translation
node_tutor -->|"checks shown messages"| node_leak_guard

click node_web_ui "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/static/app.js"
click node_api "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/main.py"
click node_tutor "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/tutor.py"
click node_extractor "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/extractor.py"
click node_line_locator "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/lines.py"
click node_llm_contract "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/llm/base.py"
click node_groq "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/llm/groq_provider.py"
click node_parser "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/parser.py"
click node_verifier "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/verifier.py"
click node_diagnoser "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/diagnoser.py"
click node_malrules "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/malrules.py"
click node_hints "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/hints.py"
click node_translation "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/i18n.py"
click node_leak_guard "https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/leakguard.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_web_ui,node_api toneBlue
class node_extractor,node_line_locator,node_llm_contract,node_groq toneAmber
class node_parser,node_verifier,node_diagnoser,node_malrules,node_groq_service toneMint
class node_tutor,node_hints toneRose
class node_translation,node_leak_guard,node_student toneIndigo
```

## Components

### Student experience

- [Web interface](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/static/app.js): `static/app.js`
- [Web API](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/main.py): `app/main.py`

### Photo reading

- [Photo extractor](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/extractor.py): `app/extractor.py`
- [Ink line locator](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/lines.py): `app/lines.py`
- [LLM interface](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/llm/base.py): `app/llm/base.py`
- [Groq provider](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/llm/groq_provider.py): `app/llm/groq_provider.py`

### Math reasoning

- [Math line parser](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/parser.py): `app/parser.py`
- [Solution verifier](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/verifier.py): `app/verifier.py`
- [Misconception diagnoser](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/diagnoser.py): `app/diagnoser.py`
- [Buggy rule library](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/malrules.py): `app/malrules.py`

### Adaptive tutoring

- [Tutor state machine](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/tutor.py): `app/tutor.py`
- [Hint ladder](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/hints.py): `app/hints.py`

### Language and safety

- [Hint translation](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/i18n.py): `app/i18n.py`
- [Answer leak guard](https://github.com/amantulsiyan/seekho-math-tutor/blob/main/app/leakguard.py): `app/leakguard.py`

### Other components

- **Student**
- **Groq API**

## Connections

- Student → Web interface: uploads and replies (evidence: `README.md`)
- Web interface → Web API: calls endpoints (evidence: `README.md`)
- Web API → Photo extractor: extracts photos (evidence: `app/main.py`)
- Photo extractor → LLM interface: requests transcription (evidence: `app/extractor.py`)
- Photo extractor → Ink line locator: assigns photo boxes (evidence: `app/extractor.py`)
- Photo extractor → Math line parser: checks transcribed lines (evidence: `app/extractor.py`)
- Web API → Groq provider: creates provider (evidence: `app/main.py`)
- Groq provider → LLM interface: implements (evidence: `app/llm/groq_provider.py`)
- Groq provider → Groq API: sends model requests (evidence: `app/llm/groq_provider.py`)
- Web API → Tutor state machine: starts and updates (evidence: `app/main.py`)
- Tutor state machine → Math line parser: parses student work (evidence: `app/tutor.py`)
- Tutor state machine → Solution verifier: checks solution steps (evidence: `app/tutor.py`)
- Tutor state machine → Misconception diagnoser: requests diagnosis (evidence: `app/tutor.py`)
- Misconception diagnoser → Buggy rule library: tests candidate rules (evidence: `app/diagnoser.py`)
- Misconception diagnoser → Solution verifier: compares solution sets (evidence: `app/diagnoser.py`)
- Tutor state machine → Hint ladder: builds hint turns (evidence: `app/tutor.py`)
- Tutor state machine → Hint translation: localises messages (evidence: `app/tutor.py`)
- Tutor state machine → Answer leak guard: checks shown messages (evidence: `app/tutor.py`)
