# jacob-sauve/leafcutter-lite architecture

> Architecture diagram of the GitHub repository jacob-sauve/leafcutter-lite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jacob-sauve/leafcutter-lite
- Repository: https://github.com/jacob-sauve/leafcutter-lite

## Overview

Leafcutter Lite is a local-model desktop assistant: a user enters a request, the prompt and Ollama model produce JSON, and the program either displays a chat response or dispatches a file tool and displays its result. File listing, overwriting, and appending are distinct tool capabilities. Runtime behavior is concentrated in main.py; the graph reflects the documented workflow and sampled implementation.

Main entry points: [`main.py`](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py) (Interactive Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User Interaction"]
  node_cli["Interactive Loop<br/>[main.py]"]
  node_display["Output Display<br/>[main.py]"]
end

subgraph group_agent["Model Workflow"]
  node_prompt["Prompt Template<br/>[main.py]"]
  node_ollama["Ollama Model"]
  node_json["JSON Parsing<br/>[main.py]"]
  node_dispatch["Tool Dispatch<br/>[main.py]"]
end

subgraph group_files["File Tools"]
  node_list["List Files<br/>[main.py]"]
  node_write["Write File<br/>[main.py]"]
  node_append["Append File<br/>[main.py]"]
  node_filesystem["Local Filesystem"]
end

node_user(("User"))

node_user -->|"enters request"| node_cli
node_cli -->|"invokes chain"| node_prompt
node_prompt -->|"formats prompt"| node_ollama
node_ollama -->|"returns response"| node_json
node_cli -->|"parses content"| node_json
node_cli -->|"dispatches tool"| node_dispatch
node_dispatch -->|"invokes"| node_list
node_dispatch -->|"invokes"| node_write
node_dispatch -->|"invokes"| node_append
node_list -->|"lists files"| node_filesystem
node_write -->|"writes file"| node_filesystem
node_append -->|"appends file"| node_filesystem
node_cli -->|"prints response"| node_display
node_cli -->|"prints tool result"| node_display
node_display -->|"shows output"| node_user

click node_cli "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_prompt "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_json "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_dispatch "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_display "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_list "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_write "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py"
click node_append "https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.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_display,node_user toneBlue
class node_prompt,node_ollama,node_json,node_dispatch toneAmber
class node_list,node_write,node_append,node_filesystem toneMint
```

## Components

### User Interaction

- [Interactive Loop](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- [Output Display](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`

### Model Workflow

- [Prompt Template](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- **Ollama Model**
- [JSON Parsing](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- [Tool Dispatch](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`

### File Tools

- [List Files](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- [Write File](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- [Append File](https://github.com/jacob-sauve/leafcutter-lite/blob/main/main.py): `main.py`
- **Local Filesystem**

### Other components

- **User**

## Connections

- User → Interactive Loop: enters request
- Interactive Loop → Prompt Template: invokes chain
- Prompt Template → Ollama Model: formats prompt
- Ollama Model → JSON Parsing: returns response
- Interactive Loop → JSON Parsing: parses content
- Interactive Loop → Tool Dispatch: dispatches tool
- Tool Dispatch → List Files: invokes
- Tool Dispatch → Write File: invokes
- Tool Dispatch → Append File: invokes
- List Files → Local Filesystem: lists files
- Write File → Local Filesystem: writes file
- Append File → Local Filesystem: appends file
- Interactive Loop → Output Display: prints response
- Interactive Loop → Output Display: prints tool result
- Output Display → User: shows output
