# nyn-05/vision_explainer architecture

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

- Interactive diagram: https://gitdiagram.com/nyn-05/vision_explainer
- Repository: https://github.com/nyn-05/vision_explainer

## Overview

Vision Explainer accepts an image and question, routes a YOLO26X task, uses Gemma vision reasoning to interpret the detections, and returns a persisted report with annotated artifacts. The graph preserves the documented seven-head and run-all modes, evidence/grounding, crop refinement, and history capabilities. Some internal calls are supported only by the README or SOURCE INDEX; unsampled details are not expanded.

Main entry points: [`backend/app.py`](https://github.com/nyn-05/vision_explainer/blob/main/backend/app.py) (FastAPI routes), [`backend/agents.py`](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py) (Analysis orchestrator), [`static/index.html`](https://github.com/nyn-05/vision_explainer/blob/main/static/index.html) (Upload and results UI), [`backend/services.py`](https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py) (YOLO26X heads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_web_ui["Upload and results UI<br/>[index.html]"]
  node_api["FastAPI routes<br/>[app.py]"]
end

subgraph group_workflow["Analysis Workflow"]
  node_orchestrator["Analysis orchestrator<br/>[agents.py]"]
  node_detector["Detector agent<br/>[agents.py]"]
  node_reasoner["Reasoner agent<br/>[agents.py]"]
  node_reporter["Reporter agent<br/>[agents.py]"]
  node_evidence["Evidence and grounding<br/>[utils.py]"]
  node_cropper["Close-up crops<br/>[utils.py]"]
  node_prompt_builders["Prompt builders<br/>[utils.py]"]
end

subgraph group_inference["Inference Services"]
  node_yolo["YOLO26X heads<br/>[services.py]"]
  node_selection["Task selection and validation<br/>[services.py]"]
  node_gemma_client["Vision chat client<br/>[services.py]"]
end

subgraph group_records["Reports and History"]
  node_report_files["Run reports and artifacts<br/>[agents.py]"]
  node_history_store[("History log<br/>[utils.py]")]
end

node_user(("Image analyst"))
node_gemma_server["Local llama.cpp server"]

node_user -->|"submits image"| node_web_ui
node_web_ui -->|"posts analysis"| node_api
node_api -->|"runs analysis"| node_orchestrator
node_api -->|"lists model heads"| node_yolo
node_api -->|"checks health"| node_gemma_client
node_api -->|"reads history"| node_history_store
node_orchestrator -->|"dispatches detection"| node_detector
node_detector -->|"predicts with"| node_yolo
node_yolo -->|"routes task"| node_selection
node_orchestrator -->|"creates crops"| node_cropper
node_orchestrator -->|"builds evidence"| node_evidence
node_orchestrator -->|"requests reasoning"| node_reasoner
node_reasoner -->|"builds prompt"| node_prompt_builders
node_reasoner -->|"requests vision reasoning"| node_gemma_client
node_gemma_client -->|"sends vision chat"| node_gemma_server
node_orchestrator -->|"builds final report"| node_reporter
node_reporter -->|"persists artifacts"| node_report_files
node_reporter -->|"appends history"| node_history_store
node_api -->|"serves interface"| node_web_ui
node_web_ui -->|"views run outputs"| node_report_files

click node_web_ui "https://github.com/nyn-05/vision_explainer/blob/main/static/index.html"
click node_api "https://github.com/nyn-05/vision_explainer/blob/main/backend/app.py"
click node_orchestrator "https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py"
click node_detector "https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py"
click node_reasoner "https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py"
click node_reporter "https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py"
click node_evidence "https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py"
click node_cropper "https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py"
click node_yolo "https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py"
click node_selection "https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py"
click node_gemma_client "https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py"
click node_report_files "https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py"
click node_history_store "https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py"
click node_prompt_builders "https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.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_orchestrator,node_detector,node_reasoner,node_reporter,node_evidence,node_cropper,node_prompt_builders toneAmber
class node_yolo,node_selection,node_gemma_client,node_gemma_server toneMint
class node_report_files,node_history_store toneRose
class node_user toneIndigo
```

## Components

### User Interface

- [Upload and results UI](https://github.com/nyn-05/vision_explainer/blob/main/static/index.html): `static/index.html`
- [FastAPI routes](https://github.com/nyn-05/vision_explainer/blob/main/backend/app.py): `backend/app.py`

### Analysis Workflow

- [Analysis orchestrator](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py): `backend/agents.py`
- [Detector agent](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py): `backend/agents.py`
- [Reasoner agent](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py): `backend/agents.py`
- [Reporter agent](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py): `backend/agents.py`
- [Evidence and grounding](https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py): `backend/utils.py`
- [Close-up crops](https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py): `backend/utils.py`
- [Prompt builders](https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py): `backend/utils.py`

### Inference Services

- [YOLO26X heads](https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py): `backend/services.py`
- [Task selection and validation](https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py): `backend/services.py`
- [Vision chat client](https://github.com/nyn-05/vision_explainer/blob/main/backend/services.py): `backend/services.py`

### Reports and History

- [Run reports and artifacts](https://github.com/nyn-05/vision_explainer/blob/main/backend/agents.py): `backend/agents.py`
- [History log](https://github.com/nyn-05/vision_explainer/blob/main/backend/utils.py): `backend/utils.py`

### Other components

- **Image analyst**
- **Local llama.cpp server**

## Connections

- Image analyst → Upload and results UI: submits image (evidence: `README.md`)
- Upload and results UI → FastAPI routes: posts analysis (evidence: `README.md`)
- FastAPI routes → Analysis orchestrator: runs analysis (evidence: `backend/app.py`)
- FastAPI routes → YOLO26X heads: lists model heads (evidence: `backend/app.py`)
- FastAPI routes → Vision chat client: checks health (evidence: `backend/app.py`)
- FastAPI routes → History log: reads history (evidence: `backend/app.py`)
- Analysis orchestrator → Detector agent: dispatches detection (evidence: `backend/agents.py`)
- Detector agent → YOLO26X heads: predicts with (evidence: `backend/agents.py`)
- YOLO26X heads → Task selection and validation: routes task (evidence: `README.md`)
- Analysis orchestrator → Close-up crops: creates crops (evidence: `backend/agents.py`)
- Analysis orchestrator → Evidence and grounding: builds evidence (evidence: `backend/agents.py`)
- Analysis orchestrator → Reasoner agent: requests reasoning (evidence: `backend/agents.py`)
- Reasoner agent → Prompt builders: builds prompt (evidence: `README.md`)
- Reasoner agent → Vision chat client: requests vision reasoning (evidence: `README.md`)
- Vision chat client → Local llama.cpp server: sends vision chat (evidence: `README.md`)
- Analysis orchestrator → Reporter agent: builds final report (evidence: `README.md`)
- Reporter agent → Run reports and artifacts: persists artifacts (evidence: `backend/agents.py`)
- Reporter agent → History log: appends history (evidence: `backend/utils.py`)
- FastAPI routes → Upload and results UI: serves interface (evidence: `backend/app.py`)
- Upload and results UI → Run reports and artifacts: views run outputs (evidence: `README.md`)
