# vasteri/price-tag-recognizer architecture

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

- Interactive diagram: https://gitdiagram.com/vasteri/price-tag-recognizer
- Repository: https://github.com/vasteri/price-tag-recognizer

## Overview

1. This repository is a small distributed application for recognizing price tags from images. The architecture is split into three runtime areas: a Python backend API, a separate Python recognition worker, and a static browser frontend.

2. The **backend** directory is the orchestration layer. It contains `main.py`, `config.py`, and `celery_app.py`, which suggests the backend exposes the public API and also produces/consumes asynchronous jobs through Celery. `scripts/start_server.sh` is the container/startup entrypoint for that service.

3. The **recognizer** directory is the compute-heavy worker service. Its code is organized around OCR and post-processing: `ocr.py` for text extraction, `tracker.py` for tracking objects/regions, `recognizer.py` as the main recognition logic, and `tasks.py` as the Celery task entrypoint. `download_model.py` indicates the worker may fetch or initialize model assets at startup, and `assets/` holds local model/data files.

4. The two Python services likely communicate through a **Celery broker/backend** rather than direct synchronous calls. Both `backend/src/celery_app.py` and `recognizer/src/celery_app.py` exist, which is a strong signal that the backend enqueues recognition jobs and the recognizer executes them asynchronously.

5. The **frontend** is purely static: `index.html`, `script.js`, and `style.css`. There is no frontend build system in the tree, so the browser UI is likely served as plain static files and talks to the backend over HTTP.

6. The `infra/nginx.conf` file indicates **Nginx** is used as the edge server/reverse proxy. In this setup, Nginx most likely serves the static frontend and forwards API requests to the backend container, keeping the browser-facing origin simple.

7. `docker-compose.yml` is the main deployment glue. It probably wires together the backend, recognizer, and Nginx containers, and may also define the Celery broker/service needed for task dispatch. The architecture is therefore container-first rather than monolithic.

8. The main data flow is: user interacts with the static UI → browser sends an image/request to the backend → backend submits a Celery job → recognizer processes the image with OCR/model logic → results return to the backend and are sent back to the UI. This separation keeps the request path lightweight while isolating expensive recognition work.

9. There is no obvious database or long-term persistence layer in the file tree. That suggests the system is either stateless or relies on Celery infrastructure and in-memory/model assets rather than a dedicated application datastore.

10. The key architectural boundary is between **API/orchestration** and **ML/OCR execution**. Anything user-facing or request-handling lives in `backend` and `frontend`; anything compute-intensive or model-specific lives in `recognizer`.

11. For an architecture diagram, the important external surfaces are: the browser, Nginx, the backend API container, the recognizer worker container, and the Celery messaging layer connecting the Python services.

