# scheckmedia/photils-cli architecture

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

- Interactive diagram: https://gitdiagram.com/scheckmedia/photils-cli
- Repository: https://github.com/scheckmedia/photils-cli

## Overview

Photils-cli is an offline image-tagging command-line application. The principal workflow accepts an image path, preprocesses the image, runs the local neural-network model, maps predictions to labels, and prints or writes the resulting tags; confidence values are optional. Users can customize or translate labels with a per-user override file. The graph separates CLI handling, inference stages, and tag resources. The sampled source shows the main runtime wiring; README-described platform-specific override locations are not independently verified here.

Main entry points: [`src/inference.cpp`](https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp) (Inference coordinator), [`src/main.cpp`](https://github.com/scheckmedia/photils-cli/blob/main/src/main.cpp) (Argument handling), [`res/photils.onnx`](https://github.com/scheckmedia/photils-cli/blob/main/res/photils.onnx) (ONNX model), [`res/labels.json`](https://github.com/scheckmedia/photils-cli/blob/main/res/labels.json) (Label catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_main["Argument handling<br/>[main.cpp]"]
end

subgraph group_inference["Inference"]
  node_engine["Inference coordinator<br/>[inference.cpp]"]
  node_preprocess["Image preprocessing<br/>[inference.cpp]"]
  node_predict["Model prediction<br/>[inference.cpp]"]
  node_model["ONNX model<br/>[photils.onnx]"]
end

subgraph group_labels["Tag resources"]
  node_labels_file["Label catalog<br/>[labels.json]"]
  node_override["Label overrides<br/>[inference.cpp]"]
  node_data_home["User data paths<br/>[helper.cpp]"]
end

node_user(("CLI user"))
node_image["Input image"]
node_stdout["Standard output"]
node_output_file["Output file"]

node_user -->|"provides arguments"| node_main
node_main -->|"requests tags"| node_engine
node_main -->|"names image"| node_image
node_engine -->|"prepares image"| node_preprocess
node_preprocess -->|"reads image"| node_image
node_engine -->|"loads labels"| node_labels_file
node_engine -->|"loads model"| node_model
node_engine -->|"gets data path"| node_data_home
node_engine -->|"loads overrides"| node_override
node_override -->|"reads override file"| node_data_home
node_engine -->|"runs inference"| node_predict
node_predict -->|"forwards input"| node_model
node_predict -->|"maps scores"| node_labels_file
node_predict -->|"substitutes labels"| node_override
node_engine -->|"returns predictions"| node_main
node_main -->|"prints tags"| node_stdout
node_main -->|"writes tags"| node_output_file

click node_main "https://github.com/scheckmedia/photils-cli/blob/main/src/main.cpp"
click node_engine "https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp"
click node_preprocess "https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp"
click node_predict "https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp"
click node_model "https://github.com/scheckmedia/photils-cli/blob/main/res/photils.onnx"
click node_labels_file "https://github.com/scheckmedia/photils-cli/blob/main/res/labels.json"
click node_override "https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp"
click node_data_home "https://github.com/scheckmedia/photils-cli/blob/main/src/helper.cpp"

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_main,node_user toneBlue
class node_engine,node_preprocess,node_predict,node_model toneAmber
class node_labels_file,node_override,node_data_home toneMint
class node_image,node_stdout,node_output_file toneIndigo
```

## Components

### CLI

- [Argument handling](https://github.com/scheckmedia/photils-cli/blob/main/src/main.cpp): `src/main.cpp`

### Inference

- [Inference coordinator](https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp): `src/inference.cpp`
- [Image preprocessing](https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp): `src/inference.cpp`
- [Model prediction](https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp): `src/inference.cpp`
- [ONNX model](https://github.com/scheckmedia/photils-cli/blob/main/res/photils.onnx): `res/photils.onnx`

### Tag resources

- [Label catalog](https://github.com/scheckmedia/photils-cli/blob/main/res/labels.json): `res/labels.json`
- [Label overrides](https://github.com/scheckmedia/photils-cli/blob/main/src/inference.cpp): `src/inference.cpp`
- [User data paths](https://github.com/scheckmedia/photils-cli/blob/main/src/helper.cpp): `src/helper.cpp`

### Other components

- **CLI user**
- **Input image**
- **Standard output**
- **Output file**

## Connections

- CLI user → Argument handling: provides arguments
- Argument handling → Inference coordinator: requests tags
- Argument handling → Input image: names image
- Inference coordinator → Image preprocessing: prepares image
- Image preprocessing → Input image: reads image
- Inference coordinator → Label catalog: loads labels
- Inference coordinator → ONNX model: loads model
- Inference coordinator → User data paths: gets data path
- Inference coordinator → Label overrides: loads overrides
- Label overrides → User data paths: reads override file
- Inference coordinator → Model prediction: runs inference
- Model prediction → ONNX model: forwards input
- Model prediction → Label catalog: maps scores
- Model prediction → Label overrides: substitutes labels
- Inference coordinator → Argument handling: returns predictions
- Argument handling → Standard output: prints tags
- Argument handling → Output file: writes tags
