# hzylmf/od-annotation architecture

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

- Interactive diagram: https://gitdiagram.com/hzylmf/od-annotation
- Repository: https://github.com/hzylmf/od-annotation

## Overview

This Flask application supports browser-based object-detection annotation: users select configured classes, annotate image samples with bounding boxes, and save results; a separate command converts saved annotations to VOC2007 files and splits. The graph preserves the documented UI interactions and conversion capability, but the frontend templates and JavaScript were not sampled, so their connections rely on README descriptions. Database helpers are present for user checks, though the sampled app routes do not show authentication wiring.

Main entry points: [`app.py`](https://github.com/hzylmf/od-annotation/blob/master/app.py) (HTTP routes), [`templates/index.html`](https://github.com/hzylmf/od-annotation/blob/master/templates/index.html) (Annotation page), [`utils/tool.py`](https://github.com/hzylmf/od-annotation/blob/master/utils/tool.py) (VOC conversion), [`utils/db_helper.py`](https://github.com/hzylmf/od-annotation/blob/master/utils/db_helper.py) (SQL access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Annotation interface"]
  node_browser_ui["Annotation page<br/>[index.html]"]
  node_drawing["Box interactions<br/>[draw_roi.js]"]
  node_client_scripts["Client controls<br/>[custom.js]"]
end

subgraph group_service["Flask service"]
  node_flask["HTTP routes<br/>[app.py]"]
  node_label_loading["Label loading<br/>[tool.py]"]
  node_voc_conversion["VOC conversion<br/>[tool.py]"]
end

subgraph group_data["Annotation data"]
  node_sample_images["Image samples"]
  node_label_config["Class definitions<br/>[label_config.txt]"]
  node_saved_annotations[("Saved annotations<br/>[annotation.txt]")]
  node_voc_output["VOC dataset files"]
end

subgraph group_support["Runtime support"]
  node_xml_writer["XML serialization<br/>[xml2dict.py]"]
  node_database_helper["SQL access<br/>[db_helper.py]"]
  node_runtime_config["Runtime configuration<br/>[config.py]"]
  node_logging["Logging<br/>[logger_manager.py]"]
end

node_annotator(("Annotator"))
node_mysql[("MySQL")]

node_annotator -->|"uses"| node_browser_ui
node_browser_ui -.->|"offers drawing"| node_drawing
node_browser_ui -.->|"uses controls"| node_client_scripts
node_browser_ui -.->|"requests samples"| node_flask
node_browser_ui -.->|"submits annotations"| node_flask
node_flask -->|"serves images"| node_sample_images
node_flask -->|"loads labels"| node_label_loading
node_label_loading -->|"reads classes"| node_label_config
node_flask -->|"appends results"| node_saved_annotations
node_flask -->|"dispatches conversion"| node_voc_conversion
node_voc_conversion -->|"reads results"| node_saved_annotations
node_voc_conversion -->|"serializes XML"| node_xml_writer
node_voc_conversion -->|"writes VOC files"| node_voc_output
node_database_helper -->|"queries"| node_mysql
node_flask -->|"configures service"| node_runtime_config
node_database_helper -->|"reads settings"| node_runtime_config
node_database_helper -->|"logs errors"| node_logging
node_label_loading -->|"logs errors"| node_logging

click node_browser_ui "https://github.com/hzylmf/od-annotation/blob/master/templates/index.html"
click node_drawing "https://github.com/hzylmf/od-annotation/blob/master/static/build/js/draw_roi.js"
click node_client_scripts "https://github.com/hzylmf/od-annotation/blob/master/static/build/js/custom.js"
click node_flask "https://github.com/hzylmf/od-annotation/blob/master/app.py"
click node_sample_images "https://github.com/hzylmf/od-annotation/tree/master/dataset"
click node_label_config "https://github.com/hzylmf/od-annotation/blob/master/annotation/label_config.txt"
click node_saved_annotations "https://github.com/hzylmf/od-annotation/blob/master/annotation/annotation.txt"
click node_label_loading "https://github.com/hzylmf/od-annotation/blob/master/utils/tool.py"
click node_voc_conversion "https://github.com/hzylmf/od-annotation/blob/master/utils/tool.py"
click node_xml_writer "https://github.com/hzylmf/od-annotation/blob/master/utils/xml2dict.py"
click node_voc_output "https://github.com/hzylmf/od-annotation/tree/master/annotation/VOC2007"
click node_database_helper "https://github.com/hzylmf/od-annotation/blob/master/utils/db_helper.py"
click node_runtime_config "https://github.com/hzylmf/od-annotation/blob/master/config.py"
click node_logging "https://github.com/hzylmf/od-annotation/blob/master/logger_manager.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_browser_ui,node_drawing,node_client_scripts toneBlue
class node_flask,node_label_loading,node_voc_conversion,node_mysql toneAmber
class node_sample_images,node_label_config,node_saved_annotations,node_voc_output toneMint
class node_xml_writer,node_database_helper,node_runtime_config,node_logging toneRose
class node_annotator toneIndigo
```

## Components

### Annotation interface

- [Annotation page](https://github.com/hzylmf/od-annotation/blob/master/templates/index.html): `templates/index.html`
- [Box interactions](https://github.com/hzylmf/od-annotation/blob/master/static/build/js/draw_roi.js): `static/build/js/draw_roi.js`
- [Client controls](https://github.com/hzylmf/od-annotation/blob/master/static/build/js/custom.js): `static/build/js/custom.js`

### Flask service

- [HTTP routes](https://github.com/hzylmf/od-annotation/blob/master/app.py): `app.py`
- [Label loading](https://github.com/hzylmf/od-annotation/blob/master/utils/tool.py): `utils/tool.py`
- [VOC conversion](https://github.com/hzylmf/od-annotation/blob/master/utils/tool.py): `utils/tool.py`

### Annotation data

- [Image samples](https://github.com/hzylmf/od-annotation/tree/master/dataset): `dataset`
- [Class definitions](https://github.com/hzylmf/od-annotation/blob/master/annotation/label_config.txt): `annotation/label_config.txt`
- [Saved annotations](https://github.com/hzylmf/od-annotation/blob/master/annotation/annotation.txt): `annotation/annotation.txt`
- [VOC dataset files](https://github.com/hzylmf/od-annotation/tree/master/annotation/VOC2007): `annotation/VOC2007`

### Runtime support

- [XML serialization](https://github.com/hzylmf/od-annotation/blob/master/utils/xml2dict.py): `utils/xml2dict.py`
- [SQL access](https://github.com/hzylmf/od-annotation/blob/master/utils/db_helper.py): `utils/db_helper.py`
- [Runtime configuration](https://github.com/hzylmf/od-annotation/blob/master/config.py): `config.py`
- [Logging](https://github.com/hzylmf/od-annotation/blob/master/logger_manager.py): `logger_manager.py`

### Other components

- **Annotator**
- **MySQL**

## Connections

- Annotator → Annotation page: uses (evidence: `README.md`)
- Annotation page → Box interactions: offers drawing
- Annotation page → Client controls: uses controls
- Annotation page → HTTP routes: requests samples (evidence: `README.md`)
- Annotation page → HTTP routes: submits annotations (evidence: `README.md`)
- HTTP routes → Image samples: serves images (evidence: `app.py`)
- HTTP routes → Label loading: loads labels (evidence: `app.py`)
- Label loading → Class definitions: reads classes (evidence: `utils/tool.py`)
- HTTP routes → Saved annotations: appends results (evidence: `app.py`)
- HTTP routes → VOC conversion: dispatches conversion (evidence: `app.py`)
- VOC conversion → Saved annotations: reads results (evidence: `utils/tool.py`)
- VOC conversion → XML serialization: serializes XML (evidence: `utils/tool.py`)
- VOC conversion → VOC dataset files: writes VOC files (evidence: `utils/tool.py`)
- SQL access → MySQL: queries (evidence: `utils/db_helper.py`)
- HTTP routes → Runtime configuration: configures service (evidence: `app.py`)
- SQL access → Runtime configuration: reads settings (evidence: `utils/db_helper.py`)
- SQL access → Logging: logs errors (evidence: `utils/db_helper.py`)
- Label loading → Logging: logs errors (evidence: `utils/tool.py`)