Main entry points: [`backend/src/main.py`](https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/main.py) (Server), [`docker-compose.yml`](https://github.com/vasteri/price-tag-recognizer/blob/main/docker-compose.yml) (Compose), [`recognizer/src/recognizer.py`](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/recognizer.py) (Recognizer), [`infra/nginx.conf`](https://github.com/vasteri/price-tag-recognizer/blob/main/infra/nginx.conf) (Nginx)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_browser(("Browser<br/>client"))
  node_static_ui["Static UI<br/>html/js/css<br/>[index.html]"]
end

subgraph group_backend["Backend"]
  node_backend_entry["Server<br/>API entrypoint<br/>[main.py]"]
  node_backend_config["Backend config<br/>settings<br/>[config.py]"]
  node_backend_celery["Backend Celery<br/>task client<br/>[celery_app.py]"]
  node_backend_startup["Start script<br/>container entrypoint<br/>[start_server.sh]"]
end

subgraph group_recognizer["Recognizer"]
  node_worker_main["Worker<br/>task consumer<br/>[tasks.py]"]
  node_worker_celery["Worker Celery<br/>task worker<br/>[celery_app.py]"]
  node_recognizer_core["Recognizer<br/>pipeline<br/>[recognizer.py]"]
  node_ocr["OCR<br/>text extraction<br/>[ocr.py]"]
  node_tracker["Tracker<br/>region tracking<br/>[tracker.py]"]
  node_model_boot["Model setup<br/>asset bootstrap<br/>[download_model.py]"]
  node_model_assets[("Assets<br/>model/data files")]
end

subgraph group_infra["Infra"]
  node_nginx["Nginx<br/>reverse proxy<br/>[nginx.conf]"]
  node_compose["Compose<br/>deployment spec<br/>[docker-compose.yml]"]
  node_broker["Broker<br/>messaging bus"]
end

node_browser -->|"HTTP"| node_nginx
node_nginx -->|"serve"| node_static_ui
node_nginx -->|"route API"| node_backend_entry
node_backend_startup -->|"launches"| node_backend_entry
node_backend_entry -.->|"reads"| node_backend_config
node_backend_entry -->|"enqueues"| node_backend_celery
node_backend_celery -->|"publish"| node_broker
node_broker -->|"deliver"| node_worker_celery
node_worker_main -->|"consumes"| node_worker_celery
node_worker_celery -->|"runs"| node_recognizer_core
node_recognizer_core -->|"uses"| node_ocr
node_recognizer_core -->|"uses"| node_tracker
node_recognizer_core -.->|"initializes"| node_model_boot
node_model_boot -->|"loads"| node_model_assets
node_worker_main -.->|"depends on"| node_model_assets
node_backend_entry -->|"response"| node_browser
node_compose -.->|"orchestrates"| node_nginx
node_compose -.->|"orchestrates"| node_backend_entry
node_compose -.->|"orchestrates"| node_worker_main
node_compose -.->|"orchestrates"| node_broker

click node_static_ui "https://github.com/vasteri/price-tag-recognizer/blob/main/frontend/static/index.html"
click node_nginx "https://github.com/vasteri/price-tag-recognizer/blob/main/infra/nginx.conf"
click node_compose "https://github.com/vasteri/price-tag-recognizer/blob/main/docker-compose.yml"
click node_backend_entry "https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/main.py"
click node_backend_config "https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/config.py"
click node_backend_celery "https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/celery_app.py"
click node_backend_startup "https://github.com/vasteri/price-tag-recognizer/blob/main/backend/scripts/start_server.sh"
click node_worker_main "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/tasks.py"
click node_worker_celery "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/celery_app.py"
click node_recognizer_core "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/recognizer.py"
click node_ocr "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/ocr.py"
click node_tracker "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/tracker.py"
click node_model_boot "https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/download_model.py"
click node_model_assets "https://github.com/vasteri/price-tag-recognizer/tree/main/recognizer/assets"

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,node_static_ui toneBlue
class node_backend_entry,node_backend_config,node_backend_celery,node_backend_startup toneAmber
class node_worker_main,node_worker_celery,node_recognizer_core,node_ocr,node_tracker,node_model_boot,node_model_assets toneMint
class node_nginx,node_compose,node_broker toneRose
```

## Components

### Frontend

Static browser UI

- **Browser**: client · User-facing web client
- [Static UI](https://github.com/vasteri/price-tag-recognizer/blob/main/frontend/static/index.html): html/js/css · Plain browser interface · `frontend/static/index.html`

### Backend

API and orchestration service

- [Server](https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/main.py): API entrypoint · Backend startup and request handling · `backend/src/main.py`
- [Backend config](https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/config.py): settings · Backend runtime configuration · `backend/src/config.py`
- [Backend Celery](https://github.com/vasteri/price-tag-recognizer/blob/main/backend/src/celery_app.py): task client · Dispatches recognition jobs · `backend/src/celery_app.py`
- [Start script](https://github.com/vasteri/price-tag-recognizer/blob/main/backend/scripts/start_server.sh): container entrypoint · Backend service bootstrap · `backend/scripts/start_server.sh`

### Recognizer

Async OCR and recognition worker

- [Worker](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/tasks.py): task consumer · Recognition worker entrypoint · `recognizer/src/tasks.py`
- [Worker Celery](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/celery_app.py): task worker · Celery integration for recognition jobs · `recognizer/src/celery_app.py`
- [Recognizer](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/recognizer.py): pipeline · Main image recognition pipeline · `recognizer/src/recognizer.py`
- [OCR](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/ocr.py): text extraction · Extracts text from images · `recognizer/src/ocr.py`
- [Tracker](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/tracker.py): region tracking · Tracks detected regions or objects · `recognizer/src/tracker.py`
- [Model setup](https://github.com/vasteri/price-tag-recognizer/blob/main/recognizer/src/download_model.py): asset bootstrap · Downloads or initializes model assets · `recognizer/src/download_model.py`
- [Assets](https://github.com/vasteri/price-tag-recognizer/tree/main/recognizer/assets): model/data files · Local worker assets and model data · `recognizer/assets`

### Infra

Edge and deployment wiring

- [Nginx](https://github.com/vasteri/price-tag-recognizer/blob/main/infra/nginx.conf): reverse proxy · Edge server for static files and routing · `infra/nginx.conf`
- [Compose](https://github.com/vasteri/price-tag-recognizer/blob/main/docker-compose.yml): deployment spec · Container wiring and service topology · `docker-compose.yml`
- **Broker**: messaging bus · Celery queue connecting services

## Connections

- Browser → Nginx: HTTP · User requests enter through the edge proxy
- Nginx → Static UI: serve · Serves the static browser application
- Nginx → Server: route API · Forwards API calls to the backend service
- Start script → Server: launches · Container entrypoint starts the API process
- Server → Backend config: reads · Loads runtime settings
- Server → Backend Celery: enqueues · Submits recognition work asynchronously
- Backend Celery → Broker: publish · Sends Celery jobs to the message layer
- Broker → Worker Celery: deliver · Routes queued tasks to the worker
- Worker → Worker Celery: consumes · Worker process is driven through Celery
- Worker Celery → Recognizer: runs · Delegates jobs to the recognition pipeline
- Recognizer → OCR: uses · Performs OCR during recognition
- Recognizer → Tracker: uses · Tracks regions or detections
- Recognizer → Model setup: initializes · Bootstraps model dependencies
- Model setup → Assets: loads · Uses local assets and model files
- Worker → Assets: depends on · Worker runtime depends on bundled assets
- Server → Browser: response · Returns recognition results to the UI
- Compose → Nginx: orchestrates · Defines deployment of the edge proxy
- Compose → Server: orchestrates · Defines backend service container
- Compose → Worker: orchestrates · Defines recognizer worker container
- Compose → Broker: orchestrates · Includes the messaging service dependency
