# kartven2/ai_calc architecture

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

- Interactive diagram: https://gitdiagram.com/kartven2/ai_calc
- Repository: https://github.com/kartven2/ai_calc

## Overview

This is a small desktop natural-language math calculator. A user enters a word problem in the Tkinter interface; its Calculate action sends the text to Ollama, extracts the tagged expression, evaluates it with SymPy, and displays the result or an error. The workflow is implemented in one file, so its distinct responsibilities share that path. The README is empty; the diagram reflects only the inspected source.

Main entry points: [`ai_calc.py`](https://github.com/kartven2/ai_calc/blob/main/ai_calc.py) (Calculation Handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("User"))
node_ui["Tkinter Interface<br/>[ai_calc.py]"]
node_handler["Calculation Handler<br/>[ai_calc.py]"]
node_ollama["Ollama Model"]
node_extract["Expression Extraction<br/>[ai_calc.py]"]
node_sympy["SymPy Evaluation"]
node_display["Result Display<br/>[ai_calc.py]"]

node_user -->|"enters problem"| node_ui
node_ui -->|"invokes on click"| node_handler
node_handler -->|"requests expression"| node_ollama
node_handler -->|"extracts expression"| node_extract
node_handler -->|"evaluates expression"| node_sympy
node_handler -->|"updates result"| node_display

click node_ui "https://github.com/kartven2/ai_calc/blob/main/ai_calc.py"
click node_handler "https://github.com/kartven2/ai_calc/blob/main/ai_calc.py"
click node_extract "https://github.com/kartven2/ai_calc/blob/main/ai_calc.py"
click node_display "https://github.com/kartven2/ai_calc/blob/main/ai_calc.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_user toneBlue
class node_ui,node_extract,node_display toneTeal
class node_handler toneMint
class node_ollama,node_sympy toneIndigo
```

## Components

### Other components

- **User**
- [Tkinter Interface](https://github.com/kartven2/ai_calc/blob/main/ai_calc.py): `ai_calc.py`
- [Calculation Handler](https://github.com/kartven2/ai_calc/blob/main/ai_calc.py): `ai_calc.py`
- **Ollama Model**
- [Expression Extraction](https://github.com/kartven2/ai_calc/blob/main/ai_calc.py): `ai_calc.py`
- **SymPy Evaluation**
- [Result Display](https://github.com/kartven2/ai_calc/blob/main/ai_calc.py): `ai_calc.py`

## Connections

- User → Tkinter Interface: enters problem (evidence: `ai_calc.py`)
- Tkinter Interface → Calculation Handler: invokes on click (evidence: `ai_calc.py`)
- Calculation Handler → Ollama Model: requests expression (evidence: `ai_calc.py`)
- Calculation Handler → Expression Extraction: extracts expression (evidence: `ai_calc.py`)
- Calculation Handler → SymPy Evaluation: evaluates expression (evidence: `ai_calc.py`)
- Calculation Handler → Result Display: updates result (evidence: `ai_calc.py`)
